diff --git a/lib/formatDate.js b/lib/formatDate.js index 5eb586bf..29190e3b 100644 --- a/lib/formatDate.js +++ b/lib/formatDate.js @@ -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 diff --git a/themes/example/components/ArticleInfo.js b/themes/example/components/ArticleInfo.js index 709dcff1..cd29e978 100644 --- a/themes/example/components/ArticleInfo.js +++ b/themes/example/components/ArticleInfo.js @@ -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' && (<> diff --git a/themes/fukasawa/components/ArticleDetail.js b/themes/fukasawa/components/ArticleDetail.js index a1297dd2..2e2cce59 100644 --- a/themes/fukasawa/components/ArticleDetail.js +++ b/themes/fukasawa/components/ArticleDetail.js @@ -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' && (<> diff --git a/themes/heo/components/PostHeader.js b/themes/heo/components/PostHeader.js index dd1330f8..5a707477 100644 --- a/themes/heo/components/PostHeader.js +++ b/themes/heo/components/PostHeader.js @@ -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' && ( <> - {post?.publishTime} + {post?.publishTime} )} +
+ {post.lastEditedTime} +
+ {JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) &&
diff --git a/themes/hexo/components/BlogPostCardInfo.js b/themes/hexo/components/BlogPostCardInfo.js index ffdf0777..135064a7 100644 --- a/themes/hexo/components/BlogPostCardInfo.js +++ b/themes/hexo/components/BlogPostCardInfo.js @@ -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
{/* 日期 */} diff --git a/themes/hexo/components/PostHeader.js b/themes/hexo/components/PostHeader.js index e6f09c22..21eec51a 100644 --- a/themes/hexo/components/PostHeader.js +++ b/themes/hexo/components/PostHeader.js @@ -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' && ( <> diff --git a/themes/matery/components/ArticleInfo.js b/themes/matery/components/ArticleInfo.js index bb816059..293eb3e7 100644 --- a/themes/matery/components/ArticleInfo.js +++ b/themes/matery/components/ArticleInfo.js @@ -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) => {
{post?.type !== 'Page' && (<> diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js index 2a6de771..eb8ff2f5 100644 --- a/themes/matery/components/BlogPostCard.js +++ b/themes/matery/components/BlogPostCard.js @@ -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 }) => {
diff --git a/themes/next/components/ArticleDetail.js b/themes/next/components/ArticleDetail.js index 38794f01..a2d6fc48 100644 --- a/themes/next/components/ArticleDetail.js +++ b/themes/next/components/ArticleDetail.js @@ -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) {
{post?.type !== 'Page' && (<>
diff --git a/themes/next/components/BlogPostCard.js b/themes/next/components/BlogPostCard.js index 96a7668e..050b33c2 100644 --- a/themes/next/components/BlogPostCard.js +++ b/themes/next/components/BlogPostCard.js @@ -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 }) => { )} {post.date?.start_date} diff --git a/themes/simple/components/ArticleInfo.js b/themes/simple/components/ArticleInfo.js index daee32a1..6f17b0df 100644 --- a/themes/simple/components/ArticleInfo.js +++ b/themes/simple/components/ArticleInfo.js @@ -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' && (<> {locale.COMMON.POST_TIME}: {post?.publishTime} diff --git a/themes/simple/components/BlogItem.js b/themes/simple/components/BlogItem.js index a60bd89e..49f5cd12 100644 --- a/themes/simple/components/BlogItem.js +++ b/themes/simple/components/BlogItem.js @@ -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 => {
{BLOG.AUTHOR} - + {post.date?.start_date || post.createdTime}