mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
🎩
This commit is contained in:
@@ -76,9 +76,27 @@ const propertyLastEditedTimeValue = (
|
||||
return `Last updated ${formatDate(block?.last_edited_time, {
|
||||
month: 'long'
|
||||
})}`
|
||||
} else {
|
||||
return defaultFn()
|
||||
}
|
||||
|
||||
return defaultFn()
|
||||
}
|
||||
|
||||
const propertyDateValue = (
|
||||
{ data, schema, pageHeader },
|
||||
defaultFn: () => React.ReactNode
|
||||
) => {
|
||||
if (pageHeader && schema?.name?.toLowerCase() === 'published') {
|
||||
const publishDate = data?.[0]?.[1]?.[0]?.[1]?.start_date
|
||||
console.log('date', { data, publishDate })
|
||||
|
||||
if (publishDate) {
|
||||
return `Published ${formatDate(publishDate, {
|
||||
month: 'long'
|
||||
})}`
|
||||
}
|
||||
}
|
||||
|
||||
return defaultFn()
|
||||
}
|
||||
|
||||
const propertyTextValue = (
|
||||
@@ -87,9 +105,9 @@ const propertyTextValue = (
|
||||
) => {
|
||||
if (pageHeader && schema?.name?.toLowerCase() === 'author') {
|
||||
return <b>{defaultFn()}</b>
|
||||
} else {
|
||||
return defaultFn()
|
||||
}
|
||||
|
||||
return defaultFn()
|
||||
}
|
||||
|
||||
export const NotionPage: React.FC<types.PageProps> = ({
|
||||
@@ -113,7 +131,8 @@ export const NotionPage: React.FC<types.PageProps> = ({
|
||||
Tweet,
|
||||
Header: NotionPageHeader,
|
||||
propertyLastEditedTimeValue,
|
||||
propertyTextValue
|
||||
propertyTextValue,
|
||||
propertyDateValue
|
||||
}),
|
||||
[]
|
||||
)
|
||||
|
||||
@@ -39,16 +39,16 @@
|
||||
"next": "^12.1.1",
|
||||
"next-api-og-image": "^2.2.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
"notion-client": "^6.9.1",
|
||||
"notion-client": "^6.9.2",
|
||||
"notion-types": "^6.7.0",
|
||||
"notion-utils": "^6.9.1",
|
||||
"notion-utils": "^6.9.2",
|
||||
"p-map": "^5.3.0",
|
||||
"p-memoize": "^6.0.1",
|
||||
"posthog-js": "^1.20.2",
|
||||
"react": "^17.0.2",
|
||||
"react-body-classname": "^1.3.1",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-notion-x": "^6.9.1",
|
||||
"react-notion-x": "^6.9.2",
|
||||
"react-static-tweets": "^0.7.2",
|
||||
"react-use": "^17.3.2",
|
||||
"static-tweets": "^0.7.2"
|
||||
|
||||
@@ -75,21 +75,12 @@ export default withOGImage<'query', 'id'>({
|
||||
// getPageProperty<string>('Description', block, recordMap) ||
|
||||
// config.description
|
||||
|
||||
const timeUpdated = getPageProperty<number>(
|
||||
'Last Updated',
|
||||
block,
|
||||
recordMap
|
||||
)
|
||||
const timePublished = getPageProperty<number>(
|
||||
'Published',
|
||||
block,
|
||||
recordMap
|
||||
)
|
||||
const dateUpdated = timeUpdated
|
||||
? new Date(timeUpdated)
|
||||
: timePublished
|
||||
? new Date(timePublished)
|
||||
: undefined
|
||||
const dateUpdated = timePublished ? new Date(timePublished) : undefined
|
||||
const date =
|
||||
isBlogPost && dateUpdated
|
||||
? `${dateUpdated.toLocaleString('en-US', {
|
||||
|
||||
28
yarn.lock
28
yarn.lock
@@ -2928,14 +2928,14 @@ normalize-url@^7.0.3:
|
||||
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-7.0.3.tgz"
|
||||
integrity sha512-RiCOdwdPnzvwcBFJE4iI1ss3dMVRIrEzFpn8ftje6iBfzBInqlnRrNhxcLwBEKjPPXQKzm1Ptlxtaiv9wdcj5w==
|
||||
|
||||
notion-client@^6.9.1:
|
||||
version "6.9.1"
|
||||
resolved "https://registry.yarnpkg.com/notion-client/-/notion-client-6.9.1.tgz#8a1294fcd2609133aba681166c4363917fde0ce7"
|
||||
integrity sha512-YRFe7B2uF4OoBHVpNZKEr6a/l03/9iJav3kE8/V1FBnSZkdx7Bi4qboQHwoviWWuMmpYKbCS7+nJtn4AvMCkJw==
|
||||
notion-client@^6.9.2:
|
||||
version "6.9.2"
|
||||
resolved "https://registry.yarnpkg.com/notion-client/-/notion-client-6.9.2.tgz#789b3e5ba5be3a75dc7013212db9b9abe53fc3e6"
|
||||
integrity sha512-VMuaXbd/du83r+4gKRdIgeePduWZMSYfISr8FM9gePdRFt2HoSsWQC1cxqX+V/S3N7xkUFSWbHJcJkWcDpSx+g==
|
||||
dependencies:
|
||||
got "^11.8.1"
|
||||
notion-types "^6.7.0"
|
||||
notion-utils "^6.9.1"
|
||||
notion-utils "^6.9.2"
|
||||
p-map "^5.3.0"
|
||||
|
||||
notion-types@^6.7.0:
|
||||
@@ -2943,10 +2943,10 @@ notion-types@^6.7.0:
|
||||
resolved "https://registry.yarnpkg.com/notion-types/-/notion-types-6.7.0.tgz#f5ccb8ef701389b2bf52e5561bd31bc60c49ccdf"
|
||||
integrity sha512-j7O6juQDOPgAinELMMpvVn0c8Vgr+Dhqm7UTTnhILnBhbOtQKaIYPCNKA4AJw/OPzzy1iEJ6KrthTEkPbQYEeg==
|
||||
|
||||
notion-utils@^6.9.1:
|
||||
version "6.9.1"
|
||||
resolved "https://registry.yarnpkg.com/notion-utils/-/notion-utils-6.9.1.tgz#203fd0f94277ed3e55ffb8febbeacbf9714d347a"
|
||||
integrity sha512-w5+ha+oGSZvFMgkHuNGtFl6b4ZrYu5wgqlDani3mKJMmdwgEd3koYKv8OkXYF8VS7+YAqX9y4Avqt7xR1z5dtQ==
|
||||
notion-utils@^6.9.2:
|
||||
version "6.9.2"
|
||||
resolved "https://registry.yarnpkg.com/notion-utils/-/notion-utils-6.9.2.tgz#d295a10fcef28a1b75bd8e8dd4bb319554eb0719"
|
||||
integrity sha512-bk2lbxARjZawqLjnmjH4uICHQAKFOTuu1j842ZC5XYq1DKZtatwZamTc4wwWQ9yQHyDAsY03cV9EQisUOnZLvQ==
|
||||
dependencies:
|
||||
is-url-superb "^6.1.0"
|
||||
mem "^9.0.2"
|
||||
@@ -3511,17 +3511,17 @@ react-modal@^3.14.3:
|
||||
react-lifecycles-compat "^3.0.0"
|
||||
warning "^4.0.3"
|
||||
|
||||
react-notion-x@^6.9.1:
|
||||
version "6.9.1"
|
||||
resolved "https://registry.yarnpkg.com/react-notion-x/-/react-notion-x-6.9.1.tgz#d209c262d83f66f374c4b507992b79789cf2c476"
|
||||
integrity sha512-rTK7adUVo3FRtue1JOpBnG/ZOhNkv4NTqWi5Tf2/3Ptu5zqJed3Gu9Q/y6IfwMFoZmjIe4+yLIg/fO1TMSXPRg==
|
||||
react-notion-x@^6.9.2:
|
||||
version "6.9.2"
|
||||
resolved "https://registry.yarnpkg.com/react-notion-x/-/react-notion-x-6.9.2.tgz#463a07d701cbbbf27d7b0cb245af861b546d5a07"
|
||||
integrity sha512-2AqaGCYIw6wZa4KLg+HkPC00n99L+cJjcts6f51QuWTS0gsAd6m2Va3qHzpkkFIRBL+e82TK1fXAnvcI1/jvfA==
|
||||
dependencies:
|
||||
"@matejmazur/react-katex" "^3.1.3"
|
||||
"@radix-ui/react-dropdown-menu" "^0.1.6"
|
||||
katex "^0.13.18"
|
||||
medium-zoom "^1.0.6"
|
||||
notion-types "^6.7.0"
|
||||
notion-utils "^6.9.1"
|
||||
notion-utils "^6.9.2"
|
||||
prismjs "^1.27.0"
|
||||
react-fast-compare "^3.2.0"
|
||||
react-hotkeys-hook "^3.0.3"
|
||||
|
||||
Reference in New Issue
Block a user