Skip to content

Commit

Permalink
Merge branch 'main' into hd-astro-v5
Browse files Browse the repository at this point in the history
* main:
  i18n(zh-cn): Update `plugins.mdx` (withastro#2638)
  Fix Safari VoiceOver issue (withastro#2633)
  i18n(fr): update `resources/plugins` (withastro#2631)
  i18n(fr): update `guides/overriding-components` & `reference/overrides` (withastro#2627)
  i18n(de): update `reference/overrides.md` (withastro#2625)
  i18n(de): update `guides/overriding-components.mdx` (withastro#2626)
  [ci] format
  i18n(de): update `resources/plugins.mdx` (withastro#2624)
  Update overrides.md (withastro#2632)
  i18n(ko-KR): update `overrides.md` (withastro#2629)
  i18n(ko-KR): update `overriding-components.mdx` (withastro#2628)
  i18n(ko-KR): update `plugins.mdx` (withastro#2630)
  Add my two new plugins to Starlight `resources/plugins.mdx` page (withastro#2595)
  Clarify how to override default components that use multiple slots. (withastro#2386)
  • Loading branch information
HiDeoo committed Nov 26, 2024
2 parents 71109b8 + dc481ae commit 5380aba
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-icons-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Fixes a VoiceOver issue with Safari where the content of a `<script>` element could be read before the sidebar content.
17 changes: 17 additions & 0 deletions docs/src/content/docs/de/guides/overriding-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ Beim Rendern einer integrierten Komponente innerhalb einer benutzerdefinierten K
- Verbreite `Astro.props` darin. Dadurch wird sichergestellt, dass es alle Daten erhält, die es zum Rendern benötigt.
- Füge einen [`<slot />`](https://docs.astro.build/de/core-concepts/astro-components/#slots) innerhalb der Standardkomponente hinzu. Dadurch wird sichergestellt, dass Astro weiß, wo die Komponente gerendert werden muss, wenn der Komponente untergeordnete Elemente übergeben werden.

Wenn du die Komponenten [`PageFrame`](/de/reference/overrides/#pageframe) oder [`TwoColumnContent`](/de/reference/overrides/#twocolumncontent) wiederverwendst, die [benannte Slots](https://docs.astro.build/de/basics/astro-components/#benannte-slots) enthalten, musst du auch diese Slots [übertragen](https://docs.astro.build/de/basics/astro-components/#slots-weitergeben).

Das folgende Beispiel zeigt eine benutzerdefinierte Komponente, die die Komponente `TwoColumnContent` wiederverwendet. Diese integrierte Komponente enthält einen zusätzlichen benannten Slot, nämlich `right-sidebar`, welcher übertragen werden muss:

```astro {9}
---
// src/components/CustomContent.astro
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/TwoColumnContent.astro';
---
<Default {...Astro.props}>
<slot />
<slot name="right-sidebar" slot="right-sidebar" />
</Default>
```

## Seitendaten verwenden

Beim Überschreiben einer Starlight-Komponente erhält deine benutzerdefinierte Implementierung ein Standardobjekt `Astro.props`, das alle Daten für die aktuelle Seite enthält.
Expand Down
6 changes: 4 additions & 2 deletions docs/src/content/docs/de/reference/overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ Wenn möglich, bevorzuge das Überschreiben einer Komponente auf einer niedriger

#### `PageFrame`

**Standardkomponente:** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**Standardkomponente:** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**Benannte Slots:** `header`, `sidebar`

Diese Layout-Komponente beinhaltet den größten Teil des Seiteninhalts.
Die Standardimplementierung konfiguriert das Kopfzeilen-Seitennavigation-Haupt-Layout und beinhaltet `header` und `sidebar` benannte Slots zusammen mit einem Standard-Slot für den Hauptinhalt.
Expand All @@ -211,7 +212,8 @@ Diese Komponente wird innerhalb von [`<PageFrame>`](#pageframe) gerendert und is

#### `TwoColumnContent`

**Standardkomponente:** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**Standardkomponente:** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**Benannter Slot:** `right-sidebar`

Dies ist die Layout-Komponente, welche die Hauptinhaltsspalte und die rechte Seitenleiste (Inhaltsverzeichnis) beinhaltet.
Die Standardimplementierung behandelt den Wechsel zwischen einem einspaltigen Layout mit kleinem Sichtfeld und einem zweispaltigen Layout mit größerem Sichtfeld.
Expand Down
10 changes: 10 additions & 0 deletions docs/src/content/docs/de/resources/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ Erweitere deine Seite mit offiziellen Plugins, die vom Starlight-Team unterstüt
title="starlight-sidebar-topics-dropdown"
description="Teile deine Dokumentseite in mehrere Unterseiten auf und wechsle zwischen ihnen mit einem Dropdown-Menü in der Seitenleiste."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-cooler-credit"
title="starlight-cooler-credit"
description="Füge einen netten Verweis auf Starlight oder Astro am Ende des Inhaltsverzeichnisses ein."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-contributor-list"
title="starlight-contributor-list"
description="Zeigt eine Liste aller Mitwirkenden an deinem Projekt an."
/>
</CardGrid>

### Community-Themes
Expand Down
17 changes: 17 additions & 0 deletions docs/src/content/docs/fr/guides/overriding-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ Lorsque vous affichez un composant intégré dans un composant personnalisé :
- Décomposez `Astro.props` dans celui-ci. Cela permet de s'assurer qu'il reçoit toutes les données dont il a besoin pour être affiché.
- Ajoutez un élément [`<slot />`](https://docs.astro.build/fr/core-concepts/astro-components/#les-emplacements-slots) à l'intérieur du composant par défaut. Cela permet de s'assurer que si le composant reçoit des éléments enfants, Astro sait où les afficher.

Si vous réutilisez les composants [`PageFrame`](/fr/reference/overrides/#pageframe) ou [`TwoColumnContent`](/fr/reference/overrides/#twocolumncontent) qui contiennent des [emplacements (slots) nommés](https://docs.astro.build/fr/basics/astro-components/#les-emplacements-slots-nomm%C3%A9s), vous devez également [transférer](https://docs.astro.build/fr/basics/astro-components/#transf%C3%A9rer-les-emplacements) ces emplacements.

L'exemple ci-dessous montre un composant personnalisé qui réutilise le composant `TwoColumnContent` qui contient un emplacement supplémentaire nommé `right-sidebar` qui doit être transféré :
```astro {9}
---
// src/components/CustomContent.astro
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/TwoColumnContent.astro';
---
<Default {...Astro.props}>
<slot />
<slot name="right-sidebar" slot="right-sidebar" />
</Default>
```
## Utiliser les données de la page
Lorsque vous redéfinissez un composant de Starlight, votre implémentation personnalisée reçoit un objet `Astro.props` standard contenant toutes les données de la page courante.
Expand Down
6 changes: 4 additions & 2 deletions docs/src/content/docs/fr/reference/overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ Lorsque cela est possible, préférez redéfinir un composant de plus bas niveau

#### `PageFrame`

**Composant par défaut :** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**Composant par défaut :** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**Emplacements (slots) nommés :** `header`, `sidebar`

Composant de mise en page contenant la plupart du contenu de la page.
L'implémentation par défaut configure la mise en page de l'en-tête, de la barre latérale et du contenu principal et inclut des emplacements (slots) nommés `header` et `sidebar` en plus de l'emplacement par défaut pour le contenu principal.
Expand All @@ -209,7 +210,8 @@ Composant utilisé à l'intérieur de [`<PageFrame>`](#pageframe) qui est respon

#### `TwoColumnContent`

**Composant par défaut :** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**Composant par défaut :** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**Emplacement (slot) nommé :** `right-sidebar`

Composant de mise en page enveloppant le contenu principal de la page et la barre latérale de droite (table des matières).
L'implémentation par défaut prend en charge le changement entre une mise en page à une seule colonne pour petits écrans et une mise en page à deux colonnes pour écrans plus larges.
Expand Down
16 changes: 13 additions & 3 deletions docs/src/content/docs/fr/resources/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,27 @@ Les [modules d'extension](/fr/reference/plugins/) peuvent personnaliser la confi
<LinkCard
href="https://github.com/Fevol/starlight-site-graph"
title="starlight-site-graph"
description="Ajoutez un graphe interactif de votre site dans la barre latérale de votre page."
description="Ajouter un graphe interactif de votre site dans la barre latérale de votre page."
/>
<LinkCard
href="https://github.com/HiDeoo/starlight-sidebar-topics"
title="starlight-sidebar-topics"
description="Divisez votre documentation en différentes sections, chacune ayant sa propre barre latérale."
description="Diviser votre documentation en différentes sections, chacune ayant sa propre barre latérale."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-sidebar-topics-dropdown"
title="starlight-sidebar-topics-dropdown"
description="Divisez vos pages de documentation en plusieurs sous-pages et passez de l'une à l'autre à l'aide d'un menu déroulant dans la barre latérale."
description="Diviser vos pages de documentation en plusieurs sous-pages et passez de l'une à l'autre à l'aide d'un menu déroulant dans la barre latérale."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-cooler-credit"
title="starlight-cooler-credit"
description="Ajouter de jolis crédits pour Starlight ou Astro en bas de la table des matières."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-contributor-list"
title="starlight-contributor-list"
description="Afficher une liste de tous les contributeurs à votre projet."
/>
</CardGrid>

Expand Down
17 changes: 17 additions & 0 deletions docs/src/content/docs/guides/overriding-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ When rendering a built-in component inside a custom component:
- Spread `Astro.props` into it. This makes sure that it receives all the data it needs to render.
- Add a [`<slot />`](https://docs.astro.build/en/core-concepts/astro-components/#slots) inside the default component. This makes sure that if the component is passed any child elements, Astro knows where to render them.
If you are reusing the [`PageFrame`](/reference/overrides/#pageframe) or [`TwoColumnContent`](/reference/overrides/#twocolumncontent) components which contain [named slots](https://docs.astro.build/en/basics/astro-components/#named-slots), you also need to [transfer](https://docs.astro.build/en/basics/astro-components/#transferring-slots) these slots as well.
The example below shows a custom component that reuses the `TwoColumnContent` component which contains an additional `right-sidebar` named slot that needs to be transferred:
```astro {9}
---
// src/components/CustomContent.astro
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/TwoColumnContent.astro';
---
<Default {...Astro.props}>
<slot />
<slot name="right-sidebar" slot="right-sidebar" />
</Default>
```
## Use page data
When overriding a Starlight component, your custom implementation receives a standard `Astro.props` object containing all the data for the current page.
Expand Down
17 changes: 17 additions & 0 deletions docs/src/content/docs/ko/guides/overriding-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ import Default from '@astrojs/starlight/components/SocialIcons.astro';
- 전개 연산자를 사용하여 내장 컴포넌트에 `Astro.props`의 모든 속성을 전달합니다. 이를 통해, 내장 컴포넌트는 렌더링에 필요한 모든 데이터를 전달받습니다.
- 기본 컴포넌트 내에 [`<slot />`](https://docs.astro.build/ko/core-concepts/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/#슬롯-전송)해야 합니다.

아래 예시는 `TwoColumnContent` 컴포넌트를 재사용하는 사용자 정의 컴포넌트를 보여줍니다. 이 컴포넌트는 `right-sidebar`라는 이름의 추가 슬롯을 포함하여 전송합니다.

```astro {9}
---
// src/components/CustomContent.astro
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/TwoColumnContent.astro';
---
<Default {...Astro.props}>
<slot />
<slot name="right-sidebar" slot="right-sidebar" />
</Default>
```

## 페이지 데이터 사용

Starlight 컴포넌트를 재정의할 때, 사용자 정의 구현은 현재 페이지의 모든 데이터가 포함된 표준 `Astro.props` 객체를 전달받습니다.
Expand Down
6 changes: 4 additions & 2 deletions docs/src/content/docs/ko/reference/overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ Starlight의 구성 옵션을 준수하는 콘텐츠 목차 컴포넌트를 생

#### `PageFrame`

**기본 컴포넌트:** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**기본 컴포넌트:** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**명명된 슬롯:** `header`, `sidebar`

대부분의 페이지 콘텐츠를 감싸는 레이아웃 컴포넌트입니다.
기본적으로 header-sidebar-main 레이아웃을 설정하고 슬롯으로 명명된 `header``sidebar` 및 메인 콘텐츠에 대한 기본 슬롯을 포함합니다.
Expand All @@ -208,7 +209,8 @@ Starlight의 구성 옵션을 준수하는 콘텐츠 목차 컴포넌트를 생

#### `TwoColumnContent`

**기본 컴포넌트:** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**기본 컴포넌트:** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**명명된 슬롯:** `right-sidebar`

메인 콘텐츠 열과 오른쪽 사이드바 (목차)를 감싸는 레이아웃 컴포넌트입니다.
기본적으로 작은 뷰포트에서 하나의 열로 이루어진 레이아웃과 큰 뷰포트에서 두 개의 열로 이루어진 레이아웃 간 전환을 처리합니다.
Expand Down
10 changes: 10 additions & 0 deletions docs/src/content/docs/ko/resources/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ Starlight 팀이 지원하는 공식 플러그인과 Starlight 사용자가 관
title="starlight-sidebar-topics-dropdown"
description="문서 페이지를 여러 개의 하위 페이지로 분할하고 사이드바의 드롭다운 메뉴를 사용하여 하위 페이지 간에 전환할 수 있습니다."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-cooler-credit"
title="starlight-cooler-credit"
description="Starlight 또는 Astro 목차 하단에 멋진 크레딧을 추가하세요."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-contributor-list"
title="starlight-contributor-list"
description="프로젝트의 모든 기여자 목록을 표시합니다."
/>
</CardGrid>

### 커뮤니티 테마
Expand Down
6 changes: 4 additions & 2 deletions docs/src/content/docs/reference/overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ When possible, prefer overriding a lower-level component.

#### `PageFrame`

**Default component:** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**Default component:** [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro)
**Named slots:** `header`, `sidebar`

Layout component wrapped around most of the page content.
The default implementation sets up the header–sidebar–main layout and includes `header` and `sidebar` named slots along with a default slot for the main content.
Expand All @@ -209,7 +210,8 @@ Component rendered inside [`<PageFrame>`](#pageframe) that is responsible for to

#### `TwoColumnContent`

**Default component:** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**Default component:** [`TwoColumnContent.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro)
**Named slot:** `right-sidebar`

Layout component wrapped around the main content column and right sidebar (table of contents).
The default implementation handles the switch between a single-column, small-viewport layout and a two-column, larger-viewport layout.
Expand Down
10 changes: 10 additions & 0 deletions docs/src/content/docs/resources/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ Extend your site with official plugins supported by the Starlight team and commu
title="starlight-sidebar-topics-dropdown"
description="Split your docs page into multiple subpages and switch between them with a dropdown menu in the sidebar."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-cooler-credit"
title="starlight-cooler-credit"
description="Add a nice credit to Starlight or Astro at the bottom of the table of contents."
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-contributor-list"
title="starlight-contributor-list"
description="Display a list of all contributors to your project."
/>
</CardGrid>

### Community themes
Expand Down
10 changes: 10 additions & 0 deletions docs/src/content/docs/zh-cn/resources/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ sidebar:
title="starlight-sidebar-topics-dropdown"
description="将你的文档页面拆分为多个子页面,并使用侧边栏中的下拉菜单在它们之间切换。"
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-cooler-credit"
title="starlight-cooler-credit"
description="为 Starlight 或 Astro 在目录的底部添加一个漂亮的 credit。"
/>
<LinkCard
href="https://github.com/trueberryless-org/starlight-contributor-list"
title="starlight-contributor-list"
description="在你项目中显示一个包含所有贡献者的列表。"
/>
</CardGrid>

### 社区主题
Expand Down
9 changes: 7 additions & 2 deletions packages/starlight/components/SidebarPersister.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
- On smaller viewports, restoring state is skipped as the sidebar is collapsed inside a menu.
- The state is parsed from session storage and restored.
- This is a progressive enhancement, so any errors are swallowed silently.
The `aria-hidden` attribute on script tags is used to prevent a Safari/VoiceOver bug where the
script is read out loud due to them being inside a container with `display: contents`.
@see https://bugs.webkit.org/show_bug.cgi?id=283645
@see https://github.com/withastro/starlight/pull/2633
*/
import type { Props } from '../props';
Expand All @@ -28,7 +33,7 @@ declare global {
---

<sl-sidebar-state-persist data-hash={hash}>
<script is:inline>
<script is:inline aria-hidden="true">
(() => {
try {
if (!matchMedia('(min-width: 50em)').matches) return;
Expand All @@ -55,7 +60,7 @@ declare global {

<slot />

<script is:inline>
<script is:inline aria-hidden="true">
(() => {
const scroller = document.getElementById('starlight__sidebar');
if (!window._starlightScrollRestore || !scroller) return;
Expand Down

0 comments on commit 5380aba

Please sign in to comment.