mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
fix date
This commit is contained in:
@@ -9,10 +9,12 @@ 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)
|
||||
return local.slice(0, 2).toLowerCase() === 'zh'
|
||||
const format = local.slice(0, 2).toLowerCase() === 'zh'
|
||||
? res.replace('年', '-').replace('月', '-').replace('日', '')
|
||||
: res
|
||||
return format
|
||||
}
|
||||
|
||||
export function formatDateFmt (timestamp, fmt) {
|
||||
const date = new Date(timestamp)
|
||||
const o = {
|
||||
|
||||
@@ -2,7 +2,6 @@ import TagItemMini from './TagItemMini'
|
||||
import Comment from '@/components/Comment'
|
||||
import NotionPage from '@/components/NotionPage'
|
||||
import ShareBar from '@/components/ShareBar'
|
||||
import formatDate from '@/lib/formatDate'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import Link from 'next/link'
|
||||
import ArticleAround from './ArticleAround'
|
||||
@@ -19,7 +18,6 @@ export default function ArticleDetail(props) {
|
||||
if (!post) {
|
||||
return <></>
|
||||
}
|
||||
const date = formatDate(post?.publishTime, locale.LOCALE)
|
||||
return (
|
||||
<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 && (
|
||||
@@ -59,7 +57,7 @@ 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">
|
||||
|
||||
{date}
|
||||
{post?.publishTime}
|
||||
|
||||
</Link>
|
||||
<span className='mr-2'>|</span>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Link from 'next/link'
|
||||
import TagItemMini from './TagItemMini'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import formatDate from '@/lib/formatDate'
|
||||
import BLOG from '@/blog.config'
|
||||
import NotionIcon from '@/components/NotionIcon'
|
||||
|
||||
@@ -13,11 +12,6 @@ export default function HeaderArticle({ post, siteInfo }) {
|
||||
}
|
||||
const headerImage = post?.pageCover ? `url("${post.pageCover}")` : `url("${siteInfo?.pageCover}")`
|
||||
|
||||
const date = formatDate(
|
||||
post?.publishTime,
|
||||
locale.LOCALE
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
id="header"
|
||||
@@ -53,7 +47,7 @@ export default function HeaderArticle({ post, siteInfo }) {
|
||||
passHref
|
||||
className="pl-1 mr-2 cursor-pointer hover:underline">
|
||||
|
||||
{locale.COMMON.POST_TIME}:{date}
|
||||
{locale.COMMON.POST_TIME}:{post?.publishTime}
|
||||
|
||||
</Link>
|
||||
</>
|
||||
|
||||
@@ -199,15 +199,6 @@ const LayoutSlug = props => {
|
||||
const { post, lock, validPassword } = props
|
||||
const drawerRight = useRef(null)
|
||||
|
||||
if (!post) {
|
||||
return <LayoutBase
|
||||
{...props}
|
||||
showTag={false}
|
||||
showCategory={false}
|
||||
headerSlot={<HeaderArticle {...props} />}
|
||||
></LayoutBase>
|
||||
}
|
||||
|
||||
const targetRef = isBrowser() ? document.getElementById('article-wrapper') : null
|
||||
|
||||
const floatSlot = <>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import Link from 'next/link'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import formatDate from '@/lib/formatDate'
|
||||
import TagItemMiddle from './TagItemMiddle'
|
||||
import WordCount from './WordCount'
|
||||
|
||||
@@ -8,7 +7,6 @@ export const ArticleInfo = (props) => {
|
||||
const { post } = props
|
||||
|
||||
const { locale } = useGlobal()
|
||||
const date = formatDate(post?.publishTime, locale.LOCALE)
|
||||
|
||||
return (
|
||||
<section className='mb-3 dark:text-gray-200'>
|
||||
@@ -29,7 +27,7 @@ export const ArticleInfo = (props) => {
|
||||
passHref
|
||||
className="cursor-pointer whitespace-nowrap">
|
||||
|
||||
<i className='far fa-calendar-minus fa-fw'/> {locale.COMMON.POST_TIME}:{date}
|
||||
<i className='far fa-calendar-minus fa-fw'/> {locale.COMMON.POST_TIME}:{post?.publishTime}
|
||||
|
||||
</Link>
|
||||
<span className='whitespace-nowrap'>
|
||||
|
||||
@@ -33,10 +33,7 @@ export const ArticleInfo = (props) => {
|
||||
<span className="block"> / </span>
|
||||
</div>
|
||||
<div className="mr-2 mb-4 md:ml-0">
|
||||
{formatDate(
|
||||
post?.publishTime || post?.createdTime,
|
||||
BLOG.LANG
|
||||
)}
|
||||
{post?.publishTime}
|
||||
</div>
|
||||
{post.tags && (
|
||||
<div className="flex flex-nowrap max-w-full overflow-x-auto article-tags">
|
||||
|
||||
Reference in New Issue
Block a user