伪静态&刷新缓存时间

This commit is contained in:
tangly1024
2022-12-07 12:52:58 +08:00
parent ac65dbc95c
commit 928585cbf2
14 changed files with 52 additions and 39 deletions

View File

@@ -224,8 +224,7 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
post.type &&
(post.type === 'Post' || post.type === 'Page') &&
(post.status === 'Published' || post.status === 'Invisible')
}
)
})
// Sort by date
if (BLOG.POSTS_SORT_BY === 'date') {

View File

@@ -76,6 +76,13 @@ export default async function getPageProperties(id, block, schema, authToken, ta
properties.slug = (properties.slug ?? properties.id)
}
// 开启伪静态路径
if (BLOG.PSEUDO_STATIC) {
if (!properties.slug.endsWith('.html')) {
properties.slug += '.html'
}
}
properties.createdTime = formatDate(new Date(value.created_time).toString(), BLOG.LANG)
properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG)
properties.fullWidth = value.format?.page_full_width ?? false
@@ -87,25 +94,25 @@ export default async function getPageProperties(id, block, schema, authToken, ta
}) || []
delete properties.content
return properties
// 从Block获取封面图;优先取PageCover否则取内容图片
function getImageUrl(imgObj, blockVal) {
if (!imgObj) {
return null
}
if (imgObj.startsWith('/')) {
return 'https://www.notion.so' + imgObj // notion内部图片转相对路径为绝对路径
}
if (imgObj.startsWith('http')) {
// 判断如果是notion上传的图片要拼接访问token
const u = new URL(imgObj)
if (u.pathname.startsWith('/secure.notion-static.com') && u.hostname.endsWith('.amazonaws.com')) {
return defaultMapImageUrl(imgObj, blockVal) // notion上传的图片需要转换请求地址
}
}
// 其他图片链接 或 emoji
return imgObj
}
}
// 从Block获取封面图;优先取PageCover否则取内容图片
function getImageUrl(imgObj, blockVal) {
if (!imgObj) {
return null
}
if (imgObj.startsWith('/')) {
return 'https://www.notion.so' + imgObj // notion内部图片转相对路径为绝对路径
}
if (imgObj.startsWith('http')) {
// 判断如果是notion上传的图片要拼接访问token
const u = new URL(imgObj)
if (u.pathname.startsWith('/secure.notion-static.com') && u.hostname.endsWith('.amazonaws.com')) {
return defaultMapImageUrl(imgObj, blockVal) // notion上传的图片需要转换请求地址
}
}
// 其他图片链接 或 emoji
return imgObj
}