diff --git a/docs/src/content/docs/zh-cn/guides/i18n.mdx b/docs/src/content/docs/zh-cn/guides/i18n.mdx index 79d4cd3d95..0e83217b4c 100644 --- a/docs/src/content/docs/zh-cn/guides/i18n.mdx +++ b/docs/src/content/docs/zh-cn/guides/i18n.mdx @@ -143,6 +143,34 @@ Starlight 期望你在所有语言中创建等效的页面。例如,如果你 如果某种语言尚未提供翻译,Starlight 将为读者显示该页面的默认语言(通过 `defaultLocale` 设置)的内容。例如,如果你尚未创建关于你的法语版本,并且你的默认语言是英语,那么访问 `/fr/about` 的访问者将看到来自 `/en/about` 的英语内容,并显示该页面尚未翻译的通知。这有助于你在默认语言中添加内容,然后在翻译人员有时间时逐步翻译它。 +## 翻译网站标题 + +默认情况下,Starlight 会为所有语言使用相同的站点标题。 +如果你需要为每种语言自定义标题,你可以在 Starlight 的选项中将一个对象传递给 [`title`](/zh-cn/reference/configuration/#title-必填): + +```diff lang="js" +// astro.config.mjs +import { defineConfig } from 'astro/config'; +import starlight from '@astrojs/starlight'; + +export default defineConfig({ + integrations: [ + starlight({ +- title: 'My Docs', ++ title: { ++ en: 'My Docs', ++ 'zh-CN': '我的文档', ++ }, + defaultLocale: 'en', + locales: { + en: { label: 'English' }, + 'zh-cn': { label: '简体中文', lang: 'zh-CN' }, + }, + }), + ], +}); +``` + ## 翻译 Starlight 的 UI import LanguagesList from '~/components/languages-list.astro'; diff --git a/docs/src/content/docs/zh-cn/guides/pages.mdx b/docs/src/content/docs/zh-cn/guides/pages.mdx index 0298dc6119..2d15d5f1ca 100644 --- a/docs/src/content/docs/zh-cn/guides/pages.mdx +++ b/docs/src/content/docs/zh-cn/guides/pages.mdx @@ -107,6 +107,7 @@ import CustomComponent from './CustomComponent.astro'; - [`slug`](/zh-cn/reference/frontmatter/#slug) 属性不受支持,并且会根据自定义页面的 URL 自动设置。 - [`editUrl`](/zh-cn/reference/frontmatter/#editurl) 选项需要一个 URL 来显示编辑链接。 - 用于自定义页面如何在 [自动生成的链接组](/zh-cn/reference/configuration/#sidebar) 中显示的 [`sidebar`](/zh-cn/reference/frontmatter/#sidebar) frontmatter 属性不可用。使用 `` 组件的页面不是集合的一部分,不能添加到自动生成的侧边栏组中。 +- [`draft`](/zh-cn/reference/frontmatter/#draft) 选项仅会显示页面为草稿的 [通知](/zh-cn/reference/overrides/#draftcontentnotice),但不会自动将其从生产版本中排除。 ##### `sidebar` diff --git a/docs/src/content/docs/zh-cn/reference/configuration.mdx b/docs/src/content/docs/zh-cn/reference/configuration.mdx index 8e3b3ce6bd..6bb7641843 100644 --- a/docs/src/content/docs/zh-cn/reference/configuration.mdx +++ b/docs/src/content/docs/zh-cn/reference/configuration.mdx @@ -25,10 +25,22 @@ export default defineConfig({ ### `title` (必填) -**类型:** `string` +**类型:** `string | Record` 设置你的网站标题。将用于元数据和浏览器标签标题。 +这个值可以是一个字符串,或者对于多语言网站,可以是一个包含每种不同语言值的对象。 +当使用对象形式时,键必须是 BCP-47 标签(例如 `en`,`ar` 或 `zh-CN`): + +```ts +starlight({ + title: { + en: 'My delightful docs site', + de: 'Meine bezaubernde Dokumentationsseite', + }, +}); +``` + ### `description` **类型:** `string` diff --git a/docs/src/content/docs/zh-cn/reference/frontmatter.md b/docs/src/content/docs/zh-cn/reference/frontmatter.md index c7d37556b3..408cc689cc 100644 --- a/docs/src/content/docs/zh-cn/reference/frontmatter.md +++ b/docs/src/content/docs/zh-cn/reference/frontmatter.md @@ -267,6 +267,21 @@ pagefind: false --- ``` +### `draft` + +**类型:** `boolean` +**默认值:** `false` + +设置此页面是否应被视为草稿,并且不包含在 [生产版本](https://docs.astro.build/zh-cn/reference/cli-reference/#astro-build) 和 [自动生成的链接组](/zh-cn/guides/sidebar/#自动生成的分组) 中。设置为 `true` 可将页面标记为草稿,并使其仅在开发过程中可见。 + +```md +--- +# src/content/docs/example.md +# 从生产版本中排除此页面 +draft: true +--- +``` + ### `sidebar` **类型:** [`SidebarConfig`](#sidebarconfig) diff --git a/docs/src/content/docs/zh-cn/reference/overrides.md b/docs/src/content/docs/zh-cn/reference/overrides.md index 4769f656a7..aebbc401db 100644 --- a/docs/src/content/docs/zh-cn/reference/overrides.md +++ b/docs/src/content/docs/zh-cn/reference/overrides.md @@ -50,6 +50,12 @@ Starlight 会将以下参数传递给你的自定义组件。 当前语言的根路径。对于默认语言来说是 `undefined`。 +#### `siteTitle` + +**类型:** `string` + +根据页面语言设置的网站标题。 + #### `slug` **类型:** `string` @@ -218,7 +224,7 @@ entry: { **默认组件:** [`Header.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/Header.astro) 在每个页面顶部显示的导航栏组件。 -默认实现显示了 [``](#sitetitle)、[``](#search)、[``](#socialicons)、[``](#themeselect) 和 [``](#languageselect)。 +默认实现显示了 [``](#sitetitle-1)、[``](#search)、[``](#socialicons)、[``](#themeselect) 和 [``](#languageselect)。 #### `SiteTitle` @@ -332,6 +338,12 @@ Starlight 的页面侧边栏负责显示当前页面的子标题的目录。 自定义实现应确保在 `

` 元素上设置 `id="_top"`,就像默认实现中一样。 +#### `DraftContentNotice` + +**默认组件:** [`DraftContentNotice.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/DraftContentNotice.astro) + +在开发过程中,当当前页面被标记为草稿时,向用户显示的通知。 + #### `FallbackContentNotice` **默认组件:** [`FallbackContentNotice.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/FallbackContentNotice.astro)