调整文章日期显示

This commit is contained in:
tangly1024.com
2023-06-29 12:44:46 +08:00
parent d07a145029
commit 9ac2bbb180
31 changed files with 61 additions and 67 deletions

View File

@@ -45,8 +45,8 @@ export async function getAllPosts({ notionPageData, from, pageType }) {
// Sort by date // Sort by date
if (BLOG.POSTS_SORT_BY === 'date') { if (BLOG.POSTS_SORT_BY === 'date') {
posts.sort((a, b) => { posts.sort((a, b) => {
const dateA = new Date(a?.date?.start_date || a.createdTime) const dateA = new Date(a?.publishTime || a.createdTime)
const dateB = new Date(b?.date?.start_date || b.createdTime) const dateB = new Date(b?.publishTime || b.createdTime)
return dateB - dateA return dateB - dateA
}) })
} }

View File

@@ -48,8 +48,8 @@ function getLatestPosts({ allPages, from, latestPostCount }) {
const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published') const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
const latestPosts = Object.create(allPosts).sort((a, b) => { const latestPosts = Object.create(allPosts).sort((a, b) => {
const dateA = new Date(a?.lastEditedTime || a?.createdTime || a?.date?.start_date) const dateA = new Date(a?.lastEditedTime || a?.createdTime || a?.publishTime)
const dateB = new Date(b?.lastEditedTime || b?.createdTime || b?.date?.start_date) const dateB = new Date(b?.lastEditedTime || b?.createdTime || b?.publishTime)
return dateB - dateA return dateB - dateA
}) })
return latestPosts.slice(0, latestPostCount) return latestPosts.slice(0, latestPostCount)
@@ -298,9 +298,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
// Sort by date // Sort by date
if (BLOG.POSTS_SORT_BY === 'date') { if (BLOG.POSTS_SORT_BY === 'date') {
allPages.sort((a, b) => { allPages.sort((a, b) => {
const dateA = new Date(a?.date?.start_date || a.createdTime) return b.publishTime - a.publishTime
const dateB = new Date(b?.date?.start_date || b.createdTime)
return dateB - dateA
}) })
} }

View File

@@ -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.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.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG)
properties.fullWidth = value.format?.page_full_width ?? false properties.fullWidth = value.format?.page_full_width ?? false
properties.pageIcon = mapImgUrl(block[id].value?.format?.page_icon, block[id].value) ?? '' 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.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.pageCoverThumbnail = mapImgUrl(block[id].value?.format?.page_cover, block[id].value, 'block', 'pageCoverThumbnail') ?? ''
properties.content = value.content ?? [] properties.content = value.content ?? []
properties.password = properties.password properties.password = properties.password ? md5(properties.slug + properties.password) : ''
? md5(properties.slug + properties.password)
: ''
properties.tagItems = properties?.tags?.map(tag => { properties.tagItems = properties?.tags?.map(tag => {
return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' } 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 return properties
} }
/**
* 映射用户自定义表头
*/
function mapProperties(properties) { function mapProperties(properties) {
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_post) { if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_post) {
properties.type = 'Post' properties.type = 'Post'
@@ -132,14 +134,14 @@ function generateCustomizeUrl(postProperties) {
let fullSlug = '' let fullSlug = ''
const allSlugPatterns = BLOG.POST_URL_PREFIX.split('/') const allSlugPatterns = BLOG.POST_URL_PREFIX.split('/')
allSlugPatterns.forEach((pattern, idx) => { allSlugPatterns.forEach((pattern, idx) => {
if (pattern === '%year%' && postProperties?.date?.start_date) { if (pattern === '%year%' && postProperties?.publishTime) {
const formatPostCreatedDate = new Date(postProperties?.date?.start_date) const formatPostCreatedDate = new Date(postProperties?.publishTime)
fullSlug += formatPostCreatedDate.getUTCFullYear() fullSlug += formatPostCreatedDate.getUTCFullYear()
} else if (pattern === '%month%' && postProperties?.date?.start_date) { } else if (pattern === '%month%' && postProperties?.publishTime) {
const formatPostCreatedDate = new Date(postProperties?.date?.start_date) const formatPostCreatedDate = new Date(postProperties?.publishTime)
fullSlug += String(formatPostCreatedDate.getUTCMonth() + 1).padStart(2, 0) fullSlug += String(formatPostCreatedDate.getUTCMonth() + 1).padStart(2, 0)
} else if (pattern === '%day%' && postProperties?.date?.start_date) { } else if (pattern === '%day%' && postProperties?.publishTime) {
const formatPostCreatedDate = new Date(postProperties?.date?.start_date) const formatPostCreatedDate = new Date(postProperties?.publishTime)
fullSlug += String(formatPostCreatedDate.getUTCDate()).padStart(2, 0) fullSlug += String(formatPostCreatedDate.getUTCDate()).padStart(2, 0)
} else if (pattern === '%slug%') { } else if (pattern === '%slug%') {
fullSlug += (postProperties.slug ?? postProperties.id) fullSlug += (postProperties.slug ?? postProperties.id)

View File

@@ -46,7 +46,7 @@ export async function generateRss(posts) {
link: `${BLOG.LINK}/${post.slug}`, link: `${BLOG.LINK}/${post.slug}`,
description: post.summary, description: post.summary,
content: await createFeedContent(post), content: await createFeedContent(post),
date: new Date(post?.date?.start_date || post?.createdTime) date: new Date(post?.publishTime || post?.createdTime)
}) })
} }

View File

@@ -24,7 +24,7 @@ export async function generateSitemapXml({ allPages }) {
allPages?.forEach(post => { allPages?.forEach(post => {
urls.push({ urls.push({
loc: `${BLOG.LINK}/${post.slug}`, loc: `${BLOG.LINK}/${post.slug}`,
lastmod: new Date(post?.date?.start_date || post?.createdTime).toISOString().split('T')[0], lastmod: new Date(post?.publishTime || post?.createdTime).toISOString().split('T')[0],
changefreq: 'daily' changefreq: 'daily'
}) })
}) })

View File

@@ -34,8 +34,8 @@ export async function getStaticProps() {
const postsSortByDate = Object.create(props.posts) const postsSortByDate = Object.create(props.posts)
postsSortByDate.sort((a, b) => { postsSortByDate.sort((a, b) => {
const dateA = new Date(a?.date?.start_date || a.createdTime) const dateA = new Date(a?.publishTime || a.createdTime)
const dateB = new Date(b?.date?.start_date || b.createdTime) const dateB = new Date(b?.publishTime || b.createdTime)
return dateB - dateA return dateB - dateA
}) })

View File

@@ -41,7 +41,7 @@ export const getServerSideProps = async (ctx) => {
const postFields = allPages?.filter(p => p.status === BLOG.NOTION_PROPERTY_NAME.status_publish)?.map(post => { const postFields = allPages?.filter(p => p.status === BLOG.NOTION_PROPERTY_NAME.status_publish)?.map(post => {
return { return {
loc: `${BLOG.LINK}/${post.slug}`, loc: `${BLOG.LINK}/${post.slug}`,
lastmod: new Date(post?.date?.start_date || post?.createdTime).toISOString().split('T')[0], lastmod: new Date(post?.publishTime || post?.createdTime).toISOString().split('T')[0],
changefreq: 'daily', changefreq: 'daily',
priority: '0.7' priority: '0.7'
} }

View File

@@ -20,7 +20,7 @@ export const LayoutArchive = props => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400"> <span className="text-gray-400">
{post.date?.start_date} {post.date?.start_date}
</span>{' '} </span>{' '}

View File

@@ -1,12 +1,10 @@
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import formatDate from '@/lib/formatDate'
export const ArticleInfo = (props) => { export const ArticleInfo = (props) => {
const { post } = props const { post } = props
const { locale } = useGlobal() const { locale } = useGlobal()
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE)
return ( return (
<section className="flex-wrap flex mt-2 text-gray-400 dark:text-gray-400 font-light leading-8"> <section className="flex-wrap flex mt-2 text-gray-400 dark:text-gray-400 font-light leading-8">
@@ -26,11 +24,11 @@ export const ArticleInfo = (props) => {
{post?.type !== 'Page' && (<> {post?.type !== 'Page' && (<>
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed"> className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed">
{date} {post?.publishTime}
</Link> </Link>
<span className='mr-2'>|</span> <span className='mr-2'>|</span>

View File

@@ -19,7 +19,7 @@ export default function ArticleDetail(props) {
if (!post) { if (!post) {
return <></> return <></>
} }
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE) const date = formatDate(post?.publishTime || post?.createdTime, locale.LOCALE)
return ( return (
<div id="container" className="max-w-5xl overflow-x-auto flex-grow mx-auto w-screen md:w-full "> <div id="container" className="max-w-5xl overflow-x-auto flex-grow mx-auto w-screen md:w-full ">
{post?.type && !post?.type !== 'Page' && post?.pageCover && ( {post?.type && !post?.type !== 'Page' && post?.pageCover && (
@@ -57,7 +57,7 @@ export default function ArticleDetail(props) {
{post?.type !== 'Page' && (<> {post?.type !== 'Page' && (<>
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed"> className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed">

View File

@@ -26,7 +26,7 @@ const BlogArchiveItem = ({ posts = [], archiveTitle }) => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '} <span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp; &nbsp;
<Link <Link

View File

@@ -22,7 +22,7 @@ export const LayoutArchive = props => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400"> <span className="text-gray-400">
{post.date?.start_date} {post.date?.start_date}
</span>{' '} </span>{' '}

View File

@@ -21,7 +21,7 @@ export const LayoutIndex = (props) => {
console.log('请检查您的Notion数据库中是否包含此slug页面 ', CONFIG_GITBOOK.INDEX_PAGE) console.log('请检查您的Notion数据库中是否包含此slug页面 ', CONFIG_GITBOOK.INDEX_PAGE)
const containerInner = document.getElementById('container-inner') const containerInner = document.getElementById('container-inner')
const newHTML = `<h1 class="text-3xl pt-12 dark:text-gray-300">配置有误</h1><blockquote class="notion-quote notion-block-ce76391f3f2842d386468ff1eb705b92"><div>请在您的notion中添加一个slug为${CONFIG_GITBOOK.INDEX_PAGE}的文章</div></blockquote>` const newHTML = `<h1 class="text-3xl pt-12 dark:text-gray-300">配置有误</h1><blockquote class="notion-quote notion-block-ce76391f3f2842d386468ff1eb705b92"><div>请在您的notion中添加一个slug为${CONFIG_GITBOOK.INDEX_PAGE}的文章</div></blockquote>`
containerInner.insertAdjacentHTML('afterbegin', newHTML) containerInner?.insertAdjacentHTML('afterbegin', newHTML)
} }
} }
}, 7 * 1000) }, 7 * 1000)

View File

@@ -8,7 +8,7 @@ import React from 'react'
export const LayoutIndex = (props) => { export const LayoutIndex = (props) => {
const headerSlot = CONFIG_HEXO.HOME_BANNER_ENABLE && <Header {...props} /> const headerSlot = CONFIG_HEXO.HOME_BANNER_ENABLE && <Header {...props} />
return <LayoutBase {...props} headerSlot={headerSlot}> return <LayoutBase {...props} headerSlot={headerSlot} className='pt-8'>
{BLOG.POST_LIST_STYLE === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />} {BLOG.POST_LIST_STYLE === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
</LayoutBase> </LayoutBase>
} }

View File

@@ -26,7 +26,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-indigo-500 dark:hover:border-indigo-300 dark:border-indigo-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-indigo-500 dark:hover:border-indigo-300 dark:border-indigo-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '} <span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp; &nbsp;
<Link <Link

View File

@@ -24,7 +24,7 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary
</Link> </Link>
{/* 分类 */} {/* 分类 */}
<div { post?.category && <div
className={`flex mt-2 items-center ${showPreview ? 'justify-center' : 'justify-start' className={`flex mt-2 items-center ${showPreview ? 'justify-center' : 'justify-start'
} flex-wrap dark:text-gray-500 text-gray-400 `} } flex-wrap dark:text-gray-500 text-gray-400 `}
> >
@@ -39,7 +39,7 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary
</Link> </Link>
<TwikooCommentCount className='text-sm hover:text-indigo-700 dark:hover:text-indigo-400' post={post}/> <TwikooCommentCount className='text-sm hover:text-indigo-700 dark:hover:text-indigo-400' post={post}/>
</div> </div>}
{/* 摘要 */} {/* 摘要 */}
{(!showPreview || showSummary) && !post.results && ( {(!showPreview || showSummary) && !post.results && (
@@ -70,12 +70,12 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary
<div className="text-gray-400 justify-between flex"> <div className="text-gray-400 justify-between flex">
{/* 日期 */} {/* 日期 */}
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
className="font-light menu-link cursor-pointer text-sm leading-4 mr-3"> className="font-light menu-link cursor-pointer text-sm leading-4 mr-3">
<i className="far fa-calendar-alt mr-1" /> <i className="far fa-calendar-alt mr-1" />
{post.date?.start_date || post.lastEditedTime} {post?.publishTime || post.lastEditedTime}
</Link> </Link>

View File

@@ -14,7 +14,7 @@ export default function HeaderArticle({ post, siteInfo }) {
const headerImage = post?.pageCover ? `url("${post.pageCover}")` : `url("${siteInfo?.pageCover}")` const headerImage = post?.pageCover ? `url("${post.pageCover}")` : `url("${siteInfo?.pageCover}")`
const date = formatDate( const date = formatDate(
post?.date?.start_date || post?.createdTime, post?.publishTime || post?.createdTime,
locale.LOCALE locale.LOCALE
) )
@@ -57,7 +57,7 @@ export default function HeaderArticle({ post, siteInfo }) {
{post?.type !== 'Page' && ( {post?.type !== 'Page' && (
<> <>
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
className="pl-1 mr-2 cursor-pointer hover:underline"> className="pl-1 mr-2 cursor-pointer hover:underline">

View File

@@ -8,7 +8,7 @@ export const ArticleInfo = (props) => {
const { post } = props const { post } = props
const { locale } = useGlobal() const { locale } = useGlobal()
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE) const date = formatDate(post?.publishTime || post?.createdTime, locale.LOCALE)
return ( return (
<section className='mb-3 dark:text-gray-200'> <section className='mb-3 dark:text-gray-200'>
@@ -25,7 +25,7 @@ export const ArticleInfo = (props) => {
<div className='flex flex-wrap gap-3 mt-5 text-sm'> <div className='flex flex-wrap gap-3 mt-5 text-sm'>
{post?.type !== 'Page' && (<> {post?.type !== 'Page' && (<>
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
className="cursor-pointer whitespace-nowrap"> className="cursor-pointer whitespace-nowrap">

View File

@@ -26,7 +26,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-indigo-500 dark:hover:border-indigo-300 dark:border-indigo-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-indigo-500 dark:hover:border-indigo-300 dark:border-indigo-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '} <span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp; &nbsp;
<Link <Link

View File

@@ -57,7 +57,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
<div className='text-gray-800 justify-between flex my-2 dark:text-gray-300'> <div className='text-gray-800 justify-between flex my-2 dark:text-gray-300'>
<div> <div>
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
className="font-light hover:underline cursor-pointer text-sm leading-4 mr-3"> className="font-light hover:underline cursor-pointer text-sm leading-4 mr-3">

View File

@@ -22,7 +22,7 @@ export const LayoutArchive = props => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400"> <span className="text-gray-400">
{post.date?.start_date} {post.date?.start_date}
</span>{' '} </span>{' '}

View File

@@ -20,7 +20,7 @@ export const LayoutSlug = props => {
const { locale } = useGlobal() const { locale } = useGlobal()
const date = formatDate( const date = formatDate(
post?.date?.start_date || post?.createdTime, post?.publishTime || post?.createdTime,
locale.LOCALE locale.LOCALE
) )
if (!post) { if (!post) {

View File

@@ -4,7 +4,6 @@ import Comment from '@/components/Comment'
import RecommendPosts from './RecommendPosts' import RecommendPosts from './RecommendPosts'
import ShareBar from '@/components/ShareBar' import ShareBar from '@/components/ShareBar'
import TagItem from './TagItem' import TagItem from './TagItem'
import formatDate from '@/lib/formatDate'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import Link from 'next/link' import Link from 'next/link'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
@@ -24,7 +23,6 @@ export default function ArticleDetail(props) {
const url = BLOG.LINK + useRouter().asPath const url = BLOG.LINK + useRouter().asPath
const { locale } = useGlobal() const { locale } = useGlobal()
const showArticleInfo = CONFIG_NEXT.ARTICLE_INFO const showArticleInfo = CONFIG_NEXT.ARTICLE_INFO
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE)
return ( return (
<div id="container" <div id="container"
@@ -56,11 +54,11 @@ export default function ArticleDetail(props) {
<div className='flex flex-wrap justify-center'> <div className='flex flex-wrap justify-center'>
{post?.type !== 'Page' && (<> {post?.type !== 'Page' && (<>
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
legacyBehavior> legacyBehavior>
<div className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed"> <div className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed">
<i className='far fa-calendar mr-1' /> {date} <i className='far fa-calendar mr-1' /> {post?.publishTime}
</div> </div>
</Link> </Link>
<span className='mr-2'> | <i className='far fa-calendar-check mr-2' />{post.lastEditedTime} </span> <span className='mr-2'> | <i className='far fa-calendar-check mr-2' />{post.lastEditedTime} </span>

View File

@@ -26,7 +26,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '} <span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp; &nbsp;
<Link <Link

View File

@@ -57,7 +57,7 @@ const BlogPostCard = ({ post, showSummary }) => {
</> </>
)} )}
<Link <Link
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} href={`/archive#${post?.publishTime?.substr(0, 7)}`}
passHref passHref
className="hover:text-blue-500 dark:hover:text-blue-400 font-light hover:underline cursor-pointer text-sm leading-4 mr-3"> className="hover:text-blue-500 dark:hover:text-blue-400 font-light hover:underline cursor-pointer text-sm leading-4 mr-3">
{post.date?.start_date} {post.date?.start_date}

View File

@@ -20,7 +20,7 @@ export const LayoutArchive = props => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400"> <span className="text-gray-400">
{post.date?.start_date} {post.date?.start_date}
</span>{' '} </span>{' '}

View File

@@ -34,7 +34,7 @@ export const ArticleInfo = (props) => {
</div> </div>
<div className="mr-2 mb-4 md:ml-0"> <div className="mr-2 mb-4 md:ml-0">
{formatDate( {formatDate(
post?.date?.start_date || post.createdTime, post?.publishTime || post.createdTime,
BLOG.LANG BLOG.LANG
)} )}
</div> </div>

View File

@@ -12,7 +12,7 @@ const BlogPost = ({ post }) => {
{post.title} {post.title}
</h2> </h2>
<time className="flex-shrink-0 text-gray-600 dark:text-gray-400"> <time className="flex-shrink-0 text-gray-600 dark:text-gray-400">
{formatDate(post?.date?.start_date || post.createdTime, BLOG.LANG)} {formatDate(post?.publishTime || post.createdTime, BLOG.LANG)}
</time> </time>
</header> </header>
<main> <main>

View File

@@ -20,7 +20,7 @@ export const LayoutArchive = props => {
key={post.id} key={post.id}
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500" className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
> >
<div id={post?.date?.start_date}> <div id={post?.publishTime}>
<span className="text-gray-400"> <span className="text-gray-400">
{post.date?.start_date} {post.date?.start_date}
</span>{' '} </span>{' '}

View File

@@ -1,6 +1,5 @@
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import formatDate from '@/lib/formatDate'
import CONFIG_SIMPLE from '../config_simple' import CONFIG_SIMPLE from '../config_simple'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
@@ -8,7 +7,6 @@ export const ArticleInfo = (props) => {
const { post } = props const { post } = props
const { locale } = useGlobal() const { locale } = useGlobal()
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE)
return ( return (
<section className="flex-wrap flex mt-2 text-gray-400 dark:text-gray-400 font-light leading-8"> <section className="flex-wrap flex mt-2 text-gray-400 dark:text-gray-400 font-light leading-8">
@@ -21,21 +19,21 @@ export const ArticleInfo = (props) => {
{post?.type !== 'Page' && (<> {post?.type !== 'Page' && (<>
<div className="mb-4 text-sm text-gray-700 dark:text-gray-300"> <div className="mb-4 text-sm text-gray-700 dark:text-gray-300">
<span> <i className="fa-regular fa-user"></i> <a href={CONFIG_SIMPLE.AUTHOR_LINK}>{BLOG.AUTHOR}</a></span> <span> <i className="fa-regular fa-user"></i> <a href={CONFIG_SIMPLE.AUTHOR_LINK}>{BLOG.AUTHOR}</a></span>
<span> - <i className="fa-regular fa-clock"></i> {post?.date?.start_date || post?.createdTime}</span> <span> - <i className="fa-regular fa-clock"></i> {post?.publishTime}</span>
{post?.category && <span> - <i className="fa-regular fa-folder"></i> <a href={`/category/${post?.category}`} className="hover:text-red-400 transition-all duration-200">{post?.category}</a></span>} {post?.category && <span> - <i className="fa-regular fa-folder"></i> <a href={`/category/${post?.category}`} className="hover:text-red-400 transition-all duration-200">{post?.category}</a></span>}
{post?.tags && post.tags?.length > 0 && post?.tags.map(t => <span key={t}> / <Link href={`/tag/${t}`}><span className=' hover:text-red-400 transition-all duration-200'>{t}</span></Link></span>)} {post?.tags && post.tags?.length > 0 && post?.tags.map(t => <span key={t}> / <Link href={`/tag/${t}`}><span className=' hover:text-red-400 transition-all duration-200'>{t}</span></Link></span>)}
</div> </div>
</>)} </>)}
{post?.type !== 'Page' && (<> {post?.type !== 'Page' && (<>
<Link <span>{locale.COMMON.POST_TIME}:
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} <Link
passHref href={`/archive#${post?.publishTime?.substr(0, 7)}`}
className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed"> passHref
className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed">
{date} {post?.publishTime}
</Link>
</Link> </span>
<span className='mr-2'>|</span> <span className='mr-2'>|</span>
<span className='mx-2 text-gray-400 dark:text-gray-500'> <span className='mx-2 text-gray-400 dark:text-gray-500'>
{locale.COMMON.LAST_EDITED_TIME}: {post?.lastEditedTime} {locale.COMMON.LAST_EDITED_TIME}: {post?.lastEditedTime}

View File

@@ -23,7 +23,7 @@ export const BlogItem = props => {
<div className='space-x-2'> <div className='space-x-2'>
<span> <a href={CONFIG_SIMPLE.AUTHOR_LINK} className='p-1 hover:text-red-400 transition-all duration-200'><i className="fa-regular fa-user"></i> {BLOG.AUTHOR}</a></span> <span> <a href={CONFIG_SIMPLE.AUTHOR_LINK} className='p-1 hover:text-red-400 transition-all duration-200'><i className="fa-regular fa-user"></i> {BLOG.AUTHOR}</a></span>
<span> <span>
<Link className='p-1 hover:text-red-400 transition-all duration-200' href={`/archive#${post?.date?.start_date?.substr(0, 7)}`}> <Link className='p-1 hover:text-red-400 transition-all duration-200' href={`/archive#${post?.publishTime?.substr(0, 7)}`}>
<i className="fa-regular fa-clock" /> {post.date?.start_date || post.createdTime} <i className="fa-regular fa-clock" /> {post.date?.start_date || post.createdTime}
</Link> </Link>
</span> </span>