diff --git a/components/NotionPage.tsx b/components/NotionPage.tsx index d55950e6d4..e41529f4d5 100644 --- a/components/NotionPage.tsx +++ b/components/NotionPage.tsx @@ -197,11 +197,20 @@ export const NotionPage: React.FC = ({ const keys = Object.keys(recordMap?.block || {}) const block = recordMap?.block?.[keys[0]]?.value + const title = block + ? getBlockTitle(block, recordMap) ?? site.name + : 'Notion Page' - const title = getBlockTitle(block, recordMap) || site.name + // const isRootPage = + // parsePageId(block?.id) === parsePageId(site?.rootNotionPageId) + const isBlogPost = + block?.type === 'page' && block?.parent_table === 'collection' + + const showTableOfContents = !!isBlogPost + const minTableOfContentsItems = 3 React.useEffect(() => { - if (router.isReady) { + if (router.isReady && isBlogPost) { setDisqusConfig({ // url: `test-page.notion.dev.daoedu.tw${router.asPath}`, url: `${process.env.HOSTNAME}${router.asPath}`, @@ -210,15 +219,7 @@ export const NotionPage: React.FC = ({ language: 'zh_TW' // e.g. for Traditional Chinese (Taiwan) }) } - }, [router.asPath, router.isReady, title]) - - // const isRootPage = - // parsePageId(block?.id) === parsePageId(site?.rootNotionPageId) - const isBlogPost = - block?.type === 'page' && block?.parent_table === 'collection' - - const showTableOfContents = !!isBlogPost - const minTableOfContentsItems = 3 + }, [isBlogPost, router.asPath, router.isReady, title]) const pageAside = React.useMemo( () => (