From 39b15b4be9bad65dafeb67a412009c4be4c9a310 Mon Sep 17 00:00:00 2001 From: biss Date: Thu, 18 Jun 2026 14:40:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E9=A1=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astro.config.mjs | 5 + src/components/Pagination.astro | 53 +++ src/components/PostCopyrightCard.astro | 118 ++++++ src/layouts/BaseLayout.astro | 79 +++- src/lib/pagination.ts | 25 ++ src/lib/remarkHexoLinkCards.mjs | 124 ++++++ src/pages/archives/index.astro | 6 +- src/pages/archives/page/[page].astro | 35 ++ src/pages/index.astro | 6 +- src/pages/page/[page].astro | 46 +++ src/pages/posts/[slug].astro | 2 + src/styles/site.css | 525 ++++++++++++++++++++++++- 12 files changed, 1015 insertions(+), 9 deletions(-) create mode 100644 src/components/Pagination.astro create mode 100644 src/components/PostCopyrightCard.astro create mode 100644 src/lib/pagination.ts create mode 100644 src/lib/remarkHexoLinkCards.mjs create mode 100644 src/pages/archives/page/[page].astro create mode 100644 src/pages/page/[page].astro diff --git a/astro.config.mjs b/astro.config.mjs index 7924a21..bdc3539 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,5 +1,7 @@ import { defineConfig } from 'astro/config'; import sitemap from '@astrojs/sitemap'; +import { unified } from '@astrojs/markdown-remark'; +import remarkHexoLinkCards from './src/lib/remarkHexoLinkCards.mjs'; export default defineConfig({ site: 'https://blog.biss.click', @@ -8,6 +10,9 @@ export default defineConfig({ publicDir: './static', integrations: [sitemap()], markdown: { + processor: unified({ + remarkPlugins: [remarkHexoLinkCards], + }), shikiConfig: { theme: 'github-dark', wrap: true, diff --git a/src/components/Pagination.astro b/src/components/Pagination.astro new file mode 100644 index 0000000..f95e24b --- /dev/null +++ b/src/components/Pagination.astro @@ -0,0 +1,53 @@ +--- +type Props = { + currentPage: number; + totalPages: number; + basePath?: string; +}; + +const { currentPage, totalPages, basePath = '/' } = Astro.props; + +const normalizedBasePath = basePath.endsWith('/') ? basePath : `${basePath}/`; +const getPageHref = (page: number) => (page <= 1 ? normalizedBasePath : `${normalizedBasePath}page/${page}/`); +const pages = Array.from({ length: totalPages }, (_, index) => index + 1); +--- + +{ + totalPages > 1 && ( + + ) +} diff --git a/src/components/PostCopyrightCard.astro b/src/components/PostCopyrightCard.astro new file mode 100644 index 0000000..04b8600 --- /dev/null +++ b/src/components/PostCopyrightCard.astro @@ -0,0 +1,118 @@ +--- +import type { BlogPost } from '@/lib/posts'; + +interface Props { + post: BlogPost; +} + +const { post } = Astro.props; +const author = 'biss'; +const licenseName = 'CC BY-NC-SA 4.0'; +const licenseHref = 'https://creativecommons.org/licenses/by-nc-sa/4.0/'; +const postUrl = new URL(post.href, Astro.site ?? Astro.url.origin).toString(); +const displayPath = post.href; +const tags = post.tags; +--- + +
+ + +
+

{post.title}

+ {displayPath} + +
+
+
作者
+
{author}
+
+
+
发布于
+
+
+
+
许可协议
+
{licenseName}
+
+
+
+ +
+ {tags.length > 0 && ( +
+ {tags.map((tag) => {tag})} +
+ )} + +
+ + + + 订阅 + + + + 打赏 + + + + + + + +
+
+
+ + diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 00b9a9f..24d7e96 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -9,6 +9,7 @@ interface Props { const siteTitle = "Bi's Blog"; const { title = siteTitle, description = 'Personal blog by biss.' } = Astro.props; const pageTitle = title === siteTitle ? siteTitle : `${title} | ${siteTitle}`; +const currentYear = new Date().getFullYear(); --- @@ -36,9 +37,81 @@ const pageTitle = title === siteTitle ? siteTitle : `${title} | ${siteTitle}`;
-