mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-19 07:26:45 +00:00
feat: fix tweet build
This commit is contained in:
@@ -163,7 +163,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
|
||||
return (
|
||||
<Twitter.Provider
|
||||
value={{
|
||||
tweetAstMap: recordMap.tweetAstMap || {},
|
||||
tweetAstMap: (recordMap as any).tweetAstMap || {},
|
||||
swrOptions: {
|
||||
fetcher: (id) =>
|
||||
fetch(`/api/get-tweet-ast/${id}`).then((r) => r.json())
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getAllPagesInSpace } from 'notion-utils'
|
||||
|
||||
import * as types from './types'
|
||||
import { includeNotionIdInUrls } from './config'
|
||||
import { getPage } from './notion'
|
||||
import { notion } from './notion'
|
||||
import { getCanonicalPageId } from './get-canonical-page-id'
|
||||
|
||||
const uuid = !!includeNotionIdInUrls
|
||||
@@ -17,7 +17,7 @@ export async function getAllPagesImpl(
|
||||
const pageMap = await getAllPagesInSpace(
|
||||
rootNotionPageId,
|
||||
rootNotionSpaceId,
|
||||
getPage
|
||||
notion.getPage.bind(notion)
|
||||
)
|
||||
|
||||
const canonicalPageMap = Object.keys(pageMap).reduce(
|
||||
|
||||
@@ -2,10 +2,10 @@ import { NotionAPI } from 'notion-client'
|
||||
import { ExtendedRecordMap, SearchParams, SearchResults } from 'notion-types'
|
||||
import { getPreviewImages } from './get-preview-images'
|
||||
import { mapNotionImageUrl } from './map-image-url'
|
||||
import { fetchTweetAst, getTweetAst } from 'static-tweets'
|
||||
import { fetchTweetAst } from 'static-tweets'
|
||||
import pMap from 'p-map'
|
||||
|
||||
const notion = new NotionAPI({
|
||||
export const notion = new NotionAPI({
|
||||
apiBaseUrl: process.env.NOTION_API_BASE_URL
|
||||
})
|
||||
|
||||
@@ -63,6 +63,8 @@ export async function getPage(pageId: string): Promise<ExtendedRecordMap> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
.filter(Boolean)
|
||||
|
||||
@@ -83,13 +85,16 @@ export async function getPage(pageId: string): Promise<ExtendedRecordMap> {
|
||||
}
|
||||
)
|
||||
|
||||
const tweetAstMap = tweetAsts.filter(Boolean).reduce(
|
||||
(acc, t) => ({
|
||||
...acc,
|
||||
[t.tweetId]: t.tweetAst
|
||||
}),
|
||||
{}
|
||||
)
|
||||
const tweetAstMap = tweetAsts.reduce((acc, { tweetId, tweetAst }) => {
|
||||
if (tweetAst) {
|
||||
return {
|
||||
...acc,
|
||||
[tweetId]: tweetAst
|
||||
}
|
||||
} else {
|
||||
return acc
|
||||
}
|
||||
}, {})
|
||||
|
||||
;(recordMap as any).tweetAstMap = tweetAstMap
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function resolveNotionPage(domain: string, rawPageId?: string) {
|
||||
|
||||
if (pageId) {
|
||||
// TODO: we're not re-using the site from siteMaps because it is
|
||||
// cachd aggressively
|
||||
// cached aggressively
|
||||
// site = await getSiteForDomain(domain)
|
||||
// recordMap = siteMap.pageMap[pageId]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user