Template
Initial react editor website template
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import type { Metadata } from 'next';
|
||||
import { site } from '@/config/site';
|
||||
|
||||
interface EditorPage {
|
||||
root?: {
|
||||
props?: {
|
||||
title?: string;
|
||||
description?: string;
|
||||
ogImage?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function pageMetadata(
|
||||
page: EditorPage,
|
||||
overrides: { title?: string; description?: string; path?: string } = {}
|
||||
): Metadata {
|
||||
const props = page.root?.props ?? {};
|
||||
const title = overrides.title ?? props.title ?? site.name;
|
||||
const description = overrides.description ?? props.description ?? site.description;
|
||||
const image = props.ogImage;
|
||||
|
||||
return {
|
||||
title: { absolute: title },
|
||||
description,
|
||||
alternates: overrides.path ? { canonical: overrides.path } : undefined,
|
||||
openGraph: {
|
||||
type: 'website',
|
||||
siteName: site.name,
|
||||
title,
|
||||
description,
|
||||
url: overrides.path ?? '/',
|
||||
images: image ? [{ url: image, alt: title }] : undefined,
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
title,
|
||||
description,
|
||||
images: image ? [image] : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user