diff --git a/app/lib/substack.ts b/app/lib/substack.ts index f745095..4398f54 100644 --- a/app/lib/substack.ts +++ b/app/lib/substack.ts @@ -5,10 +5,13 @@ export type SubstackPost = { description: string; }; -const FEEDS = [ - "https://substack.com/@kaiiiichen/feed", - "https://kaiiiichen.substack.com/feed", -]; +// `https://substack.com/@/feed` started returning 404 (it serves the +// generic discover HTML page now), so we hit the publication feed directly. +const FEEDS = ["https://kaiiiichen.substack.com/feed"]; + +// Refetch the RSS feed every 10 minutes so newly-published posts appear on the +// homepage within ~10 min instead of the previous 1 h window. +const REVALIDATE_SECONDS = 600; function extractTag(xml: string, tag: string): string { const cdataMatch = new RegExp(`<${tag}[^>]*><\\/${tag}>`, "i").exec(xml); @@ -34,7 +37,7 @@ export async function getSubstackPosts(): Promise { for (const feed of FEEDS) { try { const res = await fetch(feed, { - next: { revalidate: 3600 }, + next: { revalidate: REVALIDATE_SECONDS }, headers: { "User-Agent": "kaichen.dev/1.0" }, }); if (!res.ok) continue;