lastEditTime 字段名调整;修改algolia逻辑

This commit is contained in:
tangly1024
2023-07-29 16:38:49 +08:00
parent c13eb5e65e
commit 7841b556d6
39 changed files with 148 additions and 80 deletions

View File

@@ -145,7 +145,7 @@ const BLOG = {
ALGOLIA_ADMIN_APP_KEY: process.env.ALGOLIA_ADMIN_APP_KEY || null, // 管理后台的KEY不要暴露在代码中在这里查看 https://dashboard.algolia.com/account/api-keys/
ALGOLIA_SEARCH_ONLY_APP_KEY: process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_APP_KEY || null, // 客户端搜索用的KEY
ALGOLIA_INDEX: process.env.NEXT_PUBLIC_ALGOLIA_INDEX || null, // 在Algolia中创建一个index用作数据库
ALGOLIA_RECREATE_DATA: process.env.ALGOLIA_RECREATE_DATA || process.env.npm_lifecycle_event === 'build', // 为true时重新构建索引数据; 默认在build时会构建
// ALGOLIA_RECREATE_DATA: process.env.ALGOLIA_RECREATE_DATA || process.env.npm_lifecycle_event === 'build', // 为true时重新构建索引数据; 默认在build时会构建
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量0为不限制
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量0为不限制

View File

@@ -156,8 +156,8 @@ function TagGroups(props) {
return <Link passHref
key={index}
href={`/tag/${encodeURIComponent(tag.name)}`}
className={'cursor-pointer inline-block whitespace-nowrap'}>
<div className={' flex items-center hover:bg-blue-600 dark:hover:bg-yellow-600 hover:scale-110 hover:text-white rounded-lg px-2 py-0.5 duration-150 transition-all'}>
className={'cursor-pointer inline-block whitespace-nowrap'}>
<div className={' flex items-center text-black dark:text-gray-300 hover:bg-blue-600 dark:hover:bg-yellow-600 hover:scale-110 hover:text-white rounded-lg px-2 py-0.5 duration-150 transition-all'}>
<div className='text-lg'>{tag.name} </div>{tag.count ? <sup className='relative ml-1'>{tag.count}</sup> : <></>}
</div>

View File

@@ -58,7 +58,7 @@ const CommonHead = ({ meta, children }) => {
<>
<meta
property="article:published_time"
content={meta.publishTime}
content={meta.publishDay}
/>
<meta property="article:author" content={BLOG.AUTHOR} />
<meta property="article:section" content={category} />

View File

@@ -17,26 +17,88 @@ const generateAlgoliaSearch = async({ allPages, force = false }) => {
/**
* 上传数据
* 根据上次修改文章日期和上次更新索引数据判断是否需要更新algolia索引
*/
const uploadDataToAlgolia = (post) => {
const uploadDataToAlgolia = async(post) => {
// Connect and authenticate with your Algolia app
const client = algoliasearch(BLOG.ALGOLIA_APP_ID, BLOG.ALGOLIA_ADMIN_APP_KEY)
// Create a new index and add a record
const index = client.initIndex(BLOG.ALGOLIA_INDEX)
const record = {
objectID: post.id,
title: post.title,
category: post.category,
tags: post.tags,
pageCover: post.pageCover,
slug: post.slug,
summary: post.summary,
content: getPageContentText(post, post.blockMap)
if (!post) {
return
}
index.saveObject(record).wait().then(r => {
console.log('Algolia索引', r, record)
})
// 检查是否有索引
let existed
let needUpdateIndex = false
try {
existed = await index.getObject(post.id)
} catch (error) {
// 通常是不存在索引
}
if (!existed || !existed?.lastEditedDate || !existed?.lastIndexDate) {
needUpdateIndex = true
} else {
const lastEditedDate = new Date(existed.lastEditedDate)
const lastIndexDate = new Date(existed.lastIndexDate)
if (lastEditedDate.getTime() > lastIndexDate.getTime()) {
needUpdateIndex = true
}
}
// 如果需要更新搜索
if (needUpdateIndex) {
const record = {
objectID: post.id,
title: post.title,
category: post.category,
tags: post.tags,
pageCover: post.pageCover,
slug: post.slug,
summary: post.summary,
lastEditedDate: post.lastEditedDate, // 更新文章时间
lastIndexDate: new Date(), // 更新索引时间
content: truncate(getPageContentText(post, post.blockMap), 9000) // 索引9000个字节因为api限制总请求内容上限1万个字节
}
console.log('更新Algolia索引', record)
index.saveObject(record).wait().then(r => {
console.log('更新成功', r)
}).catch(err => {
console.log('algolia', err)
})
}
}
/**
* 限制内容字节数
* @param {*} str
* @param {*} maxBytes
* @returns
*/
function truncate(str, maxBytes) {
let count = 0
let result = ''
for (let i = 0; i < str.length; i++) {
const code = str.charCodeAt(i)
if (code <= 0x7f) {
count += 1
} else if (code <= 0x7ff) {
count += 2
} else if (code <= 0xffff) {
count += 3
} else {
count += 4
}
if (count <= maxBytes) {
result += str[i]
} else {
break
}
}
return result
}
export { uploadDataToAlgolia, generateAlgoliaSearch }

View File

@@ -25,7 +25,7 @@ export async function getNotion(pageId) {
title: postInfo?.properties?.title?.[0],
status: 'Published',
createdTime: formatDate(new Date(postInfo.created_time).toString(), BLOG.LANG),
lastEditedTime: formatDate(new Date(postInfo?.last_edited_time).toString(), BLOG.LANG),
lastEditedDay: formatDate(new Date(postInfo?.last_edited_time).toString(), BLOG.LANG),
fullWidth: false,
page_cover: getPageCover(postInfo),
date: { start_date: formatDate(new Date(postInfo?.last_edited_time).toString(), BLOG.LANG) },

View File

@@ -25,7 +25,8 @@ export async function getGlobalData({
from
}) {
// 从notion获取
const db = deepClone(await getNotionPageData({ pageId, from }))
const data = await getNotionPageData({ pageId, from })
const db = deepClone(data)
// 不返回的敏感数据
delete db.block
delete db.schema
@@ -48,8 +49,8 @@ function getLatestPosts({ allPages, from, latestPostCount }) {
const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
const latestPosts = Object.create(allPosts).sort((a, b) => {
const dateA = new Date(a?.lastEditedTime || a?.publishDate)
const dateB = new Date(b?.lastEditedTime || b?.publishDate)
const dateA = new Date(a?.lastEditedDay || a?.publishDate)
const dateB = new Date(b?.lastEditedDay || b?.publishDate)
return dateB - dateA
})
return latestPosts.slice(0, latestPostCount)
@@ -217,7 +218,7 @@ const EmptyData = (pageId) => {
const empty = {
notice: null,
siteInfo: getSiteInfo({}),
allPages: [{ id: 1, title: `无法获取Notion数据请检查Notion_ID \n 当前 ${pageId}`, summary: '访问文档获取帮助→ https://tangly1024.com/article/vercel-deploy-notion-next', status: 'Published', type: 'Post', slug: '13a171332816461db29d50e9f575b00d', date: { start_date: '2023-04-24', lastEditedTime: '2023-04-24', tagItems: [] } }],
allPages: [{ id: 1, title: `无法获取Notion数据请检查Notion_ID \n 当前 ${pageId}`, summary: '访问文档获取帮助→ https://tangly1024.com/article/vercel-deploy-notion-next', status: 'Published', type: 'Post', slug: '13a171332816461db29d50e9f575b00d', date: { start_date: '2023-04-24', lastEditedDay: '2023-04-24', tagItems: [] } }],
allNavPages: [],
collection: [],
collectionQuery: {},

View File

@@ -78,8 +78,9 @@ export default async function getPageProperties(id, block, schema, authToken, ta
mapProperties(properties)
properties.publishDate = new Date(properties?.date?.start_date || value.created_time).getTime()
properties.publishTime = formatDate(properties.publishDate, BLOG.LANG)
properties.lastEditedTime = formatDate(new Date(value?.last_edited_time), BLOG.LANG)
properties.publishDay = formatDate(properties.publishDate, BLOG.LANG)
properties.lastEditedDate = new Date(value?.last_edited_time)
properties.lastEditedDay = formatDate(new Date(value?.last_edited_time), 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) ?? ''
@@ -141,14 +142,14 @@ function generateCustomizeUrl(postProperties) {
let fullPrefix = ''
const allSlugPatterns = BLOG.POST_URL_PREFIX.split('/')
allSlugPatterns.forEach((pattern, idx) => {
if (pattern === '%year%' && postProperties?.publishTime) {
const formatPostCreatedDate = new Date(postProperties?.publishTime)
if (pattern === '%year%' && postProperties?.publishDay) {
const formatPostCreatedDate = new Date(postProperties?.publishDay)
fullPrefix += formatPostCreatedDate.getUTCFullYear()
} else if (pattern === '%month%' && postProperties?.publishTime) {
const formatPostCreatedDate = new Date(postProperties?.publishTime)
} else if (pattern === '%month%' && postProperties?.publishDay) {
const formatPostCreatedDate = new Date(postProperties?.publishDay)
fullPrefix += String(formatPostCreatedDate.getUTCMonth() + 1).padStart(2, 0)
} else if (pattern === '%day%' && postProperties?.publishTime) {
const formatPostCreatedDate = new Date(postProperties?.publishTime)
} else if (pattern === '%day%' && postProperties?.publishDay) {
const formatPostCreatedDate = new Date(postProperties?.publishDay)
fullPrefix += String(formatPostCreatedDate.getUTCDate()).padStart(2, 0)
} else if (pattern === '%slug%') {
fullPrefix += (postProperties.slug ?? postProperties.id)

View File

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

View File

@@ -26,7 +26,7 @@ export async function generateSitemapXml({ allPages }) {
const slugWithoutLeadingSlash = post?.slug?.startsWith('/') ? post?.slug?.slice(1) : post.slug
urls.push({
loc: `${BLOG.LINK}/${slugWithoutLeadingSlash}`,
lastmod: new Date(post?.publishTime).toISOString().split('T')[0],
lastmod: new Date(post?.publishDay).toISOString().split('T')[0],
changefreq: 'daily'
})
})

View File

@@ -117,7 +117,13 @@ export function deepClone(obj) {
if (obj && typeof obj === 'object') {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
newObj[key] = (obj && typeof obj[key] === 'object') ? deepClone(obj[key]) : obj[key]
if (obj[key] instanceof Date) { // 判断属性值是否为 Date 对象
newObj[key] = new Date(obj[key].getTime()).toISOString() // 直接拷贝引用
} else if (obj[key] && typeof obj[key] === 'object') {
newObj[key] = deepClone(obj[key])
} else {
newObj[key] = obj[key]
}
}
}
}

View File

@@ -64,8 +64,8 @@ export async function getStaticProps({ params: { prefix, slug } }) {
if (!props?.posts?.blockMap) {
props.post.blockMap = await getPostBlocks(props.post.id, from)
}
// 生成全文索引
if (BLOG.ALGOLIA_APP_ID && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA) && process.env.npm_lifecycle_event === 'build') {
// 生成全文索引 && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA)
if (BLOG.ALGOLIA_APP_ID) {
uploadDataToAlgolia(props?.post)
}

View File

@@ -95,8 +95,10 @@ export async function getStaticPaths() {
}
}
export async function getStaticProps({ params: { prefix } }) {
let fullSlug = prefix
export async function getStaticProps(p) {
const { params } = p
console.log('getStaticProps', p)
let fullSlug = params.prefix
if (JSON.parse(BLOG.PSEUDO_STATIC)) {
if (!fullSlug.endsWith('.html')) {
fullSlug += '.html'
@@ -111,7 +113,7 @@ export async function getStaticProps({ params: { prefix } }) {
// 处理非列表内文章的内信息
if (!props?.post) {
const pageId = prefix.slice(-1)[0]
const pageId = params.PSEUDO_STATICprefix.slice(-1)[0]
if (pageId.length >= 32) {
const post = await getNotion(pageId)
props.post = post
@@ -129,8 +131,8 @@ export async function getStaticProps({ params: { prefix } }) {
props.post.blockMap = await getPostBlocks(props.post.id, from)
}
// 生成全文索引
if (BLOG.ALGOLIA_APP_ID && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA) && process.env.npm_lifecycle_event === 'build') {
// 生成全文索引 && process.env.npm_lifecycle_event === 'build' && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA)
if (BLOG.ALGOLIA_APP_ID) {
uploadDataToAlgolia(props?.post)
}

View File

@@ -6,7 +6,6 @@ import { generateRobotsTxt } from '@/lib/robots.txt'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
import { generateAlgoliaSearch } from '@/lib/algolia'
/**
* 首页布局
@@ -64,9 +63,6 @@ export async function getStaticProps() {
}
// 生成全文索引 - 仅在 yarn build 时执行 && process.env.npm_lifecycle_event === 'build'
if (BLOG.ALGOLIA_APP_ID && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA)) {
generateAlgoliaSearch({ allPages: props.allPages })
}
delete props.allPages

View File

@@ -42,7 +42,7 @@ export const getServerSideProps = async (ctx) => {
const slugWithoutLeadingSlash = post?.slug.startsWith('/') ? post?.slug?.slice(1) : post.slug
return {
loc: `${BLOG.LINK}/${slugWithoutLeadingSlash}`,
lastmod: new Date(post?.publishTime).toISOString().split('T')[0],
lastmod: new Date(post?.publishDay).toISOString().split('T')[0],
changefreq: 'daily',
priority: '0.7'
}

View File

@@ -29,12 +29,12 @@ export const ArticleInfo = (props) => {
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">
{post?.publishTime}
{post?.publishDay}
</Link>
<span className='mr-2'>|</span>
<span className='mx-2 text-gray-400 dark:text-gray-500'>
{locale.COMMON.LAST_EDITED_TIME}: {post?.lastEditedTime}
{locale.COMMON.LAST_EDITED_TIME}: {post?.lastEditedDay}
</span>
<span className='mr-2'>|</span>
<span className="hidden busuanzi_container_page_pv font-light mr-2">

View File

@@ -19,9 +19,9 @@ export default function BlogListGroupByDate({ archiveTitle, archivePosts }) {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">
{post?.publishTime}
{post?.publishDay}
</span>{' '}
&nbsp;
<Link href={`${BLOG.SUB_PATH}/${post.slug}`} className="dark:text-gray-400 dark:hover:text-gray-300 overflow-x-hidden hover:underline cursor-pointer text-gray-600">

View File

@@ -59,12 +59,12 @@ export default function ArticleDetail(props) {
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">
{post?.publishTime}
{post?.publishDay}
</Link>
<span className='mr-2'>|</span>
<span className='mx-2 text-gray-400 dark:text-gray-500'>
{locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedTime}
{locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedDay}
</span>
</>)}

View File

@@ -26,7 +26,7 @@ const BlogArchiveItem = ({ posts = [], archiveTitle }) => {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp;
<Link

View File

@@ -70,7 +70,7 @@ export default function ArticleAdjacent({ prev, next }) {
{/* 桌面端 */}
<div id='pc-next-post' className={`hidden md:block fixed z-20 right-16 bottom-4 duration-200 transition-all ${isScrollEnd ? 'mb-0 opacity-100' : '-mb-24 opacity-0'}`}>
<div id='pc-next-post' className={`hidden md:block fixed z-40 right-16 bottom-4 duration-200 transition-all ${isScrollEnd ? 'mb-0 opacity-100' : '-mb-24 opacity-0'}`}>
<Link
href={`/${next.slug}`}
className='cursor-pointer duration transition-all h-24 dark:bg-[#1e1e1e] border dark:border-gray-600 p-3 bg-white dark:text-gray-300 dark:hover:text-yellow-600 hover:text-white hover:font-bold hover:bg-gray-400 rounded-lg flex flex-col justify-between'

View File

@@ -52,7 +52,7 @@ export default function LatestPostsGroupMini ({ latestPosts, siteInfo }) {
>
<div>
<div className='line-clamp-2 menu-link'>{post.title}</div>
<div className="text-gray-500">{post.lastEditedTime}</div>
<div className="text-gray-500">{post.lastEditedDay}</div>
</div>
</div>

View File

@@ -79,13 +79,13 @@ export default function PostHeader({ post, siteInfo }) {
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className="pl-1 mr-2 cursor-pointer hover:underline">
<i className="fa-regular fa-calendar"></i> {post?.publishTime}
<i className="fa-regular fa-calendar"></i> {post?.publishDay}
</Link>
</>
)}
<div className="pl-1 mr-2">
<i className="fa-regular fa-calendar-check"></i> {post.lastEditedTime}
<i className="fa-regular fa-calendar-check"></i> {post.lastEditedDay}
</div>
</div>

View File

@@ -26,7 +26,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp;
<Link

View File

@@ -76,7 +76,7 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary
className="font-light menu-link cursor-pointer text-sm leading-4 mr-3">
<i className="far fa-calendar-alt mr-1" />
{post?.publishTime || post.lastEditedTime}
{post?.publishDay || post.lastEditedDay}
</Link>

View File

@@ -52,7 +52,7 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
>
<div>
<div className='line-clamp-2 menu-link'>{post.title}</div>
<div className="text-gray-500">{post.lastEditedTime}</div>
<div className="text-gray-500">{post.lastEditedDay}</div>
</div>
</div>

View File

@@ -47,13 +47,13 @@ export default function PostHeader({ post, siteInfo }) {
passHref
className="pl-1 mr-2 cursor-pointer hover:underline">
{locale.COMMON.POST_TIME}: {post?.publishTime}
{locale.COMMON.POST_TIME}: {post?.publishDay}
</Link>
</>
)}
<div className="pl-1 mr-2">
{locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedTime}
{locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedDay}
</div>
</div>

View File

@@ -28,11 +28,11 @@ export const ArticleInfo = (props) => {
passHref
className="cursor-pointer whitespace-nowrap">
<i className='far fa-calendar-minus fa-fw'/> {locale.COMMON.POST_TIME}: {post?.publishTime}
<i className='far fa-calendar-minus fa-fw'/> {locale.COMMON.POST_TIME}: {post?.publishDay}
</Link>
<span className='whitespace-nowrap'>
<i className='far fa-calendar-check fa-fw' />{locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedTime}
<i className='far fa-calendar-check fa-fw' />{locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedDay}
</span>
<span className="hidden busuanzi_container_page_pv font-light mr-2">
<i className='mr-1 fas fa-eye' /><span className="busuanzi_value_page_pv" />

View File

@@ -26,7 +26,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp;
<Link

View File

@@ -62,7 +62,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
className="font-light hover:underline cursor-pointer text-sm leading-4 mr-3">
<i className="far fa-clock mr-1" />
{post.date?.start_date || post.lastEditedTime}
{post.date?.start_date || post.lastEditedDay}
</Link>
<TwikooCommentCount post={post} className='hover:underline cursor-pointer text-sm'/>

View File

@@ -17,9 +17,9 @@ export default function ArticleInfo(props) {
{/* meta */}
<section className="py-2 items-center text-sm px-1">
<div className='flex flex-wrap text-gray-500 py-1 dark:text-gray-600'>
<span className='whitespace-nowrap'> <i className='far fa-calendar mr-2' />{post?.publishTime}</span>
<span className='whitespace-nowrap'> <i className='far fa-calendar mr-2' />{post?.publishDay}</span>
<span className='mx-1'>|</span>
<span className='whitespace-nowrap mr-2'><i className='far fa-calendar-check mr-2' />{post?.lastEditedTime}</span>
<span className='whitespace-nowrap mr-2'><i className='far fa-calendar-check mr-2' />{post?.lastEditedDay}</span>
<div className="hidden busuanzi_container_page_pv font-light mr-2 whitespace-nowrap">
<i className="mr-1 fas fa-eye" /><span className="busuanzi_value_page_pv" />
</div>

View File

@@ -17,7 +17,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
<li 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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">
{post.date?.start_date}
</span>{' '}

View File

@@ -59,10 +59,10 @@ export default function ArticleDetail(props) {
passHref
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">
<i className='far fa-calendar mr-1' /> {post?.publishTime}
<i className='far fa-calendar mr-1' /> {post?.publishDay}
</div>
</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.lastEditedDay} </span>
<div className="hidden busuanzi_container_page_pv font-light mr-2">
<i className='mr-1 fas fa-eye' />

View File

@@ -26,7 +26,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">{post.date?.start_date}</span>{' '}
&nbsp;
<Link

View File

@@ -32,7 +32,7 @@ export const ArticleInfo = (props) => {
<span className="block">&nbsp;/&nbsp;</span>
</div>
<div className="mr-2 mb-4 md:ml-0">
{post?.publishTime}
{post?.publishDay}
</div>
{post?.tags && (
<div className="flex flex-nowrap max-w-full overflow-x-auto article-tags">

View File

@@ -19,7 +19,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">
{post.date?.start_date}
</span>{' '}

View File

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

View File

@@ -32,7 +32,7 @@ export const ArticleInfo = (props) => {
<span className="block">&nbsp;/&nbsp;</span>
</div>
<div className="mr-2 mb-4 md:ml-0">
{post?.publishTime}
{post?.publishDay}
</div>
{post?.tags && (
<div className="flex flex-nowrap max-w-full overflow-x-auto article-tags">

View File

@@ -19,7 +19,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">
{post.date?.start_date}
</span>{' '}

View File

@@ -20,7 +20,7 @@ export const ArticleInfo = (props) => {
{post?.type !== 'Page' && (<>
<div className="mb-4 text-sm text-gray-700 dark:text-gray-300">
<span> <i className="fa-regular fa-user"></i> <a href={CONFIG.AUTHOR_LINK}>{BLOG.AUTHOR}</a></span>
<span> - <i className="fa-regular fa-clock"></i> {post?.publishTime}</span>
<span> - <i className="fa-regular fa-clock"></i> {post?.publishDay}</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>)}
</div>
@@ -32,12 +32,12 @@ export const ArticleInfo = (props) => {
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
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">
{post?.publishTime}
{post?.publishDay}
</Link>
</span>
<span className='mr-2'>|</span>
<span className='mx-2 text-gray-400 dark:text-gray-500'>
{locale.COMMON.LAST_EDITED_TIME}: {post?.lastEditedTime}
{locale.COMMON.LAST_EDITED_TIME}: {post?.lastEditedDay}
</span>
<span className='mr-2'>|</span>
<span className="hidden busuanzi_container_page_pv font-light mr-2">

View File

@@ -19,7 +19,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
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"
>
<div id={post?.publishTime}>
<div id={post?.publishDay}>
<span className="text-gray-400">
{post.date?.start_date}
</span>{' '}