--- import { Icon } from "astro-icon/components"; import { type NavbarLink } from "@/types/config"; import { navbarConfig } from "@/config"; import { LinkPresets } from "@constants/link-presets"; import { url } from "@utils/url"; import GridLayout from "@layouts/grid.astro"; import BackwardButton from "@components/backwardButton.astro"; export async function getStaticPaths() { return navbarConfig.links .filter(link => typeof link !== "number" && link.children && link.children.length > 0) .map(link => { const navLink = link as NavbarLink; // 提取 slug,去掉前后的斜杠 const slug = navLink.url.replace(/^\/|\/$/g, ''); return { params: { menu: slug }, props: { link: navLink } }; }); } interface Props { link: NavbarLink; } const { link } = Astro.props; // 获取子链接,并将 LinkPreset 转换为完整的 NavbarLink 对象 const childrenLinks = link.children || []; const processedLinks = childrenLinks.map(child => { if (typeof child === "number") { return LinkPresets[child]; } return child; }); const pageTitle = link.name; const pageDescription = link.description || ""; --- {pageTitle} {pageDescription && ( {pageDescription} )} {processedLinks.map(child => ( {child.icon && } {child.name} {child.description && ( {child.description} )} ))}
{pageDescription}
{child.description}