@tenphi/cookbook 0.20.3 → 0.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/docs/authoring.mdx +77 -3
- package/docs/comparison.md +4 -4
- package/docs/component-styles.md +399 -0
- package/docs/configuration.md +58 -25
- package/docs/custom-components.md +369 -0
- package/docs/customization-rules.md +6 -5
- package/docs/es/getting-started.md +109 -0
- package/docs/es/index.md +63 -0
- package/docs/fonts-and-typography.md +157 -0
- package/docs/getting-started.md +4 -3
- package/docs/index.md +6 -0
- package/docs/ja/getting-started.md +109 -0
- package/docs/ja/index.md +63 -0
- package/docs/migration.md +18 -4
- package/docs/plugins.md +2 -2
- package/docs/quality-checks.md +1 -1
- package/docs/recipes.md +30 -4
- package/docs/ru/getting-started.md +109 -0
- package/docs/ru/index.md +63 -0
- package/docs/site-navigation.md +77 -0
- package/docs/theme-and-components.md +142 -975
- package/docs/troubleshooting.md +1 -1
- package/docs/zh/getting-started.md +109 -0
- package/docs/zh/index.md +63 -0
- package/package.json +3 -3
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Начало работы
|
|
3
|
+
description: Создайте сайт документации, опишите существующий репозиторий или используйте опубликованный npm-пакет.
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Для Cookbook требуется Node.js 22.19 или новее.
|
|
9
|
+
|
|
10
|
+
## Создайте первый сайт
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm create @tenphi/cookbook@latest my-docs -- --yes
|
|
14
|
+
cd my-docs
|
|
15
|
+
npm run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Мастер создаст README, конфигурацию Astro и `docs.config.ts`, а затем установит зависимости. Он также создаст `AGENTS.md` с инструкциями для программирующих агентов. Измените `README.md`, чтобы обновить главную страницу. Добавьте `docs/guide.md`, чтобы создать маршрут `/guide`. Новые и изменённые страницы появляются на сервере разработки без перезапуска.
|
|
19
|
+
|
|
20
|
+
## Опишите существующий репозиторий
|
|
21
|
+
|
|
22
|
+
Выполните команды из корня репозитория:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm create @tenphi/cookbook@latest docs-site -- --source . --yes
|
|
26
|
+
cd docs-site
|
|
27
|
+
npm run dev
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Созданный `docs.config.ts` ссылается на ваш репозиторий. Корневой README становится главной страницей, а `docs/**/*.{md,mdx}` — остальными страницами. Cookbook читает эти файлы без копирования или изменения.
|
|
31
|
+
|
|
32
|
+
Флаг `--no-install` позволяет создать файлы без установки зависимостей. В неинтерактивном режиме мастер не перезаписывает непустой целевой каталог.
|
|
33
|
+
|
|
34
|
+
## Опишите опубликованный npm-пакет
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm create @tenphi/cookbook@latest my-package-docs -- \
|
|
38
|
+
--package @scope/package@latest --yes
|
|
39
|
+
cd my-package-docs
|
|
40
|
+
npm run dev
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Мастер находит документацию в опубликованном пакете и записывает его точную версию и контрольную сумму в `cookbook.lock.json`. Добавьте этот файл в Git. Документируемый пакет не устанавливается, а его скрипты не запускаются. Выполните `npm run update`, когда понадобится заново определить версию по указанному тегу или диапазону.
|
|
44
|
+
|
|
45
|
+
## Добавьте Cookbook в существующий проект Astro
|
|
46
|
+
|
|
47
|
+
Для Cookbook требуется настройка Astro `output: "static"`. Если проект использует `output: "server"`, создайте отдельный статический проект Astro для документации.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npx astro add @tenphi/cookbook
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
В конфигурации Astro нужна одна интеграция:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { defineConfig } from "astro/config";
|
|
57
|
+
import cookbook from "@tenphi/cookbook";
|
|
58
|
+
|
|
59
|
+
export default defineConfig({ integrations: [cookbook()] });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Cookbook включает собственный рендерер Astro и автоматически находит `docs.config.ts`. Без конфигурации документации он следует соглашениям для README и каталога `docs/`.
|
|
63
|
+
|
|
64
|
+
## Настройте сайт
|
|
65
|
+
|
|
66
|
+
Начните с готовых [рецептов для фирменного стиля, логотипа и шрифтов](../recipes.md). Более глубокие изменения стилей и создание компонентов описаны в [правилах настройки](../customization-rules.md). Эти правила и ссылки на первоисточники также входят в установленный пакет Cookbook.
|
|
67
|
+
|
|
68
|
+
Создайте `docs.config.ts` рядом с `astro.config.ts`:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { defineDocsConfig } from "@tenphi/cookbook/config";
|
|
72
|
+
|
|
73
|
+
export default defineDocsConfig({
|
|
74
|
+
site: {
|
|
75
|
+
title: "Example Project",
|
|
76
|
+
description: "Documentation for Example Project",
|
|
77
|
+
repository: "https://github.com/example/project",
|
|
78
|
+
},
|
|
79
|
+
theme: {
|
|
80
|
+
brand: { from: "#2f5bff" },
|
|
81
|
+
fonts: { body: "Inter", heading: "Newsreader" },
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
В `theme.fonts` можно указать [Google Fonts по имени или собственные файлы шрифтов](../fonts-and-typography.md). Для типографики используйте `theme.presets`, для встроенных элементов — `theme.styles`, а для новых элементов — `defineComponent()` вместе с `theme.customStyles`. Начните с [руководства по теме](../theme-and-components.md); все настраиваемые части перечислены в [справочнике стилей компонентов](../component-styles.md).
|
|
87
|
+
|
|
88
|
+
Интеграция и CLI загружают одну и ту же конфигурацию. Поддерживаются `docs.config.ts`, `.mts`, `.js` и `.mjs` именно в таком порядке. Явный объект `config` в интеграции имеет приоритет; `configFile: false` отключает обнаружение файла. Для нестандартного расположения используйте `cookbook({ configFile: "./config/manual.ts" })` и `cookbook doctor --config ./config/manual.ts`.
|
|
89
|
+
|
|
90
|
+
## Корневой каталог монорепозитория
|
|
91
|
+
|
|
92
|
+
Приложение в `apps/docs/` может использовать материалы всего репозитория:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { defineDocsConfig } from "@tenphi/cookbook/config";
|
|
96
|
+
|
|
97
|
+
export default defineDocsConfig({ root: "../.." });
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Значение `root` указывается относительно файла конфигурации документации. Оно определяет расположение контента, локальных ресурсов и `cookbook.lock.json`. Запустите `npm run doctor` из каталога приложения: команда найдёт тот же корень, что и интеграция. Для сайта с несколькими пакетами каждый источник также может задать свой корень.
|
|
101
|
+
|
|
102
|
+
## Проверьте и опубликуйте
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
npm run validate
|
|
106
|
+
npm run preview
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Остальные руководства пока доступны на английском языке: [примеры](../examples.md), [компоненты для авторов](../authoring.mdx), [работа с ИИ-агентами](../ai-agents.md), [развёртывание](../deployment.md) и [обновление между версиями](../migration.md). Для полной конфигурации начните с [рецептов](../recipes.md). Если проверка завершилась ошибкой, см. [решение проблем](../troubleshooting.md).
|
package/docs/ru/index.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cookbook
|
|
3
|
+
description: Создайте статический сайт документации на Astro из файлов репозитория или опубликованного npm-пакета и настройте его оформление под свой продукт.
|
|
4
|
+
template: splash
|
|
5
|
+
seo:
|
|
6
|
+
title: Cookbook — документация рядом с кодом и в стиле вашего продукта
|
|
7
|
+
hero:
|
|
8
|
+
title: Документация рядом с кодом.
|
|
9
|
+
tagline: Создайте статический сайт документации на Astro из Markdown-файлов репозитория или зафиксированного npm-пакета, а затем настройте цвета, типографику и компоненты под свой продукт.
|
|
10
|
+
image:
|
|
11
|
+
html: '<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 64 64" aria-hidden="true"><rect width="64" height="64" rx="14" fill="currentColor"/><path fill="#fff" d="M14.8 16c6.7.2 12.3 2 16.7 5.4v28.4c-4.4-3.1-10-4.7-16.6-4.9a3 3 0 0 1-2.9-3V19a3 3 0 0 1 2.8-3Z"/><path fill="#fff" d="M49.2 16c-6.7.2-12.3 2-16.7 5.4v28.4c4.4-3.1 10-4.7 16.6-4.9a3 3 0 0 0 2.9-3V19a3 3 0 0 0-2.8-3Z"/></svg>'
|
|
12
|
+
actions:
|
|
13
|
+
- text: Начать работу
|
|
14
|
+
link: /ru/getting-started/
|
|
15
|
+
variant: primary
|
|
16
|
+
- text: Сравнить инструменты (на английском)
|
|
17
|
+
link: /comparison/
|
|
18
|
+
variant: secondary
|
|
19
|
+
sidebar:
|
|
20
|
+
label: Обзор
|
|
21
|
+
order: 1
|
|
22
|
+
---
|
|
23
|
+
## Начните со своего репозитория
|
|
24
|
+
|
|
25
|
+
Выполните эти команды в проекте, где уже есть `README.md` или каталог `docs/`:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm create @tenphi/cookbook@latest docs-site -- --source . --yes
|
|
29
|
+
cd docs-site
|
|
30
|
+
npm run dev
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Cookbook читает файлы на их текущем месте. Вы также можете [создать новый сайт](./getting-started.md), [описать именно те файлы, которые опубликованы в npm](./getting-started.md), или [добавить Cookbook в проект Astro](./getting-started.md).
|
|
34
|
+
|
|
35
|
+
## Этот сайт служит примером
|
|
36
|
+
|
|
37
|
+
Текущая страница находится в [docs/ru/index.md](https://github.com/tenphi/cookbook/blob/main/docs/ru/index.md). Небольшое [приложение Astro](https://github.com/tenphi/cookbook/tree/main/apps/reference) собирает сайт прямо из каталога `docs/` в репозитории. Навигация, поиск, элементы управления кодом, ссылки на редактирование и даты из Git доступны любому сайту Cookbook.
|
|
38
|
+
|
|
39
|
+
## Ваши материалы и оформление
|
|
40
|
+
|
|
41
|
+
### Храните исходные файлы там, где им место
|
|
42
|
+
|
|
43
|
+
Используйте Markdown-файлы и локальные ресурсы репозитория без копирования в дерево контента Astro. Cookbook также умеет читать спецификации OpenAPI и документацию npm-пакета, зафиксированного по версии и контрольной сумме. [Подробнее об источниках контента](../content-sources.md).
|
|
44
|
+
|
|
45
|
+
### Настройте сайт под свой продукт
|
|
46
|
+
|
|
47
|
+
Начните с фирменного цвета, затем настройте семантические палитры, шрифты, типографику и именованные части компонентов с помощью [Tasty](../upstream/tasty/README.md) и [Glaze](../upstream/glaze/README.md). Частичные переопределения `theme.styles` объединяются со стандартными стилями Cookbook до извлечения CSS. В браузер отправляется статический CSS. [Подробнее о теме](../theme-and-components.md).
|
|
48
|
+
|
|
49
|
+
### Находите ошибки до публикации
|
|
50
|
+
|
|
51
|
+
Неработающие ссылки, отсутствующие ресурсы, дублирующиеся маршруты и неверная навигация вызывают ошибки с указанием исходного файла. Результат — предварительно созданный HTML с локальным поиском, готовый для любого статического хостинга. [Посмотрите порядок проверки](../quality-checks.md).
|
|
52
|
+
|
|
53
|
+
## Изучите руководство
|
|
54
|
+
|
|
55
|
+
* [Начало работы](./getting-started.md): репозитории, npm-пакеты и существующие проекты Astro.
|
|
56
|
+
* [Сравнение инструментов](../comparison.md): модель контента и настройки Cookbook.
|
|
57
|
+
* [Примеры](../examples.md): репозитории, монорепозитории, пакеты и общие темы.
|
|
58
|
+
* [Поиск и навигация](../site-navigation.md): как читатели находят страницы.
|
|
59
|
+
* [Подготовка материалов](../authoring.mdx): страницы, компоненты и интерактивные примеры.
|
|
60
|
+
* [Тема и компоненты](../theme-and-components.md): фирменный стиль, токены, шрифты и собственные компоненты.
|
|
61
|
+
* [Развёртывание](../deployment.md): проверка и статический хостинг.
|
|
62
|
+
|
|
63
|
+
Остальная документация пока доступна на английском языке. Также см. [работу с ИИ-агентами](../ai-agents.md), [справочник конфигурации](../configuration.md), [настройки публикации](../publishing.md) и [справочник CLI](../cli.md).
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Search and navigation
|
|
3
|
+
description: Help readers find pages with search, sections, page contents, languages, and versions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Cookbook builds routes from your content sources. With no explicit navigation,
|
|
7
|
+
it lists published pages from those sources. Add `navigation.items` to choose
|
|
8
|
+
their order and groups, or `navigation.tabs` to give major sections separate
|
|
9
|
+
sidebars. The [navigation reference](./configuration.md#navigation) covers every
|
|
10
|
+
item form and the rules for nested groups and tabs.
|
|
11
|
+
|
|
12
|
+
For example, a small site can give its guide and API reference separate
|
|
13
|
+
sidebars. Create pages at each tab's `link` route first:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
navigation: {
|
|
17
|
+
tabs: [
|
|
18
|
+
{ label: "Guide", link: "/", items: ["/", "/getting-started"] },
|
|
19
|
+
{ label: "API", link: "/api", items: ["/api", "/api/client"] },
|
|
20
|
+
],
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Search
|
|
25
|
+
|
|
26
|
+
The production build creates a local Pagefind index. Readers can select Search
|
|
27
|
+
in the header or press Ctrl+K (⌘+K on macOS). The dialog focuses its input,
|
|
28
|
+
shows matching pages and headings, and closes with Escape or its close button.
|
|
29
|
+
Focus returns to the control that opened it. Search assets load when the dialog
|
|
30
|
+
opens. During `astro dev`, the dialog explains that results require a build;
|
|
31
|
+
use `npm run build && npm run preview` to test them.
|
|
32
|
+
|
|
33
|
+
Search is enabled by default. Set `search.enabled: false` when the site does
|
|
34
|
+
not need an index. Set `pagefind: false` in a published page's frontmatter to
|
|
35
|
+
omit just that page. Draft pages are always omitted from search, even though
|
|
36
|
+
their direct URLs remain available. The [publishing guide](./publishing.md)
|
|
37
|
+
explains how preview indexing and draft visibility work.
|
|
38
|
+
|
|
39
|
+
## Sections and page order
|
|
40
|
+
|
|
41
|
+
Use groups for a short, scannable sidebar. A group may link to its own overview
|
|
42
|
+
page; deeper groups expand to show their children. Cookbook checks that every
|
|
43
|
+
internal navigation route exists. The order also sets previous and next page
|
|
44
|
+
links. Tabs give each major section its own sidebar, including pages outside
|
|
45
|
+
the tab's URL prefix when listed in that tab's `items`.
|
|
46
|
+
|
|
47
|
+
Top-level groups keep their headings and direct links visible. Deeper groups
|
|
48
|
+
open on click or keyboard activation, and the current page's ancestors open on
|
|
49
|
+
arrival. A linked group header selects its page before toggling when that page
|
|
50
|
+
is already selected. Explicit expansion choices are remembered for the browser
|
|
51
|
+
tab. Only the current page is highlighted.
|
|
52
|
+
|
|
53
|
+
On narrow screens, the active sidebar moves into a drawer. It includes the
|
|
54
|
+
section selector, links, and a close control. The drawer closes when a reader
|
|
55
|
+
follows a link. Keyboard focus stays in the drawer while it is open and returns
|
|
56
|
+
to the menu control when it closes. Content and links remain readable if client
|
|
57
|
+
JavaScript is unavailable.
|
|
58
|
+
|
|
59
|
+
## Contents, languages, and versions
|
|
60
|
+
|
|
61
|
+
Desktop articles show an on-page table of contents. Enable an optional compact
|
|
62
|
+
contents list below the header on smaller screens with:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
tableOfContents: { mobile: true, minHeadingLevel: 2, maxHeadingLevel: 3 }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The same field in page frontmatter overrides the site setting for that page;
|
|
69
|
+
`tableOfContents: false` hides both lists. See [Authoring](./authoring.mdx#on-page-navigation)
|
|
70
|
+
for heading behavior.
|
|
71
|
+
|
|
72
|
+
Configure `locales` to offer translated pages and `site.versions` to offer
|
|
73
|
+
documentation versions. The selectors prefer the equivalent page when it
|
|
74
|
+
exists and fall back to a real language or version home when it does not.
|
|
75
|
+
Only available translations appear in alternate-language metadata. See the
|
|
76
|
+
[language](./configuration.md#languages) and
|
|
77
|
+
[version](./configuration.md#site) configuration examples.
|