Skip to content

Commit

Permalink
generate og images at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Nov 3, 2024
1 parent 5b3622d commit 9fae447
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions app/(post)/og/[id]/route.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
export const revalidate = 60;

import { ImageResponse } from "next/og";
import { getPosts } from "@/app/get-posts";
import { readFileSync } from "fs";
import { join } from "path";

export async function generateStaticParams() {
return (await getPosts()).map(post => ({ id: post.id }));
}

// fonts
const inter300 = readFileSync(
join(
process.cwd(),
"node_modules/@fontsource/inter/files/inter-latin-300-normal.woff"
"node_modules",
"@fontsource",
"inter",
"files",
"inter-latin-300-normal.woff"
)
);

const inter500 = readFileSync(
join(
process.cwd(),
"node_modules/@fontsource/inter/files/inter-latin-500-normal.woff"
"node_modules",
"@fontsource",
"inter",
"files",
"inter-latin-500-normal.woff"
)
);

const inter600 = readFileSync(
join(
process.cwd(),
"node_modules/@fontsource/inter/files/inter-latin-600-normal.woff"
"node_modules",
"@fontsource",
"inter",
"files",
"inter-latin-600-normal.woff"
)
);

const robotoMono400 = readFileSync(
join(
process.cwd(),
"node_modules/@fontsource/roboto-mono/files/roboto-mono-latin-400-normal.woff"
"node_modules",
"@fontsource",
"roboto-mono",
"files",
"roboto-mono-latin-400-normal.woff"
)
);

Expand Down

0 comments on commit 9fae447

Please sign in to comment.