From 35248a86e8eaef8f320f190402cabdda5d8cab8c Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 15:47:16 +0900 Subject: [PATCH 01/14] i18n(ko-KR): update `using-components.mdx` (#2672) --- docs/src/content/docs/ko/components/using-components.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/content/docs/ko/components/using-components.mdx b/docs/src/content/docs/ko/components/using-components.mdx index 2521fa4247d..86c69e45118 100644 --- a/docs/src/content/docs/ko/components/using-components.mdx +++ b/docs/src/content/docs/ko/components/using-components.mdx @@ -9,7 +9,7 @@ sidebar: 링크 카드나 YouTube 삽입 등을 예로 들 수 있습니다. Starlight는 [MDX](https://mdxjs.com/) 및 [Markdoc](https://markdoc.dev/) 파일에서 컴포넌트 사용을 지원하며 사용할 수 있는 몇 가지 공통 컴포넌트를 제공합니다. -[Astro 문서에서 컴포넌트 구축에 대해 자세히 알아보세요](https://docs.astro.build/ko/core-concepts/astro-components/). +[Astro 문서에서 컴포넌트 구축에 대해 자세히 알아보세요](https://docs.astro.build/ko/basics/astro-components/). ## MDX에서 컴포넌트 사용 @@ -30,7 +30,7 @@ import CustomCard from '../../components/CustomCard.astro'; 컴포넌트에는 **중첩된 콘텐츠**가 포함될 수도 있습니다. ``` -Starlight는 Astro로 구동되므로 [지원되는 UI 프레임워크(React, Preact, Svelte, Vue, Solid, Alpine)](https://docs.astro.build/ko/core-concepts/framework-components/)로 빌드된 컴포넌트를 MDX 파일에 추가할 수 있습니다. +Starlight는 Astro로 구동되므로 [지원되는 UI 프레임워크(React, Preact, Svelte, Vue, Solid, Alpine)](https://docs.astro.build/ko/guides/framework-components/)로 빌드된 컴포넌트를 MDX 파일에 추가할 수 있습니다. Astro 문서에서 [MDX에서 컴포넌트 사용](https://docs.astro.build/ko/guides/integrations-guide/mdx/#mdx에서-컴포넌트-사용)에 대해 자세히 알아보세요. ## Markdoc에서 컴포넌트 사용 From eef26d80c22b7bc681a1c6334c35ba59f980a48d Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 15:52:28 +0900 Subject: [PATCH 02/14] i18n(ko-KR): update `environmental-impact.md` (#2673) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/ko/environmental-impact.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/content/docs/ko/environmental-impact.md b/docs/src/content/docs/ko/environmental-impact.md index f97533f7a40..13d847e303f 100644 --- a/docs/src/content/docs/ko/environmental-impact.md +++ b/docs/src/content/docs/ko/environmental-impact.md @@ -138,6 +138,6 @@ JavaScript를 분석하고 컴파일하는 것은 브라우저가 수행해야 [sf]: https://www.sciencefocus.com/science/what-is-the-carbon-footprint-of-the-internet/ [bbc]: https://www.bbc.com/future/article/20200305-why-your-internet-habits-are-not-as-clean-as-you-think [http]: https://httparchive.org/reports/state-of-the-web -[assets]: https://docs.astro.build/ko/guides/assets/ +[assets]: https://docs.astro.build/ko/guides/images/ [islands]: https://docs.astro.build/ko/concepts/islands/ [wcc]: https://www.websitecarbon.com/ From cc0601b2cb425a5c895e08d7620aa8b09d0292c6 Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 15:57:23 +0900 Subject: [PATCH 03/14] i18n(ko-KR): update `authoring-content.mdx` (#2675) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/ko/guides/authoring-content.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/content/docs/ko/guides/authoring-content.mdx b/docs/src/content/docs/ko/guides/authoring-content.mdx index de4770edd35..f193a1532f5 100644 --- a/docs/src/content/docs/ko/guides/authoring-content.mdx +++ b/docs/src/content/docs/ko/guides/authoring-content.mdx @@ -45,7 +45,7 @@ title: 페이지 제목 ## 이미지 -Starlight의 이미지는 [Astro에 내장된 최적화된 자산 지원](https://docs.astro.build/ko/guides/assets/)을 사용합니다. +Starlight의 이미지는 [Astro에 내장된 최적화된 자산 지원](https://docs.astro.build/ko/guides/images/)을 사용합니다. Markdown 및 MDX는 스크린 리더 및 보조 기술에서 사용되는 대체 텍스트가 포함된 이미지를 표시하기 위한 Markdown 구문을 지원합니다. @@ -105,7 +105,7 @@ description: Starlight에 내장된 링크를 사용하는 방법 레벨 2 (`

`) 및 레벨 3 (`

`) 제목이 페이지 목차에 자동으로 나타납니다. -[Astro 공식 문서](https://docs.astro.build/ko/guides/markdown-content/#heading-ids)에서 Astro가 제목의 `id`를 처리하는 방법에 대해 자세히 알아보세요. +[Astro 공식 문서](https://docs.astro.build/ko/guides/markdown-content/#제목-id)에서 Astro가 제목의 `id`를 처리하는 방법에 대해 자세히 알아보세요. ## 보조 내용 @@ -144,12 +144,12 @@ npm create astro@latest -- --template starlight :::tip[알고 계셨나요?] -Astro는 ["Islands Architecture"](https://docs.astro.build/ko/concepts/islands/)를 사용하여 더 빠른 웹사이트를 구축할 수 있도록 도와줍니다. +Astro는 ["아일랜드 아키텍처"](https://docs.astro.build/ko/concepts/islands/)를 사용하여 더 빠른 웹사이트를 구축할 수 있도록 도와줍니다. ::: ```md :::tip[알고 계셨나요?] -Astro는 ["Islands Architecture"](https://docs.astro.build/ko/concepts/islands/)를 사용하여 더 빠른 웹사이트를 구축할 수 있도록 도와줍니다. +Astro는 ["아일랜드 아키텍처"](https://docs.astro.build/ko/concepts/islands/)를 사용하여 더 빠른 웹사이트를 구축할 수 있도록 도와줍니다. ::: ``` From 8e8c92d3ff10e2e12606db6618ebf84013718986 Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 16:03:47 +0900 Subject: [PATCH 04/14] fix: update links in `i18n.mdx` (#2676) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/guides/i18n.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/content/docs/guides/i18n.mdx b/docs/src/content/docs/guides/i18n.mdx index 7591a5340fe..803d1372ae1 100644 --- a/docs/src/content/docs/guides/i18n.mdx +++ b/docs/src/content/docs/guides/i18n.mdx @@ -282,7 +282,7 @@ Learn more about content collection schemas in [“Defining a collection schema You can access Starlight’s [built-in UI strings](/guides/i18n/#translate-starlights-ui) as well as [user-defined](/guides/i18n/#extend-translation-schema), and [plugin-provided](/reference/plugins/#injecttranslations) UI strings through a unified API powered by [i18next](https://www.i18next.com/). This includes support for features like [interpolation](https://www.i18next.com/translation-function/interpolation) and [pluralization](https://www.i18next.com/translation-function/plurals). -In Astro components, this API is available as part of the [global `Astro` object](https://docs.astro.build/en/reference/api-reference/#astrolocals) as `Astro.locals.t`: +In Astro components, this API is available as part of the [global `Astro` object](https://docs.astro.build/en/reference/api-reference/#locals) as `Astro.locals.t`: ```astro title="example.astro"

@@ -290,7 +290,7 @@ In Astro components, this API is available as part of the [global `Astro` object

``` -You can also use the API in [endpoints](https://docs.astro.build/en/guides/endpoints/), where the `locals` object is available as part of the [endpoint context](https://docs.astro.build/en/reference/api-reference/#contextlocals): +You can also use the API in [endpoints](https://docs.astro.build/en/guides/endpoints/), where the `locals` object is available as part of the [endpoint context](https://docs.astro.build/en/reference/api-reference/#locals): ```ts title="src/pages/404.ts" export const GET = (context) => { @@ -391,7 +391,7 @@ See the [`dir()` reference in the i18next documentation](https://www.i18next.com ## Accessing the current locale -You can use [`Astro.currentLocale`](https://docs.astro.build/en/reference/api-reference/#astrocurrentlocale) to read the current locale in `.astro` components. +You can use [`Astro.currentLocale`](https://docs.astro.build/en/reference/api-reference/#currentlocale) to read the current locale in `.astro` components. The following example reads the current locale and uses it with the [`getRelativeLocaleUrl()`](https://docs.astro.build/en/reference/modules/astro-i18n/#getrelativelocaleurl) helper to generate a link to an about page in the current language: From 485a9f5a5ae3a63eaa4523e7f6a465b9e50c7a04 Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 16:08:57 +0900 Subject: [PATCH 05/14] i18n(ko-KR): update `overriding-components.mdx` (#2677) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/ko/guides/overriding-components.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/content/docs/ko/guides/overriding-components.mdx b/docs/src/content/docs/ko/guides/overriding-components.mdx index 04ef5f9130b..20925961cf8 100644 --- a/docs/src/content/docs/ko/guides/overriding-components.mdx +++ b/docs/src/content/docs/ko/guides/overriding-components.mdx @@ -84,7 +84,7 @@ import Default from '@astrojs/starlight/components/SocialIcons.astro'; 사용자 정의 컴포넌트 내부에 내장 컴포넌트를 렌더링하는 경우: - 전개 연산자를 사용하여 내장 컴포넌트에 `Astro.props`의 모든 속성을 전달합니다. 이를 통해, 내장 컴포넌트는 렌더링에 필요한 모든 데이터를 전달받습니다. -- 기본 컴포넌트 내에 [``](https://docs.astro.build/ko/core-concepts/astro-components/#슬롯)을 추가합니다. 이를 통해, 하위 컴포넌트를 전달받은 경우, Astro가 전달받은 컴포넌트를 렌더링할 위치를 알 수 있습니다. +- 기본 컴포넌트 내에 [``](https://docs.astro.build/ko/basics/astro-components/#슬롯)을 추가합니다. 이를 통해, 하위 컴포넌트를 전달받은 경우, Astro가 전달받은 컴포넌트를 렌더링할 위치를 알 수 있습니다. [명명된 슬롯](https://docs.astro.build/ko/basics/astro-components/#명명된-슬롯)이 포함된 [`PageFrame`](/ko/reference/overrides/#pageframe) 또는 [`TwoColumnContent`](/ko/reference/overrides/#twocolumncontent) 컴포넌트를 재사용하는 경우 이러한 슬롯도 [전송](https://docs.astro.build/ko/basics/astro-components/#슬롯-전송)해야 합니다. @@ -155,4 +155,4 @@ const isHomepage = Astro.props.slug === ''; } ``` -[Astro의 템플릿 구문 가이드](https://docs.astro.build/ko/core-concepts/astro-syntax/#dynamic-html)에서 조건부 렌더링에 대해 자세히 알아보세요. +[Astro의 템플릿 구문 가이드](https://docs.astro.build/ko/basics/astro-syntax/#동적-html)에서 조건부 렌더링에 대해 자세히 알아보세요. From e92421296ab7a1ba75cc34e774111d2582334082 Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 16:13:56 +0900 Subject: [PATCH 06/14] i18n(ko-KR): update `project-structure.mdx` (#2678) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/ko/guides/project-structure.mdx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/src/content/docs/ko/guides/project-structure.mdx b/docs/src/content/docs/ko/guides/project-structure.mdx index 89f1ed295db..04d8c56e950 100644 --- a/docs/src/content/docs/ko/guides/project-structure.mdx +++ b/docs/src/content/docs/ko/guides/project-structure.mdx @@ -5,12 +5,12 @@ description: Starlight 프로젝트에서 파일을 구성하는 방법을 알 이 가이드에서는 Starlight 프로젝트가 구성되는 방법과 프로젝트의 다양한 파일이 수행하는 작업을 보여줍니다. -Starlight 프로젝트는 일반적으로 다른 Astro 프로젝트와 동일한 파일 및 디렉터리 구조를 따릅니다. 자세한 내용은 [Astro의 프로젝트 구조 문서](https://docs.astro.build/ko/core-concepts/project-structure/)를 참조하세요. +Starlight 프로젝트는 일반적으로 다른 Astro 프로젝트와 동일한 파일 및 디렉터리 구조를 따릅니다. 자세한 내용은 [Astro의 프로젝트 구조 문서](https://docs.astro.build/ko/basics/project-structure/)를 참조하세요. ## 파일 및 디렉터리 - `astro.config.mjs` — Starlight 통합 및 구성이 포함된 Astro 구성 파일 입니다. -- `src/content/config.ts` — Starlight의 프론트매터 스키마를 프로젝트에 추가하는 콘텐츠 컬렉션 구성 파일입니다. +- `src/content.config.ts` — Starlight의 프론트매터 스키마를 프로젝트에 추가하는 콘텐츠 컬렉션 구성 파일입니다. - `src/content/docs/` — 콘텐츠 파일들이 포함된 디렉터리입니다. Starlight는 이 디렉터리에 있는 `.md`, `.mdx` 또는 `.mdoc` 파일을 사이트의 페이지로 변환합니다. - `src/content/i18n/` (선택적) — [국제화](/ko/guides/i18n/)를 지원하는 번역 데이터들이 포함된 디렉터리입니다. - `src/` — 프로젝트의 기타 소스 코드 및 파일(컴포넌트, 스타일, 이미지 등)이 포함된 디렉터리입니다. @@ -39,8 +39,7 @@ import { FileTree } from '@astrojs/starlight/components'; - 01-getting-started.md - 02-advanced.md - index.mdx - - config.ts - - env.d.ts + - content.config.ts - astro.config.mjs - package.json - tsconfig.json From b6376b7433a6591d8ad5da648ffc323b878708cf Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:26:31 +0900 Subject: [PATCH 07/14] i18n(ko-KR): update `site-search.mdx` (#2679) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/ko/guides/site-search.mdx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/src/content/docs/ko/guides/site-search.mdx b/docs/src/content/docs/ko/guides/site-search.mdx index 42f3986f12e..c6b1155c3dc 100644 --- a/docs/src/content/docs/ko/guides/site-search.mdx +++ b/docs/src/content/docs/ko/guides/site-search.mdx @@ -124,18 +124,19 @@ Starlight에 내장된 [국제화 시스템](/ko/guides/i18n/#starlight-ui-번 -1. `src/content/config.ts` 파일의 DocSearch 스키마를 사용하여 Starlight의 `i18n` 콘텐츠 컬렉션 정의를 확장합니다. +1. `src/content.config.ts` 파일의 DocSearch 스키마를 사용하여 Starlight의 `i18n` 콘텐츠 컬렉션 정의를 확장합니다. - ```js ins={4} ins=/{ extend: .+ }/ - // src/content/config.ts + ```js ins={5} ins=/{ extend: .+ }/ + // src/content.config.ts import { defineCollection } from 'astro:content'; + import { docsLoader, i18nLoader } from '@astrojs/starlight/loaders'; import { docsSchema, i18nSchema } from '@astrojs/starlight/schema'; import { docSearchI18nSchema } from '@astrojs/starlight-docsearch/schema'; export const collections = { - docs: defineCollection({ schema: docsSchema() }), + docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }), i18n: defineCollection({ - type: 'data', + loader: i18nLoader(), schema: i18nSchema({ extend: docSearchI18nSchema() }), }), }; From d61dd3aa9e5382372b458d5898e0c17f6dc8d2da Mon Sep 17 00:00:00 2001 From: HiDeoo Date: Sat, 14 Dec 2024 11:27:09 +0000 Subject: [PATCH 08/14] [ci] format --- docs/src/content/docs/ko/guides/site-search.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/content/docs/ko/guides/site-search.mdx b/docs/src/content/docs/ko/guides/site-search.mdx index c6b1155c3dc..a723262ad8c 100644 --- a/docs/src/content/docs/ko/guides/site-search.mdx +++ b/docs/src/content/docs/ko/guides/site-search.mdx @@ -134,9 +134,9 @@ Starlight에 내장된 [국제화 시스템](/ko/guides/i18n/#starlight-ui-번 import { docSearchI18nSchema } from '@astrojs/starlight-docsearch/schema'; export const collections = { - docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }), + docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }), i18n: defineCollection({ - loader: i18nLoader(), + loader: i18nLoader(), schema: i18nSchema({ extend: docSearchI18nSchema() }), }), }; From e1617fd8dcb294f3723451768330b41696750c44 Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:36:26 +0900 Subject: [PATCH 09/14] i18n(ko-KR): update `index.mdx` (#2680) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/ko/index.mdx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/src/content/docs/ko/index.mdx b/docs/src/content/docs/ko/index.mdx index baa0bdf1e1d..51e16371ade 100644 --- a/docs/src/content/docs/ko/index.mdx +++ b/docs/src/content/docs/ko/index.mdx @@ -7,6 +7,12 @@ description: Starlight로 아름답고 성능이 좋은 Astro 문서 웹 사이 template: splash editUrl: false lastUpdated: false +banner: + content: | + Astro 5로 업데이트 하고 싶나요? + + 업그레이드 방법 알아보기 + hero: title: Starlight로 멋진 문서를 만드세요 tagline: 아름다운 문서 웹 사이트를 만드는데 필요한 모든 것. 빠르고, 접근성이 좋으며 사용하기 쉽습니다. From d5719f8862fc6fbb7b98128cc4fde653fcbd836e Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:17:48 +0900 Subject: [PATCH 10/14] i18n(ko-KR): update `configuration.mdx` (#2682) Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/ko/reference/configuration.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/content/docs/ko/reference/configuration.mdx b/docs/src/content/docs/ko/reference/configuration.mdx index 07000930fde..9c871540597 100644 --- a/docs/src/content/docs/ko/reference/configuration.mdx +++ b/docs/src/content/docs/ko/reference/configuration.mdx @@ -467,7 +467,7 @@ Pagefind로 사이트 색인을 생성하지 않으려면 `false`로 설정하 **타입:** `boolean` **기본값:** `true` -Starlight 페이지를 정적 HTML로 사전 렌더링할지, 아니면 [SSR 어댑터](https://docs.astro.build/ko/guides/server-side-rendering/)를 통해 주문형으로 렌더링할지 정의합니다. +Starlight 페이지를 정적 HTML로 사전 렌더링할지, 아니면 [SSR 어댑터](https://docs.astro.build/ko/guides/on-demand-rendering/)를 통해 주문형으로 렌더링할지 정의합니다. Starlight 페이지는 기본적으로 사전 렌더링됩니다. SSR 어댑터를 사용 중이고 Starlight 페이지를 주문형으로 렌더링하기를 원한다면 `prerender: false`를 설정하세요. @@ -572,7 +572,7 @@ starlight({ **타입:** `boolean` **기본값:** `false` -Starlight의 기본 [404 페이지](https://docs.astro.build/ko/core-concepts/astro-pages/#사용자-정의-404-오류-페이지) 삽입을 비활성화합니다. 프로젝트에서 사용자 정의 `src/pages/404.astro` 경로를 사용하려면 이 옵션을 `true`로 설정하세요. +Starlight의 기본 [404 페이지](https://docs.astro.build/ko/basics/astro-pages/#사용자-정의-404-오류-페이지) 삽입을 비활성화합니다. 프로젝트에서 사용자 정의 `src/pages/404.astro` 경로를 사용하려면 이 옵션을 `true`로 설정하세요. ### `components` From 5c6996cd248e9da735a14e7fcaf638b51f2796bc Mon Sep 17 00:00:00 2001 From: HiDeoo <494699+HiDeoo@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:28:18 +0100 Subject: [PATCH 11/14] Fix autogenerated sidebar issue (#2688) Co-authored-by: delucis <357379+delucis@users.noreply.github.com> --- .changeset/wild-laws-play.md | 5 +++ .../__tests__/basics/navigation.test.ts | 29 +++++++++++++++-- packages/starlight/__tests__/test-utils.ts | 6 +++- packages/starlight/utils/navigation.ts | 32 +++++++++++++------ packages/starlight/utils/slugs.ts | 3 +- 5 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 .changeset/wild-laws-play.md diff --git a/.changeset/wild-laws-play.md b/.changeset/wild-laws-play.md new file mode 100644 index 00000000000..d1d1ace244f --- /dev/null +++ b/.changeset/wild-laws-play.md @@ -0,0 +1,5 @@ +--- +'@astrojs/starlight': patch +--- + +Fixes an issue with autogenerated sidebars when using Starlight with Astro's new Content Layer API where group names would be sluggified. diff --git a/packages/starlight/__tests__/basics/navigation.test.ts b/packages/starlight/__tests__/basics/navigation.test.ts index 90676507445..0b4e5bd7d4e 100644 --- a/packages/starlight/__tests__/basics/navigation.test.ts +++ b/packages/starlight/__tests__/basics/navigation.test.ts @@ -9,6 +9,7 @@ vi.mock('astro:content', async () => ['guides/authoring-content.mdx', { title: 'Authoring Markdown' }], ['reference/frontmatter.md', { title: 'Frontmatter Reference', sidebar: { hidden: true } }], ['guides/project-structure.mdx', { title: 'Project Structure' }], + ['Getting Started/intro.md', { title: 'Introduction' }], ], }) ); @@ -33,6 +34,22 @@ describe('getSidebar', () => { "label": "Eco-friendly docs", "type": "link", }, + { + "badge": undefined, + "collapsed": false, + "entries": [ + { + "attrs": {}, + "badge": undefined, + "href": "/getting-started/intro/", + "isCurrent": false, + "label": "Introduction", + "type": "link", + }, + ], + "label": "Getting Started", + "type": "group", + }, { "badge": undefined, "collapsed": false, @@ -152,6 +169,14 @@ describe('flattenSidebar', () => { "label": "Eco-friendly docs", "type": "link", }, + { + "attrs": {}, + "badge": undefined, + "href": "/getting-started/intro/", + "isCurrent": false, + "label": "Introduction", + "type": "link", + }, { "attrs": {}, "badge": undefined, @@ -182,9 +207,9 @@ describe('getPrevNextLinks', () => { "next": { "attrs": {}, "badge": undefined, - "href": "/guides/authoring-content/", + "href": "/getting-started/intro/", "isCurrent": false, - "label": "Authoring Markdown", + "label": "Introduction", "type": "link", }, "prev": { diff --git a/packages/starlight/__tests__/test-utils.ts b/packages/starlight/__tests__/test-utils.ts index 45dbde6625e..d6e3a711252 100644 --- a/packages/starlight/__tests__/test-utils.ts +++ b/packages/starlight/__tests__/test-utils.ts @@ -28,7 +28,11 @@ function mockDoc( data: z.input, body = '' ): StarlightDocsCollectionEntry { - const slug = docsFilePath.replace(/\.[^\.]+$/, '').replace(/\/index$/, ''); + const slug = docsFilePath + .replace(/\.[^\.]+$/, '') + .replace(/\s/, '-') + .replace(/\/index$/, '') + .toLowerCase(); const doc: StarlightDocsCollectionEntry = { id: project.legacyCollections ? docsFilePath : slug, diff --git a/packages/starlight/utils/navigation.ts b/packages/starlight/utils/navigation.ts index 76608601dea..921dc2fe0a7 100644 --- a/packages/starlight/utils/navigation.ts +++ b/packages/starlight/utils/navigation.ts @@ -1,5 +1,6 @@ import { AstroError } from 'astro/errors'; import config from 'virtual:starlight/user-config'; +import project from 'virtual:starlight/project-context'; import type { Badge, I18nBadge, I18nBadgeConfig } from '../schemas/badge'; import type { PrevNextLinkConfig } from '../schemas/prevNextLink'; import type { @@ -14,8 +15,9 @@ import { formatPath } from './format-path'; import { BuiltInDefaultLocale, pickLang } from './i18n'; import { ensureLeadingSlash, ensureTrailingSlash, stripLeadingAndTrailingSlashes } from './path'; import { getLocaleRoutes, routes, type Route } from './routing'; -import { localeToLang, slugToPathname } from './slugs'; +import { localeToLang, localizedId, slugToPathname } from './slugs'; import type { StarlightConfig } from './user-config'; +import { getCollectionPathFromRoot } from './collection'; const DirKey = Symbol('DirKey'); const SlugKey = Symbol('SlugKey'); @@ -108,7 +110,7 @@ function groupFromAutogenerateConfig( // Match against `foo/anything/else.md`. doc.id.startsWith(localeDir + '/') ); - const tree = treeify(dirDocs, localeDir); + const tree = treeify(dirDocs, locale, localeDir); const label = pickLang(item.translations, localeToLang(locale)) || item.label; return { type: 'group', @@ -205,8 +207,8 @@ function pathsMatch(pathA: string, pathB: string) { function getBreadcrumbs(path: string, baseDir: string): string[] { // Strip extension from path. const pathWithoutExt = stripExtension(path); - // Index paths will match `baseDir` but we still need to consider them as a single segment. - if (pathWithoutExt === baseDir) return [path]; + // Index paths will match `baseDir` and don’t include breadcrumbs. + if (pathWithoutExt === baseDir) return []; // Ensure base directory ends in a trailing slash. baseDir = ensureTrailingSlash(baseDir); // Strip base directory from path if present. @@ -218,16 +220,28 @@ function getBreadcrumbs(path: string, baseDir: string): string[] { } /** Turn a flat array of routes into a tree structure. */ -function treeify(routes: Route[], baseDir: string): Dir { +function treeify(routes: Route[], locale: string | undefined, baseDir: string): Dir { const treeRoot: Dir = makeDir(baseDir); + const collectionPathFromRoot = getCollectionPathFromRoot('docs', project); routes // Remove any entries that should be hidden .filter((doc) => !doc.entry.data.sidebar.hidden) + // Compute the path of each entry from the root of the collection ahead of time. + .map( + (doc) => + [ + project.legacyCollections + ? doc.id + : // For collections with a loader, use a localized filePath relative to the collection + localizedId(doc.entry.filePath.replace(`${collectionPathFromRoot}/`, ''), locale), + doc, + ] as const + ) // Sort by depth, to build the tree depth first. - .sort((a, b) => b.id.split('/').length - a.id.split('/').length) + .sort(([a], [b]) => b.split('/').length - a.split('/').length) // Build the tree - .forEach((doc) => { - const parts = getBreadcrumbs(doc.id, baseDir); + .forEach(([filePathFromContentDir, doc]) => { + const parts = getBreadcrumbs(filePathFromContentDir, baseDir); let currentNode = treeRoot; parts.forEach((part, index) => { @@ -374,7 +388,7 @@ function getIntermediateSidebarFromConfig( if (sidebarConfig) { return sidebarConfig.map((group) => configItemToEntry(group, pathname, locale, routes)); } else { - const tree = treeify(routes, locale || ''); + const tree = treeify(routes, locale, locale || ''); return sidebarFromDir(tree, pathname, locale, false); } } diff --git a/packages/starlight/utils/slugs.ts b/packages/starlight/utils/slugs.ts index c811c55046f..c6b0b7393ae 100644 --- a/packages/starlight/utils/slugs.ts +++ b/packages/starlight/utils/slugs.ts @@ -82,7 +82,8 @@ export function localizedSlug(slug: string, locale: string | undefined): string } /** - * Convert a legacy collection entry ID to a different locale. + * Convert a legacy collection entry ID or filePath relative to the collection root to a different + * locale. * For example, passing an ID of `en/home.md` and a locale of `fr` results in `fr/home.md`. * An undefined locale is treated as the root locale, resulting in `home.md`. * @param id A collection entry ID From 6eacefaeacd09c0e8296edb5ba4b75ed8d464ced Mon Sep 17 00:00:00 2001 From: Junseong Park <39112954+jsparkdev@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:29:34 +0900 Subject: [PATCH 12/14] i18n(ko-KR): update `overrides.md` (#2684) Co-authored-by: Chris Swithinbank --- docs/src/content/docs/ko/reference/overrides.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/src/content/docs/ko/reference/overrides.md b/docs/src/content/docs/ko/reference/overrides.md index f66868b391f..216eae47306 100644 --- a/docs/src/content/docs/ko/reference/overrides.md +++ b/docs/src/content/docs/ko/reference/overrides.md @@ -69,11 +69,14 @@ Starlight는 사용자 정의 컴포넌트에 다음 속성들을 전달합니 콘텐츠 파일 이름에서 생성된 이 페이지의 슬러그입니다. +이 속성은 더 이상 사용되지 않으며 향후 버전의 Starlight에서 제거될 예정입니다. +[Starlight의 `docsLoader`](/ko/manual-setup/#콘텐츠-컬렉션-구성)를 사용하여 새 콘텐츠 레이어 API로 마이그레이션하고 대신 [`id`](#id) 속성을 사용하세요. + #### `id` **타입:** `string` -콘텐츠 파일 이름을 기반으로 하는 이 페이지의 고유 ID입니다. +이 페이지의 슬러그 또는 [`legacy.collections`](https://docs.astro.build/ko/reference/legacy-flags/#collections) 플래그를 사용하는 경우 콘텐츠 파일명을 기준으로 한 이 페이지의 고유 ID입니다. #### `isFallback` From 0e419cc234b18721cf9523b2287f2de23a09b4e3 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Sat, 14 Dec 2024 04:33:57 -0800 Subject: [PATCH 13/14] [ci] release (#2689) --- .changeset/wild-laws-play.md | 5 ----- examples/basics/package.json | 2 +- examples/markdoc/package.json | 2 +- examples/tailwind/package.json | 2 +- packages/starlight/CHANGELOG.md | 6 ++++++ packages/starlight/package.json | 2 +- pnpm-lock.yaml | 6 +++--- 7 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 .changeset/wild-laws-play.md diff --git a/.changeset/wild-laws-play.md b/.changeset/wild-laws-play.md deleted file mode 100644 index d1d1ace244f..00000000000 --- a/.changeset/wild-laws-play.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/starlight': patch ---- - -Fixes an issue with autogenerated sidebars when using Starlight with Astro's new Content Layer API where group names would be sluggified. diff --git a/examples/basics/package.json b/examples/basics/package.json index 8662fc45d1d..37f3bb1e43c 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/starlight": "^0.30.0", + "@astrojs/starlight": "^0.30.1", "astro": "^5.0.2", "sharp": "^0.32.5" } diff --git a/examples/markdoc/package.json b/examples/markdoc/package.json index 9d4bcbac3f6..c15fd786a3f 100644 --- a/examples/markdoc/package.json +++ b/examples/markdoc/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdoc": "^0.12.1", - "@astrojs/starlight": "^0.30.0", + "@astrojs/starlight": "^0.30.1", "@astrojs/starlight-markdoc": "^0.2.0", "astro": "^5.0.2", "sharp": "^0.32.5" diff --git a/examples/tailwind/package.json b/examples/tailwind/package.json index b8ab6c9b8e7..a21e5f5d8ea 100644 --- a/examples/tailwind/package.json +++ b/examples/tailwind/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/starlight": "^0.30.0", + "@astrojs/starlight": "^0.30.1", "@astrojs/starlight-tailwind": "^3.0.0", "@astrojs/tailwind": "^5.1.3", "astro": "^5.0.2", diff --git a/packages/starlight/CHANGELOG.md b/packages/starlight/CHANGELOG.md index 53b50c34c4e..d55cc74b141 100644 --- a/packages/starlight/CHANGELOG.md +++ b/packages/starlight/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/starlight +## 0.30.1 + +### Patch Changes + +- [#2688](https://github.com/withastro/starlight/pull/2688) [`5c6996c`](https://github.com/withastro/starlight/commit/5c6996cd248e9da735a14e7fcaf638b51f2796bc) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue with autogenerated sidebars when using Starlight with Astro's new Content Layer API where group names would be sluggified. + ## 0.30.0 ### Minor Changes diff --git a/packages/starlight/package.json b/packages/starlight/package.json index 0a00a079648..d5297df79df 100644 --- a/packages/starlight/package.json +++ b/packages/starlight/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/starlight", - "version": "0.30.0", + "version": "0.30.1", "description": "Build beautiful, high-performance documentation websites with Astro", "scripts": { "test": "vitest", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f775c799823..02bd8e1cc6a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -81,7 +81,7 @@ importers: examples/basics: dependencies: '@astrojs/starlight': - specifier: ^0.30.0 + specifier: ^0.30.1 version: link:../../packages/starlight astro: specifier: ^5.0.2 @@ -96,7 +96,7 @@ importers: specifier: ^0.12.1 version: 0.12.1(astro@5.0.2) '@astrojs/starlight': - specifier: ^0.30.0 + specifier: ^0.30.1 version: link:../../packages/starlight '@astrojs/starlight-markdoc': specifier: ^0.2.0 @@ -111,7 +111,7 @@ importers: examples/tailwind: dependencies: '@astrojs/starlight': - specifier: ^0.30.0 + specifier: ^0.30.1 version: link:../../packages/starlight '@astrojs/starlight-tailwind': specifier: ^3.0.0 From a7cf57ef71282343c30e0a6882a4d0268b314990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Sat, 14 Dec 2024 13:43:11 +0100 Subject: [PATCH 14/14] =?UTF-8?q?docs:=20deprecated=20`Astro.props.slug`?= =?UTF-8?q?=20=E2=86=92=20`Astro.props.id`=20(#2685)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> --- docs/src/content/docs/guides/overriding-components.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/content/docs/guides/overriding-components.mdx b/docs/src/content/docs/guides/overriding-components.mdx index edac98b2f1e..dc465589a53 100644 --- a/docs/src/content/docs/guides/overriding-components.mdx +++ b/docs/src/content/docs/guides/overriding-components.mdx @@ -141,7 +141,7 @@ In the following example, a component overriding Starlight's [`Footer`](/referen import type { Props } from '@astrojs/starlight/props'; import Default from '@astrojs/starlight/components/Footer.astro'; -const isHomepage = Astro.props.slug === ''; +const isHomepage = Astro.props.id === ''; --- {