Skip to content

Commit

Permalink
🎩
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Apr 8, 2022
1 parent 89b3c8f commit 67b5a8d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
29 changes: 24 additions & 5 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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> = ({
Expand All @@ -113,7 +131,8 @@ export const NotionPage: React.FC<types.PageProps> = ({
Tweet,
Header: NotionPageHeader,
propertyLastEditedTimeValue,
propertyTextValue
propertyTextValue,
propertyDateValue
}),
[]
)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 1 addition & 10 deletions pages/api/social-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2928,25 +2928,25 @@ 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:
version "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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 67b5a8d

Please sign in to comment.