heo 添加最后更新日期,修复归档日期bug

This commit is contained in:
tangly1024.com
2023-07-27 18:32:21 +08:00
parent a43445377e
commit 2a83af39a9
12 changed files with 28 additions and 12 deletions

View File

@@ -9,6 +9,7 @@ export default function formatDate (date, local) {
const d = new Date(date)
const options = { year: 'numeric', month: 'short', day: 'numeric' }
const res = d.toLocaleDateString(local, options)
// 如果格式是中文日期,则转为横杆
const format = local.slice(0, 2).toLowerCase() === 'zh'
? res.replace('年', '-').replace('月', '-').replace('日', '')
: res

View File

@@ -1,5 +1,6 @@
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import { formatDateFmt } from '@/lib/formatDate'
export const ArticleInfo = (props) => {
const { post } = props
@@ -24,7 +25,7 @@ export const ArticleInfo = (props) => {
{post?.type !== 'Page' && (<>
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
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">

View File

@@ -7,6 +7,7 @@ import Link from 'next/link'
import ArticleAround from './ArticleAround'
import { AdSlot } from '@/components/GoogleAdsense'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
/**
*
@@ -54,7 +55,7 @@ export default function ArticleDetail(props) {
{post?.type !== 'Page' && (<>
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
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">

View File

@@ -5,6 +5,7 @@ import WavesArea from './WavesArea'
import { HashTag } from '@/components/HeroIcons'
import WordCount from '@/components/WordCount'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
export default function PostHeader({ post, siteInfo }) {
if (!post) {
@@ -75,14 +76,18 @@ export default function PostHeader({ post, siteInfo }) {
{post?.type !== 'Page' && (
<>
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className="pl-1 mr-2 cursor-pointer hover:underline">
<i className="fa-solid fa-calendar-days"></i> {post?.publishTime}
<i className="fa-regular fa-calendar"></i> {post?.publishTime}
</Link>
</>
)}
<div className="pl-1 mr-2">
<i className="fa-regular fa-calendar-check"></i> {post.lastEditedTime}
</div>
</div>
{JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) && <div className="busuanzi_container_page_pv font-light mr-2">

View File

@@ -3,6 +3,7 @@ import Link from 'next/link'
import TagItemMini from './TagItemMini'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import BLOG from '@/blog.config'
import { formatDateFmt } from '@/lib/formatDate'
/**
* 博客列表的文字内容
@@ -70,7 +71,7 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary
<div className="text-gray-400 justify-between flex">
{/* 日期 */}
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className="font-light menu-link cursor-pointer text-sm leading-4 mr-3">

View File

@@ -4,6 +4,7 @@ import { useGlobal } from '@/lib/global'
import BLOG from '@/blog.config'
import NotionIcon from '@/components/NotionIcon'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
export default function PostHeader({ post, siteInfo }) {
const { locale } = useGlobal()
@@ -42,7 +43,7 @@ export default function PostHeader({ post, siteInfo }) {
{post?.type !== 'Page' && (
<>
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className="pl-1 mr-2 cursor-pointer hover:underline">

View File

@@ -2,6 +2,7 @@ import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import TagItemMiddle from './TagItemMiddle'
import WordCount from './WordCount'
import { formatDateFmt } from '@/lib/formatDate'
export const ArticleInfo = (props) => {
const { post } = props
@@ -23,7 +24,7 @@ export const ArticleInfo = (props) => {
<div className='flex flex-wrap gap-3 mt-5 text-sm'>
{post?.type !== 'Page' && (<>
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className="cursor-pointer whitespace-nowrap">

View File

@@ -5,6 +5,7 @@ import TagItemMini from './TagItemMini'
import CONFIG from '../config'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
// import Image from 'next/image'
const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
@@ -56,7 +57,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
<div className='text-gray-800 justify-between flex my-2 dark:text-gray-300'>
<div>
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className="font-light hover:underline cursor-pointer text-sm leading-4 mr-3">

View File

@@ -13,6 +13,7 @@ import NotionPage from '@/components/NotionPage'
import CONFIG from '../config'
import NotionIcon from '@/components/NotionIcon'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
/**
*
@@ -54,7 +55,7 @@ export default function ArticleDetail(props) {
<div className='flex flex-wrap justify-center'>
{post?.type !== 'Page' && (<>
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
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">

View File

@@ -9,6 +9,7 @@ import CONFIG from '../config'
import NotionPage from '@/components/NotionPage'
import NotionIcon from '@/components/NotionIcon'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { formatDateFmt } from '@/lib/formatDate'
const BlogPostCard = ({ post, showSummary }) => {
const { locale } = useGlobal()
@@ -57,7 +58,7 @@ const BlogPostCard = ({ post, showSummary }) => {
</>
)}
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
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}

View File

@@ -2,6 +2,7 @@ import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG from '../config'
import BLOG from '@/blog.config'
import { formatDateFmt } from '@/lib/formatDate'
export const ArticleInfo = (props) => {
const { post } = props
@@ -28,7 +29,7 @@ export const ArticleInfo = (props) => {
{post?.type !== 'Page' && (<>
<span>{locale.COMMON.POST_TIME}:
<Link
href={`/archive#${post?.publishTime?.substr(0, 7)}`}
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}

View File

@@ -2,6 +2,7 @@ import BLOG from '@/blog.config'
import Link from 'next/link'
import CONFIG from '../config'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { formatDateFmt } from '@/lib/formatDate'
export const BlogItem = props => {
const { post } = props
@@ -23,7 +24,7 @@ export const BlogItem = props => {
<div className='space-x-2'>
<span> <a href={CONFIG.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>
<Link className='p-1 hover:text-red-400 transition-all duration-200' href={`/archive#${post?.publishTime?.substr(0, 7)}`}>
<Link className='p-1 hover:text-red-400 transition-all duration-200' href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}>
<i className="fa-regular fa-clock" /> {post.date?.start_date || post.createdTime}
</Link>
</span>