From 7b1fc5fe7b307cfe6fbc07324d6193366a8a31f4 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Fri, 22 Apr 2022 17:29:04 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/NotionPage.tsx | 1 + pages/feed.xml.tsx | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/components/NotionPage.tsx b/components/NotionPage.tsx index 1e4e0a7..68719f7 100644 --- a/components/NotionPage.tsx +++ b/components/NotionPage.tsx @@ -195,6 +195,7 @@ export const NotionPage: React.FC = ({ // parsePageId(block?.id) === parsePageId(site?.rootNotionPageId) const isBlogPost = block?.type === 'page' && block?.parent_table === 'collection' + const showTableOfContents = !!isBlogPost const minTableOfContentsItems = 3 diff --git a/pages/feed.xml.tsx b/pages/feed.xml.tsx index b337c03..bff41da 100644 --- a/pages/feed.xml.tsx +++ b/pages/feed.xml.tsx @@ -1,6 +1,12 @@ import RSS from 'rss' import type { GetServerSideProps } from 'next' -import { getBlockTitle, getPageProperty } from 'notion-utils' +import { + getBlockParentPage, + getBlockTitle, + getPageProperty, + idToUuid +} from 'notion-utils' +import { ExtendedRecordMap } from 'notion-types' import * as config from 'lib/config' import { getSiteMap } from 'lib/get-site-map' @@ -30,13 +36,22 @@ export const getServerSideProps: GetServerSideProps = async ({ req, res }) => { for (const pagePath of Object.keys(siteMap.canonicalPageMap)) { const pageId = siteMap.canonicalPageMap[pagePath] - const recordMap = siteMap.pageMap[pageId] + const recordMap = siteMap.pageMap[pageId] as ExtendedRecordMap if (!recordMap) continue const keys = Object.keys(recordMap?.block || {}) const block = recordMap?.block?.[keys[0]]?.value if (!block) continue + const parentPage = getBlockParentPage(block, recordMap) + const isBlogPost = + block.type === 'page' && + block.parent_table === 'collection' && + parentPage?.id === idToUuid(config.rootNotionPageId) + if (!isBlogPost) { + continue + } + const title = getBlockTitle(block, recordMap) || config.name const description = getPageProperty('Description', block, recordMap) ||