diff --git a/src/app/[id]/page.tsx b/src/app/[id]/page.tsx index 5572da4..ed31f00 100644 --- a/src/app/[id]/page.tsx +++ b/src/app/[id]/page.tsx @@ -39,10 +39,17 @@ export async function generateMetadata({ params }: Props) { }; const numLines = paste.content.split("\n").length; + const codeblockPreview = paste.content + .split("\n") + .slice(0, 3) + .join("\n") + .replace(/`/g, "\\`") + .replace(/^\s*```(\w+)?/, "```" + paste.language) + .replace(/^\s*```/, "```"); return { title: `spongebin • ${paste.id}`, - description: `a paste containing ${numLines} lines of ${paste.language}`, + description: `a paste containing ${numLines} lines of ${paste.language}\ncode:\n${codeblockPreview}`, openGraph: { images: "/sponge.png" }, twitter: { card: "summary" }, };