diff --git a/src/components/ArticleCard.vue b/src/components/ArticleCard.vue index b6a1990..46af432 100644 --- a/src/components/ArticleCard.vue +++ b/src/components/ArticleCard.vue @@ -1,16 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/src/utils/readingTime.ts b/src/utils/readingTime.ts new file mode 100644 index 0000000..35390e0 --- /dev/null +++ b/src/utils/readingTime.ts @@ -0,0 +1,12 @@ +export function estimateReadingTime(content: string = ''): string { + const noWhitespace = content.replace(/\s/g, '').length + const minutes = Math.ceil(noWhitespace / 400) + return `${minutes} 分钟` +} + +export function formatDay(iso: string): string { + const d = new Date(iso) + if (isNaN(d.getTime())) return iso + const pad = (n: number) => String(n).padStart(2, '0') + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}` +} \ No newline at end of file diff --git a/src/views/ArticleDetailView.vue b/src/views/ArticleDetailView.vue index 5c0a1f5..9c2b51d 100644 --- a/src/views/ArticleDetailView.vue +++ b/src/views/ArticleDetailView.vue @@ -6,6 +6,7 @@ import { renderMarkdown } from '@/utils/markdown' import { setPageMeta } from '@/utils/seo' import { useApi } from '@/composables/useApi' import CommentSection from '@/components/CommentSection.vue' +import ArticleMetaBar from '@/components/ArticleMetaBar.vue' import type { ArticleDetail, ResponseArticleDetail } from '@/generated/api' const route = useRoute() @@ -22,13 +23,6 @@ const renderedContent = computed(() => { return renderMarkdown(article.value.content) }) -function formatDate(iso?: string): string { - if (!iso) return '' - const d = new Date(iso) - if (isNaN(d.getTime())) return iso - return d.toLocaleString('zh-CN', { hour12: false }) -} - function applyMeta(data: ArticleDetail) { setPageMeta({ title: data.title, @@ -59,8 +53,12 @@ watch(slug, load, { immediate: true })
{{ article.summary }}