mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 23:16:47 +00:00
feat: add support for includeNotionIdInUrls
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
import { parsePageId } from 'notion-utils'
|
||||
import { getSiteConfig, getEnv } from './get-config-value'
|
||||
|
||||
// where it all starts -- the site's root Notion page
|
||||
export const rootNotionPageId: string = parsePageId(
|
||||
getSiteConfig('rootNotionPageId', 'ROOT_NOTION_PAGE_ID'),
|
||||
{ uuid: false }
|
||||
@@ -101,11 +100,18 @@ export const isPreviewImageSupportEnabled: boolean = getSiteConfig(
|
||||
false
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
export const isDev =
|
||||
process.env.NODE_ENV === 'development' || !process.env.NODE_ENV
|
||||
|
||||
// where it all starts -- the site's root Notion page
|
||||
export const includeNotionIdInUrls: boolean = getSiteConfig(
|
||||
'includeNotionIdInUrls',
|
||||
'INCLUDE_NOTION_ID_IN_URLS',
|
||||
!!isDev
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
export const isServer = typeof window === 'undefined'
|
||||
|
||||
export const port = getEnv('PORT', '3000')
|
||||
|
||||
@@ -2,8 +2,11 @@ import pMemoize from 'p-memoize'
|
||||
import { getAllPagesInSpace, getCanonicalPageId } from 'notion-utils'
|
||||
|
||||
import * as types from './types'
|
||||
import { includeNotionIdInUrls } from './config'
|
||||
import { getPage } from './notion'
|
||||
|
||||
const uuid = !!includeNotionIdInUrls
|
||||
|
||||
export const getAllPages = pMemoize(getAllPagesImpl, { maxAge: 60000 * 5 })
|
||||
|
||||
export async function getAllPagesImpl(
|
||||
@@ -24,7 +27,7 @@ export async function getAllPagesImpl(
|
||||
}
|
||||
|
||||
const canonicalPageId = getCanonicalPageId(pageId, recordMap, {
|
||||
uuid: false
|
||||
uuid
|
||||
})
|
||||
|
||||
if (map[canonicalPageId]) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as types from './types'
|
||||
import { isDev } from './config'
|
||||
import { includeNotionIdInUrls } from './config'
|
||||
import { getCanonicalPageId, uuidToId, parsePageId } from 'notion-utils'
|
||||
|
||||
// include UUIDs in page URLs during local development but not in production
|
||||
// (they're nice for debugging and speed up local dev)
|
||||
const uuid = !!isDev
|
||||
const uuid = !!includeNotionIdInUrls
|
||||
|
||||
export const mapPageUrl = (
|
||||
site: types.Site,
|
||||
|
||||
Reference in New Issue
Block a user