Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,060 changes: 17,060 additions & 0 deletions files/budget-2024.md

Large diffs are not rendered by default.

Binary file added files/budget-2024.pdf
Binary file not shown.
19,237 changes: 19,237 additions & 0 deletions files/budget-2025.md

Large diffs are not rendered by default.

Binary file added files/budget-2025.pdf
Binary file not shown.
38,704 changes: 38,704 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"next-auth": "4.24.11",
"next-themes": "^0.4.6",
"openai": "^5.15.0",
"pdf-parse": "^2.4.5",
"react": "19.1.1",
"react-day-picker": "^9.9.0",
"react-dom": "19.1.1",
Expand Down
128 changes: 128 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions src/app/budget-2025/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { ImageResponse } from "next/og";
import { BillOgCard } from "@/components/OpenGraph/BillOgCard";

export const runtime = "nodejs";

export const size = {
width: 1200,
height: 630,
};

export const contentType = "image/png";

export const revalidate = 3600;

const budgetBill = {
billId: "budget-2025",
title: "Budget 2025",
short_title: "Budget 2025",
summary: "Coming very soon.",
final_judgment: "yes" as const,
};

async function loadGoogleFont(font: string, weight: number, text: string) {
const params = new URLSearchParams({
family: `${font}:wght@${weight}`,
text,
});
const cssUrl = `https://fonts.googleapis.com/css2?${params.toString()}`;
const css = await (await fetch(cssUrl)).text();
const resource = css.match(
/src: url\((.+?)\) format\('(opentype|truetype|woff2)'\)/,
);
if (resource) {
const res = await fetch(resource[1]);
if (res.status === 200) {
return await res.arrayBuffer();
}
}
throw new Error("failed to load font data");
}

export default async function BudgetOpengraphImage() {
const textForFont = `${budgetBill.title} ${budgetBill.summary} Vote: Yes`;

let interRegular: ArrayBuffer | undefined;
let interBold: ArrayBuffer | undefined;

try {
interRegular = await loadGoogleFont("Inter", 400, textForFont);
interBold = await loadGoogleFont("Inter", 700, textForFont);
} catch (_e) {
interRegular = undefined;
interBold = undefined;
}

return new ImageResponse(<BillOgCard bill={budgetBill} />, {
...size,
fonts:
interRegular && interBold
? [
{
name: "Inter",
data: interRegular,
weight: 400,
style: "normal",
},
{ name: "Inter", data: interBold, weight: 700, style: "normal" },
]
: undefined,
headers: {
"Cache-Control": "public, max-age=3600, s-maxage=3600",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Headers": "Content-Type",
},
});
}
Loading