Skip to content

Commit

Permalink
feat: getMetadata template
Browse files Browse the repository at this point in the history
  • Loading branch information
rin-st committed Nov 8, 2024
1 parent 59bde81 commit 1d20780
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import type { Metadata } from "next";
import { withDefaults } from '../../../../../utils.js'

const contents = ({ titleTemplate, thumbnailPath }) =>
`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}";
export const getMetadata = ({
title,
description,
imageRelativePath = "/thumbnail.jpg",
imageRelativePath = "${thumbnailPath}",
}: {
title: string;
description: string;
imageRelativePath?: string;
}): Metadata => {
const imageUrl = `${baseUrl}${imageRelativePath}`;
const imageUrl = \`\${baseUrl}\${imageRelativePath}\`;
return {
metadataBase: new URL(baseUrl),
Expand Down Expand Up @@ -48,3 +51,9 @@ export const getMetadata = ({
},
};
};
`

export default withDefaults(contents, {
titleTemplate: "%s | Scaffold-ETH 2",
thumbnailPath: "/thumbnail.jpg",
})

0 comments on commit 1d20780

Please sign in to comment.