Initial commit with 🏗️ Scaffold-ETH 2 @ 1.0.5
This commit is contained in:
56
packages/nextjs/utils/scaffold-eth/getMetadata.ts
Normal file
56
packages/nextjs/utils/scaffold-eth/getMetadata.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
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 | SpeedRunEthereum";
|
||||
|
||||
export const getMetadata = ({
|
||||
title,
|
||||
description,
|
||||
imageRelativePath = "/thumbnail-challenge.png",
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
imageRelativePath?: string;
|
||||
}): Metadata => {
|
||||
const imageUrl = `${baseUrl}${imageRelativePath}`;
|
||||
|
||||
return {
|
||||
metadataBase: new URL(baseUrl),
|
||||
title: {
|
||||
default: title,
|
||||
template: titleTemplate,
|
||||
},
|
||||
description: description,
|
||||
openGraph: {
|
||||
title: {
|
||||
default: title,
|
||||
template: titleTemplate,
|
||||
},
|
||||
description: description,
|
||||
images: [
|
||||
{
|
||||
url: imageUrl,
|
||||
},
|
||||
],
|
||||
},
|
||||
twitter: {
|
||||
title: {
|
||||
default: title,
|
||||
template: titleTemplate,
|
||||
},
|
||||
description: description,
|
||||
images: [imageUrl],
|
||||
},
|
||||
icons: {
|
||||
icon: [
|
||||
{
|
||||
url: "/favicon.png",
|
||||
sizes: "32x32",
|
||||
type: "image/png",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user