Skip to content

Commit

Permalink
Add getmetadata template... in a weird way...
Browse files Browse the repository at this point in the history
  • Loading branch information
portdeveloper committed Nov 1, 2024
1 parent e8d6227 commit 0816599
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { stringify, withDefaults } from '../../../../../utils.js'

const contents = ({ titleTemplate, extraIcons, extraMetadata }) => `
import type { Metadata } from "next";
const baseUrl = process.env.VERCEL_PROJECT_PRODUCTION_URL
? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`
: `http://localhost:${process.env.PORT || 3000}`;
const titleTemplate = "%s | Scaffold-ETH 2";
? \`https://\${process.env.VERCEL_PROJECT_PRODUCTION_URL}\`
: \`http://localhost:\${process.env.PORT || 3000}\`;
const titleTemplate = "${titleTemplate[0] || '%s | Scaffold-ETH 2'}";
export const getMetadata = ({
title,
Expand All @@ -14,7 +17,7 @@ export const getMetadata = ({
description: string;
imageRelativePath?: string;
}): Metadata => {
const imageUrl = `${baseUrl}${imageRelativePath}`;
const imageUrl = \`\${baseUrl}\${imageRelativePath}\`;
return {
metadataBase: new URL(baseUrl),
Expand Down Expand Up @@ -45,6 +48,15 @@ export const getMetadata = ({
},
icons: {
icon: [{ url: "/favicon.png", sizes: "32x32", type: "image/png" }],
${extraIcons[0] ? Object.entries(extraIcons[0]).map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(',\n ') : ''}
},
${extraMetadata[0] ? Object.entries(extraMetadata[0]).map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(',\n ') : ''}
};
};
`

export default withDefaults(contents, {
titleTemplate: '',
extraIcons: {},
extraMetadata: {}
})

0 comments on commit 0816599

Please sign in to comment.