# @farming-labs/astro-theme 中文文档

规范地址：https://npmcn.com/package/%40farming-labs/astro-theme/

版本：0\.2\.146
npm 元数据更新时间：2026-11-13T20:33:27.653Z
中文译文更新时间：2026-11-14T10:33:40.958Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40farming-labs/astro-theme
原文对照：https://npmcn.com/package/%40farming-labs/astro-theme/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：384 kB，51 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：3 个
- peer 依赖：astro \>=4\.0\.0
- 首次发布：2026-02-19T19:32:58.168Z
- 最新版本发布：2026-11-13T20:33:27.417Z
- 近 30 天下载量：21239（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：367（近 12 个月 367 个）

## 中文简介

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

## 安装

```sh
npm install @farming-labs/astro-theme
```

也可以使用：`pnpm add @farming-labs/astro-theme`、`yarn add @farming-labs/astro-theme`、`bun add @farming-labs/astro-theme`

## README

# @农地/天文主题

Astro-native UI 层和主题预设软件包 [`@farming-labs/docs`](https://www.npmjs.com/package/@farming-labs/docs)。 。 。 .

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

## 安装

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

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

```bash
npx @farming-labs/docs@latest init
```

## 配置主题

```ts
// 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 组件从组件子路径导出:

```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` 进入点.

## 学多点

-   [文档](https://docs.farming-labs.dev/docs)
-   [主题](https://docs.farming-labs.dev/docs/themes)
-   [天体实例](https://github.com/farming-labs/docs/tree/main/examples/astro)
-   [GitHub 仓库](https://github.com/farming-labs/docs)

## 许可证

麻省理工学院

## 常见问题

### @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 和提交记录判断。

