@farming-labs/astro-theme

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

Astro UI components for @farming-labs/docs — layout, sidebar, TOC, search, and theme toggle

原始使用文档
文档目录6 节
  1. Install
  2. Configure the theme
  3. Render the docs UI
  4. Themes and components
  5. Learn more
  6. License

@farming-labs/astro-theme

The Astro-native UI layer and theme preset package for @farming-labs/docs.

It renders the docs shell, page content, search dialog, AI chat, and theme controls. Content loading and route handlers live in @farming-labs/astro.

Install

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

The CLI can scaffold the complete Astro integration:

npx @farming-labs/docs@latest init

Configure the theme

// 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" },
});

Render the docs UI

Astro components are exported from component subpaths:

---
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} />

The server-side load() function comes from @farming-labs/astro/server.

Themes and components

The package ships DocsLayout, DocsContent, DocsPage, SearchDialog, FloatingAIChat, and ThemeToggle Astro components.

Preset subpaths are fumadocs, pixel-border, darksharp, colorful, greentree, hardline, concrete, command-grid, and ledger. The fumadocs preset uses @farming-labs/theme/default/css; the other presets use the matching @farming-labs/theme/<preset>/css entrypoint.

Learn more

License

MIT

版本与发布记录

@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 是什么?

Astro UI components for @farming-labs/docs — layout, sidebar, TOC, search, and theme toggle

如何安装 @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 和提交记录判断。