From 66717405db1907908fdaf8d60d698983971acbbb Mon Sep 17 00:00:00 2001 From: xy <10816187@qq.com> Date: Fri, 10 Jul 2026 20:07:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=98=BE=E7=A4=BA=E5=8D=9A=E5=AE=A2?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/posts/[...slug].astro | 76 ++++++++++++++++++++++----------- src/types/post.ts | 2 + 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro index 4794705..8e2260c 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/posts/[...slug].astro @@ -6,18 +6,10 @@ import Layout from "@/layouts/Layout.astro"; import {http} from "@/lib/request.ts"; import {highlightHtmlWithJsdom} from "@/lib/highlight.js"; import {formatDatetime} from "@/lib/format.ts"; +import type {Post} from "@/types"; const {slug} = Astro.params; -interface Post { - title: string; - summary: string; - slug: string; - cover: string; - published_at: string; - content: string; -} - let data: Post; try { @@ -33,22 +25,34 @@ const published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日')

{data.title}

-
- - - - - - - - - - - - - {published_at} +
@@ -60,6 +64,12 @@ const published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日') font-size: 24px; } + .post-meta { + display: flex; + align-items: center; + justify-content: space-between; + } + .published-at { display: flex; align-items: center; @@ -82,6 +92,22 @@ const published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日') box-shadow: rgba(149, 157, 165, 0.2) 0 2px 14px -4px; } + .post-view { + display: flex; + align-items: center; + gap: 4px; + color: #6b7280; + padding-right: 12px; + font-size: 14px; + } + + .post-view svg { + width: 20px; + height: 20px; + fill: currentColor; /* 让填充跟随 color */ + stroke: currentColor; /* 让描边也跟随 color */ + } + @media (max-width: 768px) { .post-title { font-size: 20px; diff --git a/src/types/post.ts b/src/types/post.ts index 86ac85d..51b2548 100644 --- a/src/types/post.ts +++ b/src/types/post.ts @@ -5,4 +5,6 @@ export type Post = { cover: string; category_name: string; published_at: string; + view: number; + content: string; }