mirror of
https://github.com/SrIzan10/spongebin.git
synced 2026-05-01 11:05:09 +00:00
feat: generated metadata titles
This commit is contained in:
@@ -4,11 +4,11 @@ import { MonacoEditor } from "~/components/monaco-editor";
|
||||
import { EditorProvider } from "~/components/editor-provider";
|
||||
import { Header } from "~/components/header";
|
||||
|
||||
export default async function PastePage({
|
||||
params,
|
||||
}: {
|
||||
interface Props {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
}
|
||||
|
||||
export default async function PastePage({ params }: Props) {
|
||||
const { id } = await params;
|
||||
const paste = await getPasteById(id);
|
||||
|
||||
@@ -25,3 +25,23 @@ export default async function PastePage({
|
||||
</EditorProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props) {
|
||||
const { id } = await params;
|
||||
const paste = await getPasteById(id);
|
||||
|
||||
if (!paste)
|
||||
return {
|
||||
title: "spongebin",
|
||||
description: "a pastebin made with sponge",
|
||||
openGraph: { images: "/sponge.png" },
|
||||
twitter: { card: "summary" },
|
||||
};
|
||||
|
||||
return {
|
||||
title: `spongebin • ${paste.id}`,
|
||||
description: "a pastebin made with sponge",
|
||||
openGraph: { images: "/sponge.png" },
|
||||
twitter: { card: "summary" },
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user