Skip to content

Commit 67b5a8d

Browse files
🎩
1 parent 89b3c8f commit 67b5a8d

File tree

4 files changed

+42
-32
lines changed

4 files changed

+42
-32
lines changed

components/NotionPage.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,27 @@ const propertyLastEditedTimeValue = (
7676
return `Last updated ${formatDate(block?.last_edited_time, {
7777
month: 'long'
7878
})}`
79-
} else {
80-
return defaultFn()
8179
}
80+
81+
return defaultFn()
82+
}
83+
84+
const propertyDateValue = (
85+
{ data, schema, pageHeader },
86+
defaultFn: () => React.ReactNode
87+
) => {
88+
if (pageHeader && schema?.name?.toLowerCase() === 'published') {
89+
const publishDate = data?.[0]?.[1]?.[0]?.[1]?.start_date
90+
console.log('date', { data, publishDate })
91+
92+
if (publishDate) {
93+
return `Published ${formatDate(publishDate, {
94+
month: 'long'
95+
})}`
96+
}
97+
}
98+
99+
return defaultFn()
82100
}
83101

84102
const propertyTextValue = (
@@ -87,9 +105,9 @@ const propertyTextValue = (
87105
) => {
88106
if (pageHeader && schema?.name?.toLowerCase() === 'author') {
89107
return <b>{defaultFn()}</b>
90-
} else {
91-
return defaultFn()
92108
}
109+
110+
return defaultFn()
93111
}
94112

95113
export const NotionPage: React.FC<types.PageProps> = ({
@@ -113,7 +131,8 @@ export const NotionPage: React.FC<types.PageProps> = ({
113131
Tweet,
114132
Header: NotionPageHeader,
115133
propertyLastEditedTimeValue,
116-
propertyTextValue
134+
propertyTextValue,
135+
propertyDateValue
117136
}),
118137
[]
119138
)

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
"next": "^12.1.1",
4040
"next-api-og-image": "^2.2.1",
4141
"node-fetch": "^2.6.1",
42-
"notion-client": "^6.9.1",
42+
"notion-client": "^6.9.2",
4343
"notion-types": "^6.7.0",
44-
"notion-utils": "^6.9.1",
44+
"notion-utils": "^6.9.2",
4545
"p-map": "^5.3.0",
4646
"p-memoize": "^6.0.1",
4747
"posthog-js": "^1.20.2",
4848
"react": "^17.0.2",
4949
"react-body-classname": "^1.3.1",
5050
"react-dom": "^17.0.2",
51-
"react-notion-x": "^6.9.1",
51+
"react-notion-x": "^6.9.2",
5252
"react-static-tweets": "^0.7.2",
5353
"react-use": "^17.3.2",
5454
"static-tweets": "^0.7.2"

pages/api/social-image.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,12 @@ export default withOGImage<'query', 'id'>({
7575
// getPageProperty<string>('Description', block, recordMap) ||
7676
// config.description
7777

78-
const timeUpdated = getPageProperty<number>(
79-
'Last Updated',
80-
block,
81-
recordMap
82-
)
8378
const timePublished = getPageProperty<number>(
8479
'Published',
8580
block,
8681
recordMap
8782
)
88-
const dateUpdated = timeUpdated
89-
? new Date(timeUpdated)
90-
: timePublished
91-
? new Date(timePublished)
92-
: undefined
83+
const dateUpdated = timePublished ? new Date(timePublished) : undefined
9384
const date =
9485
isBlogPost && dateUpdated
9586
? `${dateUpdated.toLocaleString('en-US', {

yarn.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,25 +2928,25 @@ normalize-url@^7.0.3:
29282928
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-7.0.3.tgz"
29292929
integrity sha512-RiCOdwdPnzvwcBFJE4iI1ss3dMVRIrEzFpn8ftje6iBfzBInqlnRrNhxcLwBEKjPPXQKzm1Ptlxtaiv9wdcj5w==
29302930

2931-
notion-client@^6.9.1:
2932-
version "6.9.1"
2933-
resolved "https://registry.yarnpkg.com/notion-client/-/notion-client-6.9.1.tgz#8a1294fcd2609133aba681166c4363917fde0ce7"
2934-
integrity sha512-YRFe7B2uF4OoBHVpNZKEr6a/l03/9iJav3kE8/V1FBnSZkdx7Bi4qboQHwoviWWuMmpYKbCS7+nJtn4AvMCkJw==
2931+
notion-client@^6.9.2:
2932+
version "6.9.2"
2933+
resolved "https://registry.yarnpkg.com/notion-client/-/notion-client-6.9.2.tgz#789b3e5ba5be3a75dc7013212db9b9abe53fc3e6"
2934+
integrity sha512-VMuaXbd/du83r+4gKRdIgeePduWZMSYfISr8FM9gePdRFt2HoSsWQC1cxqX+V/S3N7xkUFSWbHJcJkWcDpSx+g==
29352935
dependencies:
29362936
got "^11.8.1"
29372937
notion-types "^6.7.0"
2938-
notion-utils "^6.9.1"
2938+
notion-utils "^6.9.2"
29392939
p-map "^5.3.0"
29402940

29412941
notion-types@^6.7.0:
29422942
version "6.7.0"
29432943
resolved "https://registry.yarnpkg.com/notion-types/-/notion-types-6.7.0.tgz#f5ccb8ef701389b2bf52e5561bd31bc60c49ccdf"
29442944
integrity sha512-j7O6juQDOPgAinELMMpvVn0c8Vgr+Dhqm7UTTnhILnBhbOtQKaIYPCNKA4AJw/OPzzy1iEJ6KrthTEkPbQYEeg==
29452945

2946-
notion-utils@^6.9.1:
2947-
version "6.9.1"
2948-
resolved "https://registry.yarnpkg.com/notion-utils/-/notion-utils-6.9.1.tgz#203fd0f94277ed3e55ffb8febbeacbf9714d347a"
2949-
integrity sha512-w5+ha+oGSZvFMgkHuNGtFl6b4ZrYu5wgqlDani3mKJMmdwgEd3koYKv8OkXYF8VS7+YAqX9y4Avqt7xR1z5dtQ==
2946+
notion-utils@^6.9.2:
2947+
version "6.9.2"
2948+
resolved "https://registry.yarnpkg.com/notion-utils/-/notion-utils-6.9.2.tgz#d295a10fcef28a1b75bd8e8dd4bb319554eb0719"
2949+
integrity sha512-bk2lbxARjZawqLjnmjH4uICHQAKFOTuu1j842ZC5XYq1DKZtatwZamTc4wwWQ9yQHyDAsY03cV9EQisUOnZLvQ==
29502950
dependencies:
29512951
is-url-superb "^6.1.0"
29522952
mem "^9.0.2"
@@ -3511,17 +3511,17 @@ react-modal@^3.14.3:
35113511
react-lifecycles-compat "^3.0.0"
35123512
warning "^4.0.3"
35133513

3514-
react-notion-x@^6.9.1:
3515-
version "6.9.1"
3516-
resolved "https://registry.yarnpkg.com/react-notion-x/-/react-notion-x-6.9.1.tgz#d209c262d83f66f374c4b507992b79789cf2c476"
3517-
integrity sha512-rTK7adUVo3FRtue1JOpBnG/ZOhNkv4NTqWi5Tf2/3Ptu5zqJed3Gu9Q/y6IfwMFoZmjIe4+yLIg/fO1TMSXPRg==
3514+
react-notion-x@^6.9.2:
3515+
version "6.9.2"
3516+
resolved "https://registry.yarnpkg.com/react-notion-x/-/react-notion-x-6.9.2.tgz#463a07d701cbbbf27d7b0cb245af861b546d5a07"
3517+
integrity sha512-2AqaGCYIw6wZa4KLg+HkPC00n99L+cJjcts6f51QuWTS0gsAd6m2Va3qHzpkkFIRBL+e82TK1fXAnvcI1/jvfA==
35183518
dependencies:
35193519
"@matejmazur/react-katex" "^3.1.3"
35203520
"@radix-ui/react-dropdown-menu" "^0.1.6"
35213521
katex "^0.13.18"
35223522
medium-zoom "^1.0.6"
35233523
notion-types "^6.7.0"
3524-
notion-utils "^6.9.1"
3524+
notion-utils "^6.9.2"
35253525
prismjs "^1.27.0"
35263526
react-fast-compare "^3.2.0"
35273527
react-hotkeys-hook "^3.0.3"

0 commit comments

Comments
 (0)