mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
28 lines
629 B
TypeScript
28 lines
629 B
TypeScript
import { ExtendedRecordMap } from 'notion-types'
|
|
import {
|
|
parsePageId,
|
|
getCanonicalPageId as getCanonicalPageIdImpl
|
|
} from 'notion-utils'
|
|
|
|
import { inversePageUrlOverrides } from './config'
|
|
|
|
export function getCanonicalPageId(
|
|
pageId: string,
|
|
recordMap: ExtendedRecordMap,
|
|
{ uuid = true }: { uuid?: boolean } = {}
|
|
): string | null {
|
|
const cleanPageId = parsePageId(pageId, { uuid: false })
|
|
if (!cleanPageId) {
|
|
return null
|
|
}
|
|
|
|
const override = inversePageUrlOverrides[cleanPageId]
|
|
if (override) {
|
|
return override
|
|
} else {
|
|
return getCanonicalPageIdImpl(pageId, recordMap, {
|
|
uuid
|
|
})
|
|
}
|
|
}
|