mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-09 07:26:47 +00:00
调整文章日期显示
This commit is contained in:
@@ -94,15 +94,14 @@ export default async function getPageProperties(id, block, schema, authToken, ta
|
||||
}
|
||||
|
||||
properties.createdTime = formatDate(new Date(value.created_time).toString(), BLOG.LANG)
|
||||
properties.publishTime = value?.date?.start_date ? formatDate(new Date(value?.date?.start_date).toString, BLOG.LANG) : properties.createdTime
|
||||
properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG)
|
||||
properties.fullWidth = value.format?.page_full_width ?? false
|
||||
properties.pageIcon = mapImgUrl(block[id].value?.format?.page_icon, block[id].value) ?? ''
|
||||
properties.pageCover = mapImgUrl(block[id].value?.format?.page_cover, block[id].value) ?? ''
|
||||
properties.pageCoverThumbnail = mapImgUrl(block[id].value?.format?.page_cover, block[id].value, 'block', 'pageCoverThumbnail') ?? ''
|
||||
properties.content = value.content ?? []
|
||||
properties.password = properties.password
|
||||
? md5(properties.slug + properties.password)
|
||||
: ''
|
||||
properties.password = properties.password ? md5(properties.slug + properties.password) : ''
|
||||
properties.tagItems = properties?.tags?.map(tag => {
|
||||
return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' }
|
||||
}) || []
|
||||
@@ -110,6 +109,9 @@ export default async function getPageProperties(id, block, schema, authToken, ta
|
||||
return properties
|
||||
}
|
||||
|
||||
/**
|
||||
* 映射用户自定义表头
|
||||
*/
|
||||
function mapProperties(properties) {
|
||||
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_post) {
|
||||
properties.type = 'Post'
|
||||
@@ -132,14 +134,14 @@ function generateCustomizeUrl(postProperties) {
|
||||
let fullSlug = ''
|
||||
const allSlugPatterns = BLOG.POST_URL_PREFIX.split('/')
|
||||
allSlugPatterns.forEach((pattern, idx) => {
|
||||
if (pattern === '%year%' && postProperties?.date?.start_date) {
|
||||
const formatPostCreatedDate = new Date(postProperties?.date?.start_date)
|
||||
if (pattern === '%year%' && postProperties?.publishTime) {
|
||||
const formatPostCreatedDate = new Date(postProperties?.publishTime)
|
||||
fullSlug += formatPostCreatedDate.getUTCFullYear()
|
||||
} else if (pattern === '%month%' && postProperties?.date?.start_date) {
|
||||
const formatPostCreatedDate = new Date(postProperties?.date?.start_date)
|
||||
} else if (pattern === '%month%' && postProperties?.publishTime) {
|
||||
const formatPostCreatedDate = new Date(postProperties?.publishTime)
|
||||
fullSlug += String(formatPostCreatedDate.getUTCMonth() + 1).padStart(2, 0)
|
||||
} else if (pattern === '%day%' && postProperties?.date?.start_date) {
|
||||
const formatPostCreatedDate = new Date(postProperties?.date?.start_date)
|
||||
} else if (pattern === '%day%' && postProperties?.publishTime) {
|
||||
const formatPostCreatedDate = new Date(postProperties?.publishTime)
|
||||
fullSlug += String(formatPostCreatedDate.getUTCDate()).padStart(2, 0)
|
||||
} else if (pattern === '%slug%') {
|
||||
fullSlug += (postProperties.slug ?? postProperties.id)
|
||||
|
||||
Reference in New Issue
Block a user