mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
feat: lots of refactors and improvements
This commit is contained in:
@@ -36,6 +36,9 @@ export const pageUrlAdditions = cleanPageUrlMap(
|
||||
'pageUrlAdditions'
|
||||
)
|
||||
|
||||
export const isDev =
|
||||
process.env.NODE_ENV === 'development' || !process.env.NODE_ENV
|
||||
|
||||
// general site config
|
||||
export const name: string = getSiteConfig('name')
|
||||
export const author: string = getSiteConfig('author')
|
||||
@@ -70,24 +73,20 @@ export const defaultPageCoverPosition: number = getSiteConfig(
|
||||
0.5
|
||||
)
|
||||
|
||||
// Optional utteranc.es comments via GitHub issue comments
|
||||
export const utterancesGitHubRepo: string | null = getSiteConfig(
|
||||
'utterancesGitHubRepo',
|
||||
null
|
||||
)
|
||||
|
||||
// Optional image CDN host to proxy all image requests through
|
||||
export const imageCDNHost: string | null = getSiteConfig('imageCDNHost', null)
|
||||
|
||||
// Optional whether or not to enable support for LQIP preview images
|
||||
// (requires a Google Firebase collection)
|
||||
export const isPreviewImageSupportEnabled: boolean = getSiteConfig(
|
||||
'isPreviewImageSupportEnabled',
|
||||
false
|
||||
)
|
||||
|
||||
export const isDev =
|
||||
process.env.NODE_ENV === 'development' || !process.env.NODE_ENV
|
||||
// Optional whether or not to enable support for LQIP preview images
|
||||
export const isTweetEmbedSupportEnabled: boolean = getSiteConfig(
|
||||
'isTweetEmbedSupportEnabled',
|
||||
true
|
||||
)
|
||||
|
||||
// where it all starts -- the site's root Notion page
|
||||
export const includeNotionIdInUrls: boolean = getSiteConfig(
|
||||
@@ -105,7 +104,6 @@ export const host = isDev ? `http://localhost:${port}` : `https://${domain}`
|
||||
export const apiBaseUrl = `${host}/api`
|
||||
|
||||
export const api = {
|
||||
createPreviewImage: `${apiBaseUrl}/create-preview-image`,
|
||||
searchNotion: `${apiBaseUrl}/search-notion`
|
||||
}
|
||||
|
||||
@@ -119,46 +117,6 @@ export const fathomConfig = fathomId
|
||||
}
|
||||
: undefined
|
||||
|
||||
const defaultEnvValueForPreviewImageSupport =
|
||||
isPreviewImageSupportEnabled && isServer ? undefined : null
|
||||
|
||||
export const googleProjectId = getEnv(
|
||||
'GCLOUD_PROJECT',
|
||||
defaultEnvValueForPreviewImageSupport
|
||||
)
|
||||
|
||||
export const googleApplicationCredentials = getGoogleApplicationCredentials()
|
||||
|
||||
export const firebaseCollectionImages = getEnv(
|
||||
'FIREBASE_COLLECTION_IMAGES',
|
||||
defaultEnvValueForPreviewImageSupport
|
||||
)
|
||||
|
||||
// this hack is necessary because vercel doesn't support secret files so we need to encode our google
|
||||
// credentials a base64-encoded string of the JSON-ified content
|
||||
function getGoogleApplicationCredentials() {
|
||||
if (!isPreviewImageSupportEnabled || !isServer) {
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
const googleApplicationCredentialsBase64 = getEnv(
|
||||
'GOOGLE_APPLICATION_CREDENTIALS',
|
||||
defaultEnvValueForPreviewImageSupport
|
||||
)
|
||||
|
||||
return JSON.parse(
|
||||
Buffer.from(googleApplicationCredentialsBase64, 'base64').toString()
|
||||
)
|
||||
} catch (err) {
|
||||
console.error(
|
||||
'Firebase config error: invalid "GOOGLE_APPLICATION_CREDENTIALS" should be base64-encoded JSON\n'
|
||||
)
|
||||
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
function cleanPageUrlMap(
|
||||
pageUrlMap: PageUrlOverridesMap,
|
||||
label: string
|
||||
|
||||
Reference in New Issue
Block a user