From 8437a6d263ac6b7636589547fa08196436815b84 Mon Sep 17 00:00:00 2001 From: log101 Date: Wed, 7 Aug 2024 14:27:39 +0300 Subject: [PATCH] fix: summary is not rendered correctly --- src/components/Post.astro | 8 +++++--- src/content/blog/acilis.md | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Post.astro b/src/components/Post.astro index 147f1ec..35d3d51 100644 --- a/src/components/Post.astro +++ b/src/components/Post.astro @@ -52,6 +52,10 @@ const postLink = `/${post.data.category}/${post.slug}`; // Create post content as an astro component const { Content } = await post.render(); +const copyPost = post; +copyPost.body = copyPost.body.slice(0, 500); +const { Content: Summary } = await copyPost.render(); + import { Image } from "astro:assets"; import questionMark from "@/images/questionMark.svg"; import calendar from "@/images/calendar.svg"; @@ -101,9 +105,7 @@ import calendar from "@/images/calendar.svg"; { options.longSummary && ( <> -

- {post.body.slice(0, 500).replace(/(<([^>]+)>)/gi, "")} -

+ {post.body.length > 500 && (