diff --git a/templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts b/templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts.template.mjs similarity index 61% rename from templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts rename to templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts.template.mjs index ad531aea6..935b65dbb 100644 --- a/templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts +++ b/templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts.template.mjs @@ -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), @@ -48,3 +51,9 @@ export const getMetadata = ({ }, }; }; +` + +export default withDefaults(contents, { + titleTemplate: "%s | Scaffold-ETH 2", + thumbnailPath: "/thumbnail.jpg", +})