This commit is contained in:
Travis Fischer
2022-04-22 17:29:04 -04:00
parent 4641fd6708
commit 7b1fc5fe7b
2 changed files with 18 additions and 2 deletions

View File

@@ -195,6 +195,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
// parsePageId(block?.id) === parsePageId(site?.rootNotionPageId)
const isBlogPost =
block?.type === 'page' && block?.parent_table === 'collection'
const showTableOfContents = !!isBlogPost
const minTableOfContentsItems = 3

View File

@@ -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<string>('Description', block, recordMap) ||