From fdd9f670e636dce9311fe8faa6ae26d055935cf4 Mon Sep 17 00:00:00 2001 From: grassblock Date: Sun, 10 Aug 2025 19:05:46 +0800 Subject: [PATCH] feat: display cover on article page --- src/pages/blog/[...slug].astro | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 33b9d6e..3b1ecf9 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -3,7 +3,7 @@ import Layout from '../../layouts/Layout.astro'; import { getCollection, getEntry } from 'astro:content'; import Comments from "../../components/Comments.astro"; -import {getImage} from "astro:assets"; +import {getImage, Image} from "astro:assets"; import {siteConfig} from "../../config"; import ReplyViaEmail from "../../components/ReplyViaEmail.astro"; import { ExtractFirstImage } from '../../plugins/extract-images'; @@ -60,8 +60,9 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || ` (Updated on {new Date(lastUpdated).toISOString().split('T')[0]}) | {wordcount.words} words - {headings.length !== 0 && } - {entry.data.summary &&

{entry.data.summary}

} + { (cover && cover !== firstImageURL && cover !== `/blog/${slug}/featured.png`) && {`cover } + {headings.length !== 0 && } + {entry.data.summary &&

{entry.data.summary}

}
@@ -84,4 +85,9 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || ` color: var(--secondary-text-color); margin: 1rem; } + img.cover { + width: 100%; + height: auto; + margin: 1rem auto; + }