mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
feat: add date formatting component and configuration options
- Add DateFormat and PostTime components, supporting multiple date display formats - Add dateFormat option in theme configuration, allowing customization of date display styles - Refactor time display logic in article list and article detail pages - Update configuration type definitions to support new date format options
This commit is contained in:
parent
4b21e6ee39
commit
8ac9b865f5
7 changed files with 184 additions and 30 deletions
|
@ -25,7 +25,7 @@ const { Content, remarkPluginFrontmatter } = await post.render()
|
|||
<h1>{post.data.title}</h1>
|
||||
<time>
|
||||
{post.data.published.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' }).replace('/', '-')}
|
||||
{remarkPluginFrontmatter.minutes && <span> · {remarkPluginFrontmatter.minutes} min</span>}
|
||||
{remarkPluginFrontmatter.minutes && <span> {remarkPluginFrontmatter.minutes} min</span>}
|
||||
</time>
|
||||
<Content />
|
||||
</article>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
import Comments from '@/components/Comments/index.astro'
|
||||
import PostTime from '@/components/PostTime.astro'
|
||||
import Layout from '@/layouts/Layout.astro'
|
||||
import { checkSlugDuplication } from '@/utils/content'
|
||||
import { generatePostPaths } from '@/utils/i18n/route'
|
||||
|
@ -40,17 +41,12 @@ const { Content, remarkPluginFrontmatter } = await post.render()
|
|||
transition:name={`time-${post.data.abbrlink || post.slug}`}
|
||||
data-disable-transition-on-theme
|
||||
>
|
||||
<time>
|
||||
{post.data.published.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')}
|
||||
</time>
|
||||
<span class="ml-1.5">
|
||||
{remarkPluginFrontmatter.minutes} min
|
||||
</span>
|
||||
{post.data.updated && (
|
||||
<span class="ml-1.5">
|
||||
updated {post.data.updated.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')}
|
||||
</span>
|
||||
)}
|
||||
<!-- published and updated time -->
|
||||
<PostTime
|
||||
date={post.data.published}
|
||||
updatedDate={post.data.updated}
|
||||
minutes={remarkPluginFrontmatter.minutes}
|
||||
/>
|
||||
</div>
|
||||
<Content />
|
||||
</article>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue