From 6fb900808401dbedb1c1d5cb20d0a7e97e2db361 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 14 Jul 2023 17:15:45 +0100 Subject: [PATCH] feat: display reading time on post card --- src/components/home/HomeFeed.tsx | 55 +++++++++++++++++------------ src/lib/expand-unit.ts | 8 +++++ src/lib/i18n/locales/zh/common.json | 4 ++- src/lib/types.ts | 1 + src/markdown/index.ts | 8 +---- src/queries/page.server.ts | 5 +-- 6 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/components/home/HomeFeed.tsx b/src/components/home/HomeFeed.tsx index b50c4c67..23d1f647 100644 --- a/src/components/home/HomeFeed.tsx +++ b/src/components/home/HomeFeed.tsx @@ -102,30 +102,39 @@ const PostCard = ({ )} - {(!!post.metadata?.content?.tags?.[1] || - post.stat?.viewDetailCount) && ( -
- {!!post.metadata?.content?.tags?.[1] && ( - - { - e.preventDefault() - router.push(`/tag/${post.metadata?.content?.tags?.[1]}`) - }} - > - #{post.metadata?.content?.tags?.[1]} - +
+ {!!post.metadata?.content?.tags?.[1] && ( + { + e.preventDefault() + router.push(`/tag/${post.metadata?.content?.tags?.[1]}`) + }} + > + + {post.metadata?.content?.tags?.[1]} + + )} + {!post.stat?.viewDetailCount && ( + + + + {post.metadata?.content?.readingTime}{" "} + {t(post.metadata?.content?.readingTime === 1 ? "min" : "mins")} - )} - {!!post.stat?.viewDetailCount && ( - - - {post.stat?.viewDetailCount} - - )} -
- )} +
+ )} + {!!post.stat?.viewDetailCount && ( + + + {post.stat?.viewDetailCount} + + )} +
- cover: string - audio: string - toc: TocResult | null - tree: Root | null -} +} & Omit refractor.alias("html", ["svelte", "vue"]) refractor.register(tsx) diff --git a/src/queries/page.server.ts b/src/queries/page.server.ts index 2100a50a..b0958619 100644 --- a/src/queries/page.server.ts +++ b/src/queries/page.server.ts @@ -118,10 +118,7 @@ const getOriginalSummary = async (cid: string, lang: string) => { } const res = await chain.call({ - input_document: removeMarkdown(content, { - useImgAltText: true, - gfm: true, - }), + input_document: removeMarkdown(content), }) console.timeEnd(`fetching summary ${cid}, ${lang}`)