Skip to content

Commit c1ff2e7

Browse files
committed
fix: correct PageHead props, blog slugs, add header to homepage
1 parent 1a9ead3 commit c1ff2e7

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

lib/homepage-data.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NotionAPI } from 'notion-client'
2+
import { getCanonicalPageId } from './get-canonical-page-id'
23

34
const notion = new NotionAPI()
45

@@ -12,10 +13,7 @@ export interface BlogPost {
1213

1314
export async function getHomepageData() {
1415
try {
15-
// Fetch the blog posts collection
16-
const collectionId = 'c7cbc279-6edb-4462-85c1-84ae5af1c7b6'
17-
18-
// Fetch the page that contains the collection
16+
// Fetch the root page which contains the blog posts collection
1917
const recordMap = await notion.getPage('16ccc94eb4cf4b3d85fb31ac7be58e87')
2018

2119
const posts: BlogPost[] = []
@@ -28,9 +26,13 @@ export async function getHomepageData() {
2826
if (block.value && block.value.type === 'page' && block.value.parent_table === 'collection') {
2927
const properties = block.value.properties
3028

29+
// Skip pages without Public checkbox or where Public is false
30+
const isPublic = block.value.properties?.['[ZmN'']?.[0]?.[0] === 'Yes'
31+
3132
if (properties) {
3233
const title = properties.title?.[0]?.[0] || 'Untitled'
33-
const slug = block.value.id.replace(/-/g, '')
34+
// Use the canonical page ID which generates the proper URL slug
35+
const slug = getCanonicalPageId(block.value.id, recordMap, { uuid: false }) || block.value.id.replace(/-/g, '')
3436
const date = properties.published?.[0]?.[1]?.[0]?.[1]?.start_date
3537
const tags = properties.tags?.[0]?.[0]?.split(',').map((t: string) => t.trim()) || []
3638

pages/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import Hero from '@/components/home/Hero'
77
import About from '@/components/home/About'
88
import BlogGrid from '@/components/home/BlogGrid'
99
import EnhancedFooter from '@/components/layout/EnhancedFooter'
10+
import { NotionPageHeader } from '@/components/NotionPageHeader'
1011
import { PageHead } from '@/components/PageHead'
12+
import { getBlockValue } from 'notion-utils'
1113

1214
interface HomePageProps extends PageProps {
1315
isHomePage: boolean
@@ -38,9 +40,19 @@ export default function NotionDomainPage(props: HomePageProps) {
3840

3941
// Render custom homepage for the root page
4042
if (isHomePage && notionProps.pageId === '16ccc94eb4cf4b3d85fb31ac7be58e87') {
43+
// Get block for header
44+
const keys = Object.keys(notionProps.recordMap?.block || {})
45+
const block = getBlockValue(notionProps.recordMap?.block?.[keys[0]!])
46+
4147
return (
4248
<>
43-
<PageHead site={notionProps} />
49+
<PageHead
50+
site={notionProps.site}
51+
pageId={notionProps.pageId}
52+
title="Abdullah Abid"
53+
description="Tech Leader & Builder - CEO @ Autonomous, Founder @ Memox"
54+
/>
55+
{block && <NotionPageHeader block={block as any} />}
4456
<Hero />
4557
<About />
4658
<BlogGrid posts={posts} />

0 commit comments

Comments
 (0)