跳转到内容
本页面的翻译由 LLM 生成。如果你发现翻译有误,请在 GitHub 上提交 issue 告诉我们。

集成

varsha 预装了生产站点所需的精选 Astro 集成。本指南概述每个集成以及如何添加额外集成。

Starlight

Astro 官方文档框架。提供侧边栏导航、全文搜索、i18n、深浅模式、代码块语法高亮等功能的美观文档站点。

Sitemap

构建时自动生成 sitemap.xml,提升 SEO 和搜索引擎爬取效果。

Vercel

Vercel 部署适配器。支持边缘/Serverless 函数、图片优化和缓存。

Starlight 驱动文档站点(/docs/),在 astro.config.mjs 中配置:

astro.config.mjs
starlight({
title: 'varsha',
customCss: ['./src/styles/global.css', './src/styles/marketing.css'],
sidebar: [
{ label: 'Start here', items: [/* ... */] },
],
locales: {
root: { label: 'English', lang: 'en' },
ja: { label: '日本語', lang: 'ja' },
'zh-cn': { label: '简体中文', lang: 'zh-CN' },
},
social: {
github: 'https://github.com/yethikrishna/web-ui-template',
},
})

@astrojs/sitemap 集成在构建时自动生成站点地图。在 astro.config.mjs 中配置:

sitemap({
filter: (page) => !page.includes('/admin/'),
changefreq: 'weekly',
priority: 0.7,
})

Vercel 适配器为 Vercel 平台优化构建。部署到其他平台时,切换适配器:

终端窗口
npx astro add netlify

RSS

添加博客 RSS 订阅:npx astro add rss

Tailwind CSS

如需使用 Tailwind:npx astro add tailwind(varsha 默认使用原生 CSS)

添加 Astro 集成的最简单方式是使用 Astro CLI:

终端窗口
npx astro add <integration-name>

这会自动安装依赖并更新 astro.config.mjs。