@farming-labs/astro-theme

中文文档
0.2.146发布于 2026/11/14MITTypeScriptES Module近 30 天下载 2.1万

@ farmining-labs/ docs的 Astro UI 组件——布局、侧边栏、 TOC、 搜索和主题切换

中文使用文档
文档目录6 节
  1. 安装
  2. 配置主题
  3. 打开文件UI
  4. 主题和组件
  5. 学多点
  6. 许可证

@农地/天文主题

Astro-native UI 层和主题预设软件包 @farming-labs/docs。 。 。 .

它使文件 shell, 页面内容, 搜索对话框, AI聊天, 以及主题控制 。 内容 装入和路由处理人员居住 @farming-labs/astro。 。 。 .

安装

npm install @farming-labs/docs @farming-labs/astro @farming-labs/astro-theme @farming-labs/theme

CLI可以脚手架 完整的Astro集成:

npx @farming-labs/docs@latest init

配置主题

// src/lib/docs.config.ts
import { defineDocs } from "@farming-labs/docs";
import { fumadocs } from "@farming-labs/astro-theme";

export default defineDocs({
  entry: "docs",
  contentDir: "docs",
  theme: fumadocs(),
  nav: { title: "Docs", url: "/docs" },
});

打开文件UI

Astro 组件从组件子路径导出:

---
import DocsLayout from "@farming-labs/astro-theme/src/components/DocsLayout.astro";
import DocsContent from "@farming-labs/astro-theme/src/components/DocsContent.astro";
import SearchDialog from "@farming-labs/astro-theme/src/components/SearchDialog.astro";
import "@farming-labs/theme/default/css";

import config from "../../lib/docs.config";
import { load } from "../../lib/docs.server";

const data = await load(Astro.url.pathname);
---

<DocsLayout tree={data.tree} config={config}>
  <DocsContent data={data} config={config} />
</DocsLayout>
<SearchDialog config={config} />

服务器侧 load() 函数来自 @farming-labs/astro/server。 。 。 .

主题和组件

货船 DocsLayout, (中文(简体) ), DocsContent, (中文(简体) ), DocsPage, (中文(简体) ), SearchDialog, (中文(简体) ), FloatingAIChat,以及 ThemeToggle Astro组件.

预设子路径为 fumadocs, (中文(简体) ), pixel-border, (中文(简体) ), darksharp, (中文(简体) ), colorful, (中文(简体) ), greentree, (中文(简体) ), hardline, (中文(简体) ), concrete, (中文(简体) ), command-grid,以及 ledger编辑 fumadocs 预设用途 @farming-labs/theme/default/css; 其他预设使用匹配 @farming-labs/theme/<preset>/css 进入点.

学多点

许可证

麻省理工学院

版本与发布记录

@farming-labs/astro-theme 共发布 367 个版本,首次发布于 2026/02/20;过去 12 个月发布了 367 个版本。

版本发布日期距今
0.2.146latest2026/11/14今天
0.2.1452026/11/131 天前
0.2.1442026/11/131 天前
0.2.1432026/11/068 天前
0.2.1422026/11/068 天前
0.2.1412026/11/059 天前

其他发布通道:perf → 0.2.133-perf.1,beta → 0.2.139-beta.1。

关于 @farming-labs/astro-theme 的常见问题

@farming-labs/astro-theme 是什么?

@ farmining-labs/ docs的 Astro UI 组件——布局、侧边栏、 TOC、 搜索和主题切换

如何安装 @farming-labs/astro-theme?

在项目目录运行 npm install @farming-labs/astro-theme,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:astro(>=4.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@farming-labs/astro-theme 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@farming-labs/astro-theme 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@farming-labs/astro-theme 可以商用吗?

@farming-labs/astro-theme 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@farming-labs/astro-theme 的下载量有多少?

根据 npm 官方下载统计,@farming-labs/astro-theme 在 2026/10/15 – 2026/11/13 这 30 天内被下载 21,239 次,日均约 708 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@farming-labs/astro-theme 还在维护吗?

最新版本 0.2.146 发布于 2026/11/14(今天);至今共发布 367 个版本,其中过去 12 个月发布了 367 个;首次发布于 2026/02/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。