From d62ac361c06813fa5e6e4d6a14d4f775feba4290 Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Thu, 17 Sep 2026 15:05:12 +0800 Subject: [PATCH] update overall layout --- src/components/Posts/PostItem.astro | 150 +++++++++------------------ src/components/Posts/PostList.astro | 6 +- src/components/TagLink.astro | 48 +++++++++ src/layouts/MarkdownPostLayout.astro | 40 +------ src/pages/[lang]/index.astro | 17 ++- src/pages/[lang]/tags/index.astro | 43 +------- 6 files changed, 123 insertions(+), 181 deletions(-) create mode 100644 src/components/TagLink.astro diff --git a/src/components/Posts/PostItem.astro b/src/components/Posts/PostItem.astro index f81c360..ddda3ae 100644 --- a/src/components/Posts/PostItem.astro +++ b/src/components/Posts/PostItem.astro @@ -1,6 +1,7 @@ --- import "@/styles/global.css"; import Remark42Counter from "@/components/Remark42Counter.astro"; +import TagLink from "@/components/TagLink.astro"; import { getLangFromUrl } from "@/i18n"; const lang = getLangFromUrl(Astro.url); @@ -22,9 +23,7 @@ const tags = data.tags;
{ tags.map((tag: string) => ( -

- {tag} -

+ )) }
@@ -51,81 +50,31 @@ const tags = data.tags; -
- diff --git a/src/components/Posts/PostList.astro b/src/components/Posts/PostList.astro index 43cd00f..85bdada 100644 --- a/src/components/Posts/PostList.astro +++ b/src/components/Posts/PostList.astro @@ -59,15 +59,15 @@ const latestPosts = filteredPosts.slice(0, 7); } .more-link-wrap { - margin-top: 1rem; + margin-top: 2rem; text-align: right; } .more-link { color: #6f8090; - font-weight: 700; + font-weight: 400; text-decoration: none; - font-size: 1.14rem; + font-size: 0.9rem; } .more-link:hover { diff --git a/src/components/TagLink.astro b/src/components/TagLink.astro new file mode 100644 index 0000000..767ad33 --- /dev/null +++ b/src/components/TagLink.astro @@ -0,0 +1,48 @@ +--- +interface Props { + tag: string; + lang: string; +} + +const { tag, lang } = Astro.props; +--- + +#{tag} + + diff --git a/src/layouts/MarkdownPostLayout.astro b/src/layouts/MarkdownPostLayout.astro index 731c07f..4ad5071 100644 --- a/src/layouts/MarkdownPostLayout.astro +++ b/src/layouts/MarkdownPostLayout.astro @@ -2,6 +2,7 @@ import BaseLayout from "./BaseLayout.astro"; import Remark42Embed from "@/components/Remark42Embed.astro"; import PostNav from "@/components/Posts/PostNav.astro"; +import TagLink from "@/components/TagLink.astro"; import PostMenu from "@/components/Posts/PostMenu.astro"; import Dialog from "@/components/Posts/Dialog.astro"; import { fade } from "astro:transitions"; @@ -61,9 +62,7 @@ const t = getTranslations(lang);
{ frontmatter.tags.map((tag: string) => ( -

- {tag} -

+ )) }
@@ -317,8 +316,6 @@ const t = getTranslations(lang); aspect-ratio: 16 / 10; object-fit: cover; object-position: center; - /* border-radius: 0.4rem; */ - border: 1.5px #94a0ab dashed; display: block; } @@ -334,42 +331,13 @@ const t = getTranslations(lang); .tags { display: flex; flex-wrap: wrap; - gap: 0.4rem; + gap: 0.25rem 0.9rem; margin-top: 0.8rem; min-width: 0; - } - - .tag { - margin: 0; - padding: 0.22em 0.65em; font-size: 0.88rem; - line-height: 1.2; - border: 1px dashed #8b6b4a; - border-radius: 0; - background-color: transparent; - max-width: 100%; } - .tag a { - color: #6f4e37; - text-decoration: none; - overflow-wrap: anywhere; - word-break: break-word; - } - - .tag a:hover { - text-decoration: underline; - } - - :global(.dark) .tag { - border-color: #d8c7a1; - } - - :global(.dark) .tag a { - color: #e6d8b8; - } - - @media (max-width: 560px) { + @media (max-width: 800px) { .post-header { grid-template-columns: 1fr; } diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index 05532c0..c8db2bb 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -49,7 +49,7 @@ const rssLink = lang === "zh" ? "/rss.xml" : "/en/rss.xml";
-

{t.home.latestTitle}

+

{t.home.latestTitle}

@@ -80,4 +80,19 @@ const rssLink = lang === "zh" ? "/rss.xml" : "/en/rss.xml"; .page-title { font-weight: 700; } + + .section-title, + .index :global(.latest-comments > h2) { + margin: 0 0 1.25rem; + font-family: "Noto Sans SC", system-ui, sans-serif; + font-size: 0.95rem; + font-weight: 500; + line-height: 1.5; + color: #66717c; + } + + :global(html.dark) .section-title, + :global(html.dark) .index :global(.latest-comments > h2) { + color: #aab7c4; + } diff --git a/src/pages/[lang]/tags/index.astro b/src/pages/[lang]/tags/index.astro index 5e01213..42e2b7e 100644 --- a/src/pages/[lang]/tags/index.astro +++ b/src/pages/[lang]/tags/index.astro @@ -1,5 +1,6 @@ --- import BaseLayout from "@/layouts/BaseLayout.astro"; +import TagLink from "@/components/TagLink.astro"; import { getCollection } from "astro:content"; import { getTranslations, type Lang } from "@/i18n"; import "@/styles/global.css"; @@ -24,7 +25,7 @@ const pageTitle = lang === "zh" ? "标签索引" : "Tag Index"; { tags.map((tag) => (

- {tag} +

)) } @@ -40,49 +41,13 @@ const pageTitle = lang === "zh" ? "标签索引" : "Tag Index"; .tags { display: flex; flex-wrap: wrap; - gap: 0.4rem; + gap: 0.4rem 1.25rem; margin-top: 0.8rem; } .tag { - font-family: - "Noto Sans SC", - system-ui, - -apple-system, - BlinkMacSystemFont, - "Segoe UI", - Roboto, - Oxygen, - Ubuntu, - Cantarell, - "Open Sans", - "Helvetica Neue", - sans-serif; - margin: 0; - padding: 0.22em 0.65em; font-size: 1rem; - line-height: 1.2; - border: 1px dashed #8b6b4a; - border-radius: 0; - background-color: transparent; - } - - .tag a { - color: #6f4e37; - text-decoration: none; - font-weight: 500; - } - - .tag a:hover { - text-decoration: underline; - } - - :global(.dark) .tag { - border-color: #d8c7a1; - } - - :global(.dark) .tag a { - color: #e6d8b8; + max-width: 100%; }