aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYasutake Yohei <yohei@yasutakeyohei.com>2026-07-04 23:28:35 +0900
committerYasutake Yohei <yohei@yasutakeyohei.com>2026-07-04 23:28:35 +0900
commit90524606043100978a80e1a725e6ec866e778e29 (patch)
tree8013b1e545ac16a1d9123a1e20f64e1aaa494dbb /src
parent38f811a24e9611c53105931399a4de9625923817 (diff)
og画像: キャッシュをnode_modules/.og-cacheに移動しビルド間で保持
Diffstat (limited to 'src')
-rw-r--r--src/pages/og/[slug].png.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pages/og/[slug].png.ts b/src/pages/og/[slug].png.ts
index 1047647..a743efe 100644
--- a/src/pages/og/[slug].png.ts
+++ b/src/pages/og/[slug].png.ts
@@ -142,10 +142,10 @@ export async function GET({ params }: { params: { slug: string } }) {
title = `${reiwa}${month}定例会`;
}
- // Check cache: if title hash matches, return cached PNG
- const distDir = path.join(process.cwd(), "dist", "og");
- const cacheFile = path.join(distDir, `${slug}.png`);
- const cacheJsonPath = path.join(distDir, ".og-cache.json");
+ // Check cache: if title hash matches, return cached PNG from node_modules/.og-cache
+ const cacheDir = path.join(process.cwd(), "node_modules", ".og-cache");
+ const cacheFile = path.join(cacheDir, `${slug}.png`);
+ const cacheJsonPath = path.join(cacheDir, ".og-cache.json");
let cache: Record<string, string> = {};
if (existsSync(cacheJsonPath)) {
@@ -293,8 +293,8 @@ export async function GET({ params }: { params: { slug: string } }) {
const resvg = new Resvg(svg, { fitTo: { mode: "width", value: 1200 } });
const pngBuffer = resvg.render().asPng();
- // Save to cache
- if (!existsSync(distDir)) mkdirSync(distDir, { recursive: true });
+ // Save to cache in node_modules/.og-cache (persists across builds)
+ if (!existsSync(cacheDir)) mkdirSync(cacheDir, { recursive: true });
writeFileSync(cacheFile, pngBuffer);
cache[slug] = titleHash;
writeFileSync(cacheJsonPath, JSON.stringify(cache, null, 2));