fix: update reading time display and enhance localization
- Changed the comment for average reading speed in content-collections.ts for clarity. - Added a new translation key for reading time in English and Chinese localization files. - Updated the BlogPostPage to utilize the new translation key for displaying estimated reading time, improving user experience and localization support.
This commit is contained in:
parent
29ed01182e
commit
516cd70bba
@ -162,7 +162,7 @@ export const posts = defineCollection({
|
||||
|
||||
// Calculate estimated reading time
|
||||
const wordCount = data.content.split(/\s+/).length;
|
||||
const wordsPerMinute = 200; // Average reading speed: 200 words per minute
|
||||
const wordsPerMinute = 200; // average reading speed: 200 words per minute
|
||||
const estimatedTime = Math.max(Math.ceil(wordCount / wordsPerMinute), 1);
|
||||
|
||||
return {
|
||||
|
@ -175,6 +175,7 @@
|
||||
"author": "Author",
|
||||
"categories": "Categories",
|
||||
"tableOfContents": "Table of Contents",
|
||||
"readTime": " min read",
|
||||
"all": "All",
|
||||
"noPostsFound": "No posts found",
|
||||
"allPosts": "All Posts"
|
||||
|
@ -171,6 +171,7 @@
|
||||
"author": "作者",
|
||||
"categories": "分类",
|
||||
"tableOfContents": "目录",
|
||||
"readTime": " 分钟阅读",
|
||||
"all": "全部",
|
||||
"noPostsFound": "没有找到文章",
|
||||
"allPosts": "全部文章"
|
||||
|
@ -1,21 +1,21 @@
|
||||
import AllPostsButton from '@/components/blog/all-posts-button';
|
||||
import { BlogToc } from '@/components/blog/blog-toc';
|
||||
import { NewsletterCard } from '@/components/newsletter/newsletter-card';
|
||||
import { LocaleLink } from '@/i18n/navigation';
|
||||
import { getTableOfContents } from '@/lib/blog/toc';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { getLocaleDate } from '@/lib/utils';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import { MDXContent } from '@content-collections/mdx/react';
|
||||
import { allPosts } from 'content-collections';
|
||||
import defaultMdxComponents from 'fumadocs-ui/mdx';
|
||||
import { CalendarIcon, ClockIcon } from 'lucide-react';
|
||||
import type { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import Image from 'next/image';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { Locale } from 'next-intl';
|
||||
import { NewsletterCard } from '@/components/newsletter/newsletter-card';
|
||||
import { MDXContent } from '@content-collections/mdx/react';
|
||||
import defaultMdxComponents from 'fumadocs-ui/mdx';
|
||||
|
||||
import '@/styles/mdx.css';
|
||||
|
||||
@ -137,7 +137,7 @@ export default async function BlogPostPage(props: NextPageProps) {
|
||||
<div className="flex items-center gap-2">
|
||||
<ClockIcon className="size-4 text-muted-foreground" />
|
||||
<span className="text-sm text-muted-foreground leading-none my-auto">
|
||||
{post.estimatedTime ? `${post.estimatedTime} min read` : 'Quick read'}
|
||||
{post.estimatedTime}{t('readTime')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user