From c3280c0a920d9eac0375d6fc5d20876bf4988342 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 3 Jun 2026 01:04:37 +0000 Subject: [PATCH] fix: restore Substack fetch + merge with local posts, iframe only as fallback getStaticProps now attempts getSubstackEssays again (returns [] gracefully if blocked by Cloudflare). Local Notion posts and Substack posts are merged into one sorted list. The embed iframe only shows when substackEssays is empty, acting as a fallback rather than always rendering. https://claude.ai/code/session_01P9Bn6gkWtM15yEzGf79XCQ --- pages/index.tsx | 110 ++++++++++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 40 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 8cdf281..1dccf63 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -6,6 +6,7 @@ import { getSitePosts } from "lib/get-site-posts"; import * as config from "lib/config"; import { resolveNotionPage } from "lib/resolve-notion-page"; import { resolveArenaChannels } from "lib/resolve-arena-channels"; +import { getSubstackEssays, SubstackEssay } from "lib/get-substack-essays"; import { useDarkMode } from "lib/use-dark-mode"; import { mapPageUrl } from "lib/map-page-url"; import { getLayoutProps } from "lib/get-layout-props"; @@ -34,12 +35,15 @@ export const getStaticProps = async () => { const siteMap = await getSiteMap(); const substackHandle = process.env.SUBSTACK_HANDLE || "suruleredotdev"; + const substackApiKey = process.env.SUBSTACK_API_KEY; + const substackEssays = await getSubstackEssays(substackHandle, 10, substackApiKey); const props = { ...notionProps, channels, siteMap, substackHandle, + substackEssays, }; return { props, revalidate: 3600 }; // Revalidate every hour for fresh Substack content @@ -67,6 +71,7 @@ const textVersion = 0; interface HomePageContentProps extends types.PageProps { substackHandle?: string; + substackEssays?: SubstackEssay[]; } export const HomePageContent: React.FC = ({ @@ -76,6 +81,7 @@ export const HomePageContent: React.FC = ({ channels, siteMap, substackHandle = "suruleredotdev", + substackEssays = [], }) => { // TODO: render from root page block const posts = getSitePosts({ @@ -110,46 +116,67 @@ export const HomePageContent: React.FC = ({ > Read on Substack - {posts?.filter((post) => post.public == true).length > 0 && ( - - )} -