fix: Biome 格式化 + archive.astro 传入缺失的 tags/categories props

小橘 🍊(NEKO Team)
This commit is contained in:
小橘 2026-04-15 05:51:21 +00:00
parent 3e5d8b5b58
commit 4ddbe8ac18
4 changed files with 238 additions and 230 deletions

View File

@ -29,7 +29,8 @@ interface Props {
ogImage?: string; ogImage?: string;
} }
let { title, banner, description, lang, setOGTypeArticle, ogImage } = Astro.props; let { title, banner, description, lang, setOGTypeArticle, ogImage } =
Astro.props;
// apply a class to the body element to decide the height of the banner, only used for initial page load // apply a class to the body element to decide the height of the banner, only used for initial page load
// Swup can update the body for each page visit, but it's after the page transition, causing a delay for banner height change // Swup can update the body for each page visit, but it's after the page transition, causing a delay for banner height change

View File

@ -3,12 +3,18 @@ import ArchivePanel from "@components/ArchivePanel.svelte";
import I18nKey from "@i18n/i18nKey"; import I18nKey from "@i18n/i18nKey";
import { i18n } from "@i18n/translation"; import { i18n } from "@i18n/translation";
import MainGridLayout from "@layouts/MainGridLayout.astro"; import MainGridLayout from "@layouts/MainGridLayout.astro";
import { getSortedPostsList } from "../utils/content-utils"; import {
getCategoryList,
getSortedPostsList,
getTagList,
} from "../utils/content-utils";
const sortedPostsList = await getSortedPostsList(); const sortedPostsList = await getSortedPostsList();
const tags = (await getTagList()).map((t) => t.name);
const categories = (await getCategoryList()).map((c) => c.name);
--- ---
<MainGridLayout title={i18n(I18nKey.archive)}> <MainGridLayout title={i18n(I18nKey.archive)}>
<ArchivePanel sortedPosts={sortedPostsList} client:only="svelte"></ArchivePanel> <ArchivePanel sortedPosts={sortedPostsList} tags={tags} categories={categories} client:only="svelte"></ArchivePanel>
</MainGridLayout> </MainGridLayout>

View File

@ -1,9 +1,9 @@
import type { APIRoute, GetStaticPaths } from "astro";
import { getSortedPosts } from "@utils/content-utils";
import satori from "satori";
import sharp from "sharp";
import fs from "node:fs"; import fs from "node:fs";
import path from "node:path"; import path from "node:path";
import { getSortedPosts } from "@utils/content-utils";
import type { APIRoute, GetStaticPaths } from "astro";
import satori from "satori";
import sharp from "sharp";
import { formatDateToYYYYMMDD } from "../../utils/date-utils"; import { formatDateToYYYYMMDD } from "../../utils/date-utils";
// Load font at module level (cached across calls during build) // Load font at module level (cached across calls during build)
@ -38,10 +38,9 @@ export const GET: APIRoute = async ({ props }) => {
}; };
// Truncate title to ~40 chars for display // Truncate title to ~40 chars for display
const displayTitle = const displayTitle = title.length > 42 ? `${title.slice(0, 40)}` : title;
title.length > 42 ? title.slice(0, 40) + "…" : title;
const displayDesc = const displayDesc =
description.length > 70 ? description.slice(0, 68) + "…" : description; description.length > 70 ? `${description.slice(0, 68)}` : description;
const displayTags = tags.slice(0, 3).join(" · "); const displayTags = tags.slice(0, 3).join(" · ");
const svg = await satori( const svg = await satori(
@ -55,7 +54,8 @@ export const GET: APIRoute = async ({ props }) => {
flexDirection: "column", flexDirection: "column",
justifyContent: "space-between", justifyContent: "space-between",
padding: "60px 64px", padding: "60px 64px",
background: "linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #3b82f6 100%)", background:
"linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #3b82f6 100%)",
color: "#ffffff", color: "#ffffff",
fontFamily: "Noto Sans SC", fontFamily: "Noto Sans SC",
}, },
@ -216,7 +216,8 @@ export const GET: APIRoute = async ({ props }) => {
{ {
width: 1200, width: 1200,
height: 630, height: 630,
fonts: fontData.byteLength > 0 fonts:
fontData.byteLength > 0
? [ ? [
{ {
name: "Noto Sans SC", name: "Noto Sans SC",
@ -232,7 +233,7 @@ export const GET: APIRoute = async ({ props }) => {
}, },
] ]
: [], : [],
} },
); );
const png = await sharp(Buffer.from(svg)).png().toBuffer(); const png = await sharp(Buffer.from(svg)).png().toBuffer();

View File

@ -1,7 +1,7 @@
--- ---
import path from "node:path"; import path from "node:path";
import License from "@components/misc/License.astro";
import Comments from "@components/misc/Comments.astro"; import Comments from "@components/misc/Comments.astro";
import License from "@components/misc/License.astro";
import Markdown from "@components/misc/Markdown.astro"; import Markdown from "@components/misc/Markdown.astro";
import I18nKey from "@i18n/i18nKey"; import I18nKey from "@i18n/i18nKey";
import { i18n } from "@i18n/translation"; import { i18n } from "@i18n/translation";