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 && ( - - )} -