mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-26 01:45:25 -04:00
33 lines
859 B
TypeScript
33 lines
859 B
TypeScript
import defaultMetadata from "../config/seo";
|
|
import type { Metadata } from "next";
|
|
|
|
/**
|
|
* Helper function to deep merge a page's metadata into the default site metadata
|
|
* @see https://nextjs.org/docs/app/api-reference/functions/generate-metadata
|
|
*/
|
|
export const addMetadata = (metadata: Metadata): Metadata => {
|
|
return {
|
|
...defaultMetadata,
|
|
...metadata,
|
|
openGraph: {
|
|
...defaultMetadata.openGraph,
|
|
title: metadata.title as string,
|
|
description: metadata.description as string,
|
|
url: metadata.alternates?.canonical as string,
|
|
...metadata.openGraph,
|
|
},
|
|
twitter: {
|
|
...defaultMetadata.twitter,
|
|
...metadata.twitter,
|
|
},
|
|
alternates: {
|
|
...defaultMetadata.alternates,
|
|
...metadata.alternates,
|
|
},
|
|
other: {
|
|
...defaultMetadata.other,
|
|
...metadata.other,
|
|
},
|
|
};
|
|
};
|