Skip to content

Commit

Permalink
Added 'post' dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeraze committed Nov 20, 2022
1 parent 150a16e commit 90d5720
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/map-page-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const mapPageUrl =
return createUrl('/', searchParams)
} else {
return createUrl(
`/${getCanonicalPageId(pageUuid, recordMap, { uuid })}`,
`/post/${getCanonicalPageId(pageUuid, recordMap, { uuid })}`,
searchParams
)
}
Expand All @@ -32,7 +32,7 @@ export const getCanonicalPageUrl =
if (uuidToId(pageId) === site.rootNotionPageId) {
return `https://${site.domain}`
} else {
return `https://${site.domain}/${getCanonicalPageId(pageUuid, recordMap, {
return `https://${site.domain}/post/${getCanonicalPageId(pageUuid, recordMap, {
uuid
})}`
}
Expand Down
9 changes: 7 additions & 2 deletions lib/resolve-notion-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import { getPage } from './notion'
export async function resolveNotionPage(domain: string, rawPageId?: string) {
let pageId: string
let recordMap: ExtendedRecordMap
console.error(rawPageId)

if (rawPageId && rawPageId !== 'index') {
pageId = parsePageId(rawPageId)

console.error(rawPageId.substring(0,5))
if (rawPageId.substring(0,5) === "post/") {
pageId = parsePageId(rawPageId.substring(6))
} else {
pageId = parsePageId(rawPageId)
}
if (!pageId) {
// check if the site configuration provides an override or a fallback for
// the page's URI
Expand Down
1 change: 1 addition & 0 deletions pages/[pageId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const getStaticProps: GetStaticProps<PageProps, Params> = async (
const rawPageId = context.params.pageId as string

try {
console.error(rawPageId)
const props = await resolveNotionPage(domain, rawPageId)

return { props, revalidate: 10 }
Expand Down

0 comments on commit 90d5720

Please sign in to comment.