diff options
author | 李瑞丰 | 2023-07-25 00:32:10 +0800 |
---|---|---|
committer | GitHub | 2023-07-24 18:32:10 +0200 |
commit | 05f2e35df1f6950bfdf2fbd3ec99c5663f64f208 (patch) | |
tree | 0fb6a9dad577e1fd67c75cd4e6599b81e29e36fe | |
parent | 0ebc47e52dc420240c8cb724c01f98dc22bdfc60 (diff) | |
download | IT.starlight-05f2e35df1f6950bfdf2fbd3ec99c5663f64f208.tar.gz IT.starlight-05f2e35df1f6950bfdf2fbd3ec99c5663f64f208.tar.bz2 IT.starlight-05f2e35df1f6950bfdf2fbd3ec99c5663f64f208.zip |
i18n(zh-cn): translate index & getting-started & manual-setup.mdx (#387)
* i18n(zh-cn): translate index & manyal-setup.mdx
* Include `/zh/` in i18n labeller
---------
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
-rw-r--r-- | .github/labeler.yml | 1 | ||||
-rw-r--r-- | docs/astro.config.mjs | 8 | ||||
-rw-r--r-- | docs/src/content/docs/zh/getting-started.mdx | 135 | ||||
-rw-r--r-- | docs/src/content/docs/zh/index.mdx | 44 | ||||
-rw-r--r-- | docs/src/content/docs/zh/manual-setup.mdx | 127 |
5 files changed, 314 insertions, 1 deletions
diff --git a/.github/labeler.yml b/.github/labeler.yml index 18441fb0..02cedc80 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -9,6 +9,7 @@ i18n: - docs/src/content/docs/fr/**/* - docs/src/content/docs/it/**/* - docs/src/content/docs/ja/**/* + - docs/src/content/docs/zh/**/* '🌟 core': - packages/starlight/** diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 210eb5bc..065e3507 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -8,6 +8,7 @@ export const locales = { ja: { label: '日本語', lang: 'ja' }, fr: { label: 'Français', lang: 'fr' }, it: { label: 'Italiano', lang: 'it' }, + zh: { label: '简体中文', lang: 'zh' }, }; const site = 'https://starlight.astro.build/'; @@ -58,6 +59,7 @@ export default defineConfig({ ja: 'ここからはじめる', fr: 'Commencez ici', it: 'Inizia qui', + zh: '从这里开始', }, items: [ { @@ -69,6 +71,7 @@ export default defineConfig({ ja: '入門', fr: 'Mise en route', it: 'Iniziamo', + zh: '开始使用', }, }, { @@ -80,6 +83,7 @@ export default defineConfig({ ja: '手動セットアップ', // fr: 'Manual Setup', // it: 'Manual Setup', + zh: '手动配置', }, }, { @@ -91,6 +95,7 @@ export default defineConfig({ ja: '環境への負荷', fr: 'Impact environnemental', it: 'Impatto ambientale', + zh: '环境影响', }, }, { @@ -108,7 +113,7 @@ export default defineConfig({ }, { label: 'Guides', - translations: { de: 'Anleitungen', es: 'Guías', ja: 'ガイド', fr: 'Guides', it: "Guide", }, + translations: { de: 'Anleitungen', es: 'Guías', ja: 'ガイド', fr: 'Guides', it: "Guide", zh: '指南' }, autogenerate: { directory: 'guides' }, }, { @@ -119,6 +124,7 @@ export default defineConfig({ ja: 'リファレンス', fr: 'Référence', it: 'Riferimenti', + zh: '参考', }, autogenerate: { directory: 'reference' }, }, diff --git a/docs/src/content/docs/zh/getting-started.mdx b/docs/src/content/docs/zh/getting-started.mdx new file mode 100644 index 00000000..b63be94c --- /dev/null +++ b/docs/src/content/docs/zh/getting-started.mdx @@ -0,0 +1,135 @@ +--- +title: 开始使用 +description: 了解如何使用 Astro 的 Starlight 开始构建下一个文档站点。 + +--- + +import { Tabs, TabItem } from '@astrojs/starlight/components'; + +:::caution[工作正在进行中] +Starlight 处于早期开发阶段。 +如果您发现有些东西不能正常工作,请在 [GitHub 上打开一个问题](https://github.com/withastro/starlight/issues/new/choose) ,或在 [Discord](https://astro.build/chat) 上告诉我们。 +::: + +## 创建一个新项目 + +Starlight 是一个基于 [Astro](https://astro.build) 框架构建的全功能文档主题。 + +你可以使用以下命令创建一个新的 Astro + Starlight 项目: + +<Tabs> +<TabItem label="npm"> + +```sh +# 使用 npm 创建一个新项目 +npm create astro@latest -- --template starlight +``` + +</TabItem> +<TabItem label="pnpm"> + +```sh +# 使用 pnpm 创建一个新项目 +pnpm create astro --template starlight +``` + +</TabItem> +<TabItem label="Yarn"> + +```sh +# 使用 yarn 创建一个新项目 +yarn create astro --template starlight +``` + +</TabItem> +</Tabs> + +这将创建一个新的 [项目目录](/zh/guides/project-structure/),其中包含你网站所需的所有文件和配置。 + +:::tip[查看实际效果] +在浏览器中尝试 Starlight: +[在 StackBlitz 上打开模板](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)。 +::: + +## 使用 Starlight 创建内容 + +Starlight 已经准备好让你添加新的内容,或者将你现有的文件带过来! + +### 文件格式 + +Starlight 支持使用 Markdown 和 MDX 来编写内容。(你可以通过安装实验性的 [Astro Markdoc 集成](https://docs.astro.build/en/guides/integrations-guide/markdoc/) 来添加对 Markdoc 的支持。) + +### 添加页面 + +在 `src/content/docs/` 中创建 `.md` 或 `.mdx` 文件,就可以自动将新页面添加到你的站点中。添加子文件夹来组织你的文件,并创建多个路径段: + +``` +src/content/docs/hello-world.md => your-site.com/hello-world +src/content/docs/guides/faq.md => your-site.com/guides/faq +``` + +### 类型安全的 frontmatter + +所有 Starlight 页面都共享一个可自定义的 [frontmatter 属性集](/zh/reference/frontmatter/),用于控制页面的外观: + +```md +--- +title: Hello, World! +description: This is a page in my Starlight-powered site +--- +``` + +如果你忘记了任何重要的东西,Starlight 会提醒你。 + +## 部署你的 Starlight 网站 + +一旦你创建并自定义了你的 Starlight 网站,你就可以将它部署到你选择的 web 服务器或托管平台上,包括 Netlify、Vercel、GitHub Pages 等等。 + +[在 Astro 文档中了解如何部署 Astro 网站。](https://docs.astro.build/zh-cn/guides/deploy/) + +## 更新 Starlight + +:::tip[提示] +由于 Starlight 是 beta 软件,所以会经常更新和改进。请务必定期更新 Starlight! +::: + +Starlight 是一个 Astro 集成,可以像任何 `@astrojs/*` 集成一样更新: + +<Tabs> +<TabItem label="npm"> + +```sh +# 使用 npm 升级 Starlight +npm install @astrojs/starlight@latest +``` + +</TabItem> +<TabItem label="pnpm"> + +```sh +# 使用 pnpm 升级 Starlight +pnpm upgrade @astrojs/starlight --latest +``` + +</TabItem> +<TabItem label="Yarn"> + +```sh +# 使用 yarn 升级 Starlight +yarn upgrade @astrojs/starlight --latest +``` + +</TabItem> +</Tabs> + +你可以在 [Starlight 更新日志](https://github.com/withastro/starlight/blob/main/packages/starlight/CHANGELOG.md) 中查看每个版本的变动列表。 + +## Starlight 故障排除 + +本站点的参考部分提供了 Starlight [项目配置](/zh/reference/configuration/)和[单个页面 frontmatter 配置](/zh/reference/frontmatter/)信息。使用这些页面来确保你的 Starlight 网站已正确配置和运行。 + +请参阅侧边栏中不断增长的指南列表,以获取有关添加内容和自定义 Starlight 网站的帮助。 + +如果你在这些文档中找不到答案,请访问[完整的 Astro 文档](https://docs.astro.build) 以获取完整的 Astro 文档。你的问题可能是通过了解 Starlight 主题下 Astro 的工作原理来解决的。 + +你也可以在 [Astro Discord](https://astro.build/chat/)上从我们活跃的、友好的社区中获得帮助!你可以在我们的 `#support` 论坛中发布问题,或者访问我们专门的 `#starlight` 频道来讨论当前的开发和更多! diff --git a/docs/src/content/docs/zh/index.mdx b/docs/src/content/docs/zh/index.mdx new file mode 100644 index 00000000..60531460 --- /dev/null +++ b/docs/src/content/docs/zh/index.mdx @@ -0,0 +1,44 @@ +--- +title: Starlight 🌟 使用 Astro 构建文档站点 +description: Starlight 帮助你使用 Astro 构建漂亮、高性能的文档网站。 +template: splash +hero: + title: 使用 Starlight 让你的文档闪耀 + tagline: 构建漂亮、高性能的文档网站。快速、易用、可访问。 + image: + file: ../../../assets/hero-star.webp + actions: + - text: 开始使用 + icon: right-arrow + variant: primary + link: /zh/getting-started/ + - text: 在 GitHub 上查看 + icon: external + link: https://github.com/withastro/starlight +--- + +import { CardGrid, Card } from '@astrojs/starlight/components'; +import AboutAstro from '../../../components/about-astro.astro'; + +<CardGrid stagger> + <Card title="令人愉悦的文档" icon="open-book"> + 包括:网站导航、搜索、国际化、SEO、易于阅读的排版、代码高亮、深色模式等等。 + </Card> + <Card title="由 Astro 提供支持" icon="rocket"> + 充分利用 Astro 的全部功能和性能。使用你最喜欢的 Astro 集成和库扩展 Starlight。 + </Card> + <Card title="Markdown、Markdoc 和 MDX" icon="document"> + 带上你最喜欢的标记语言。Starlight 为你提供了内置的 frontmatter 验证和 TypeScript 类型安全。 + </Card> + <Card title="带上你自己的 UI 组件" icon="puzzle"> + Starlight 作为一个不依赖于框架的完整文档解决方案。可以使用 React、Vue、Svelte、Solid 等进行扩展。 + </Card> +</CardGrid> + +<AboutAstro title="由以下提供支持"> +Astro 是专为速度而设计的全能 Web 框架。 +从任何地方获取你的内容并在任何地方部署,所有这些都由你喜欢的 UI 组件和库提供支持。 + +[了解 Astro](https://astro.build/) + +</AboutAstro> diff --git a/docs/src/content/docs/zh/manual-setup.mdx b/docs/src/content/docs/zh/manual-setup.mdx new file mode 100644 index 00000000..7ef5bea1 --- /dev/null +++ b/docs/src/content/docs/zh/manual-setup.mdx @@ -0,0 +1,127 @@ +--- +title: 手动配置 +description: 了解如何手动配置 Starlight 以将其添加到现有的 Astro 项目中。 +--- + +import { Tabs, TabItem } from '@astrojs/starlight/components'; + +创建新的 Starlight 站点的最快方法是使用 `create astro`,如[入门指南](/zh/getting-started/#创建一个新项目)所示。 +如果你想将 Starlight 添加到现有的 Astro 项目中,本指南将解释如何操作。 + +## 设置 Starlight + +要遵循本指南,你需要一个现有的 Astro 项目。 + +### 添加 Starlight 集成 + +Starlight 是一个 [Astro 集成](https://docs.astro.build/zh-cn/guides/integrations-guide/)。通过在项目的根目录中运行 `astro add` 命令将其添加到你的站点中: + +<Tabs> + <TabItem label="npm"> + ```sh + npx astro add starlight + ``` + + </TabItem> + <TabItem label="pnpm"> + ```sh + pnpm astro add starlight + ``` + </TabItem> + <TabItem label="Yarn"> + ```sh + yarn astro add starlight + ``` + </TabItem> + +</Tabs> + +这将安装所需的依赖项,并将 Starlight 添加到 Astro 配置文件中的 `integrations` 数组中。 + +### 配置集成 + +Starlight 集成在 `astro.config.mjs` 文件中配置。 + +添加一个 `title` 以开始: + +```js {7-9} +// astro.config.mjs +import { defineConfig } from 'astro/config'; +import starlight from '@astrojs/starlight'; + +export default defineConfig({ + integrations: [ + starlight({ + title: '我的令人愉悦的文档网站', + }), + ], +}); +``` + +在 [Starlight 配置参考](/zh/reference/configuration/) 中查找所有可用选项。 + +### 配置内容集合 + +Starlight 是建立在 Astro 的[内容集合](https://docs.astro.build/zh-cn/guides/content-collections/)之上的,这些集合在 `src/content/config.ts` 文件中配置。 + +创建或更新内容配置文件,添加一个使用 Starlight 的 `docsSchema` 的 `docs` 集合: + +```js ins={3,6} +// src/content/config.ts +import { defineCollection } from 'astro:content'; +import { docsSchema } from '@astrojs/starlight/schema'; + +export const collections = { + docs: defineCollection({ schema: docsSchema() }), +}; +``` + +### 添加内容 + +现在 Starlight 已经配置好了,是时候添加一些内容了! + +创建一个 `src/content/docs/` 目录,并从添加一个 `index.md` 文件开始。 +这将是你的新站点的首页: + +```md +--- +# src/content/docs/index.md +title: 我的文档 +description: 通过 Starlight 构建的文档网站,了解有关我的项目的更多信息。 +--- + +欢迎来到我的项目! +``` + +Starlight 使用基于文件的路由,这意味着 `src/content/docs/` 中的每个 Markdown、MDX 或 Markdoc 文件都将变成你站点上的一个页面。前置元数据(上面示例中的 `title` 和 `description` 字段)可以更改每个页面的显示方式。在 [frontmatter 指南](/zh/reference/frontmatter/) 中查看所有可用选项。 + +## 现有站点的提示 + +如果你有一个现有的 Astro 项目,你可以使用 Starlight 快速地为你的站点添加一个文档部分。 + +### 在子路径中使用 Starlight + +要在子路径中添加所有 Starlight 页面,请将所有文档内容放在 `src/content/docs/` 的子目录中。 + +例如,如果 Starlight 页面都应该以 `/guides/` 开头,请将内容添加到 `src/content/docs/guides/` 目录中: + +import FileTree from '../../../components/file-tree.astro'; + +<FileTree> + +- src/ + - content/ + - docs/ + - **guides/** + - guide.md + - index.md + - pages/ +- astro.config.mjs + +</FileTree> + +在将来,我们计划更好地支持这种用例,以避免在 `src/content/docs/` 中需要额外的嵌套目录。 + +### 结合 SSR 使用 Starlight + +目前,Starlight 不支持使用 Astro 的服务器适配器进行 [SSR 部署](https://docs.astro.build/zh-cn/guides/server-side-rendering/) 。我们希望能够尽快支持这一点。 |