diff --git a/lib/config.ts b/lib/config.ts index 17a2c98..041c3b7 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -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') diff --git a/lib/get-all-pages.ts b/lib/get-all-pages.ts index 1fd1074..2874104 100644 --- a/lib/get-all-pages.ts +++ b/lib/get-all-pages.ts @@ -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]) { diff --git a/lib/map-page-url.ts b/lib/map-page-url.ts index 6163da7..488f684 100644 --- a/lib/map-page-url.ts +++ b/lib/map-page-url.ts @@ -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,