diff --git a/.changeset/great-plums-study.md b/.changeset/great-plums-study.md new file mode 100644 index 00000000000..17765e18097 --- /dev/null +++ b/.changeset/great-plums-study.md @@ -0,0 +1,9 @@ +--- +'@astrojs/starlight': minor +--- + +Makes sidebar entry parsing stricter in Starlight config + +**⚠️ Potentially breaking change:** Previously Starlight would accept a sidebar entry that matched one of its expected shapes, even if it included additional properties. For example, including both `link` and `items` was considered valid, with `items` being ignored. Now, it is an error to include more than one of `link`, `items`, or `autogenerate` in a sidebar entry. + +If you see errors after updating, look for sidebar entries in the Starlight configuration in `astro.config.mjs` that include too many keys and remove the one that was previously ignored. diff --git a/.changeset/new-trains-complain.md b/.changeset/new-trains-complain.md new file mode 100644 index 00000000000..cf35248953f --- /dev/null +++ b/.changeset/new-trains-complain.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Updates the Ukrainian UI translations diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b7a5b947d9..90a1474ded9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,11 +14,32 @@ concurrency: env: NODE_VERSION: 18 + ASTRO_TELEMETRY_DISABLED: true jobs: + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + docs: ${{ steps.filter.outputs.docs }} + packages: ${{ steps.filter.outputs.packages }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + docs: + - 'docs/**' + packages: + - 'packages/**' + unit-test: name: Run unit tests - runs-on: ubuntu-20.04 + needs: changes + if: ${{ needs.changes.outputs.packages == 'true' }} + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v3 @@ -31,8 +52,14 @@ jobs: run: pnpm -r test:coverage e2e-test: - name: Run E2E tests - runs-on: ubuntu-20.04 + name: 'Run E2E tests (${{ matrix.os }})' + needs: changes + if: ${{ needs.changes.outputs.packages == 'true' }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v3 @@ -46,7 +73,7 @@ jobs: type-check: name: Run type checks - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v3 @@ -63,7 +90,7 @@ jobs: pa11y: name: Check for accessibility issues - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -107,7 +134,9 @@ jobs: links: name: Check for broken links - runs-on: ubuntu-20.04 + needs: changes + if: ${{ needs.changes.outputs.docs == 'true' }} + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index d825d3a73cc..035a7ad7a24 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,9 @@ pnpm-debug.log* # Vitest __coverage__/ +# Playwright +test-results/ + # Vercel output .vercel diff --git a/docs/package.json b/docs/package.json index c0eacd497bb..53420880575 100644 --- a/docs/package.json +++ b/docs/package.json @@ -16,7 +16,7 @@ "dependencies": { "@astro-community/astro-embed-youtube": "^0.5.2", "@astrojs/starlight": "workspace:*", - "@lunariajs/core": "^0.1.0", + "@lunariajs/core": "^0.1.1", "@types/culori": "^2.0.0", "astro": "^4.10.2", "culori": "^3.2.0", diff --git a/docs/src/assets/showcase/docs.orama.com.png b/docs/src/assets/showcase/docs.orama.com.png new file mode 100644 index 00000000000..e4fe6374617 Binary files /dev/null and b/docs/src/assets/showcase/docs.orama.com.png differ diff --git a/docs/src/assets/showcase/ee.qqv.com.au.png b/docs/src/assets/showcase/ee.qqv.com.au.png index e8654b743a3..2dff3d94bcf 100644 Binary files a/docs/src/assets/showcase/ee.qqv.com.au.png and b/docs/src/assets/showcase/ee.qqv.com.au.png differ diff --git a/docs/src/assets/showcase/tutorialkit.dev.png b/docs/src/assets/showcase/tutorialkit.dev.png new file mode 100644 index 00000000000..a69751b3ed1 Binary files /dev/null and b/docs/src/assets/showcase/tutorialkit.dev.png differ diff --git a/docs/src/assets/showcase/www.devhealthos.com.png b/docs/src/assets/showcase/www.devhealthos.com.png new file mode 100644 index 00000000000..d9318fab008 Binary files /dev/null and b/docs/src/assets/showcase/www.devhealthos.com.png differ diff --git a/docs/src/components/showcase-sites.astro b/docs/src/components/showcase-sites.astro index bea2ee7e348..a6e82032619 100644 --- a/docs/src/components/showcase-sites.astro +++ b/docs/src/components/showcase-sites.astro @@ -126,4 +126,11 @@ import FluidGrid from './fluid-grid.astro'; + + + diff --git a/docs/src/content/docs/es/guides/site-search.mdx b/docs/src/content/docs/es/guides/site-search.mdx index a1baec1f492..a100172a2d8 100644 --- a/docs/src/content/docs/es/guides/site-search.mdx +++ b/docs/src/content/docs/es/guides/site-search.mdx @@ -142,6 +142,7 @@ Para agregar traducciones de la UI al modal en otros idiomas, usa el [sistema de "docsearch.searchBox.resetButtonAriaLabel": "Clear the query", "docsearch.searchBox.cancelButtonText": "Cancel", "docsearch.searchBox.cancelButtonAriaLabel": "Cancel", + "docsearch.searchBox.searchInputLabel": "Search", "docsearch.startScreen.recentSearchesTitle": "Recent", "docsearch.startScreen.noRecentSearchesText": "No recent searches", diff --git a/docs/src/content/docs/es/resources/plugins.mdx b/docs/src/content/docs/es/resources/plugins.mdx index d4d6ec4cff1..5f0f1fff6f9 100644 --- a/docs/src/content/docs/es/resources/plugins.mdx +++ b/docs/src/content/docs/es/resources/plugins.mdx @@ -73,6 +73,16 @@ Amplia tu sitio con un plugins oficiales respaldados por el equipo de Starlight title="starlight-view-modes" description="Agrega diferentes capacidades de modo de vista a tu sitio de documentación." /> + + ## Herramientas e integraciones de la comunidad diff --git a/docs/src/content/docs/fr/guides/site-search.mdx b/docs/src/content/docs/fr/guides/site-search.mdx index 89bc99ce4d0..54d171cd60a 100644 --- a/docs/src/content/docs/fr/guides/site-search.mdx +++ b/docs/src/content/docs/fr/guides/site-search.mdx @@ -142,6 +142,7 @@ Ajoutez des traductions de l'interface utilisateur de la modale pour votre langu "docsearch.searchBox.resetButtonAriaLabel": "Clear the query", "docsearch.searchBox.cancelButtonText": "Cancel", "docsearch.searchBox.cancelButtonAriaLabel": "Cancel", + "docsearch.searchBox.searchInputLabel": "Search", "docsearch.startScreen.recentSearchesTitle": "Recent", "docsearch.startScreen.noRecentSearchesText": "No recent searches", diff --git a/docs/src/content/docs/fr/resources/community-content.mdx b/docs/src/content/docs/fr/resources/community-content.mdx index 59bff3f0c2a..37d0de9ad7c 100644 --- a/docs/src/content/docs/fr/resources/community-content.mdx +++ b/docs/src/content/docs/fr/resources/community-content.mdx @@ -146,5 +146,11 @@ import YouTubeGrid from '~/components/youtube-grid.astro'; description: "Dans cette vidéo, je passe en revue ce qui rend Starlight si cool et pourquoi vous voudriez l'essayer avec votre prochain projet.", }, + { + href: 'https://www.youtube.com/watch?v=Q1E4Gkt63ko', + title: 'Astro Starlight et emoji-blast avec Chris Swithinbank', + description: + "Chris, le créateur du thème de documentation Starlight pour Astro, m'aide à le configurer pour le nouveau site web d'emoji-blast. 🌟 🎇", + }, ]} /> diff --git a/docs/src/content/docs/fr/resources/plugins.mdx b/docs/src/content/docs/fr/resources/plugins.mdx index f240c5498f7..acdc330e7d4 100644 --- a/docs/src/content/docs/fr/resources/plugins.mdx +++ b/docs/src/content/docs/fr/resources/plugins.mdx @@ -73,6 +73,16 @@ Les [modules d'extension](/fr/reference/plugins/) peuvent personnaliser la confi title="starlight-view-modes" description="Ajouter différents modes d'affichage à votre site web de documentation." /> + + ## Outils et intégrations communautaires diff --git a/docs/src/content/docs/ko/guides/site-search.mdx b/docs/src/content/docs/ko/guides/site-search.mdx index 63d6180ba15..4e8dfd85e7e 100644 --- a/docs/src/content/docs/ko/guides/site-search.mdx +++ b/docs/src/content/docs/ko/guides/site-search.mdx @@ -142,6 +142,7 @@ Starlight에 내장된 [국제화 시스템](/ko/guides/i18n/#starlight-ui-번 "docsearch.searchBox.resetButtonAriaLabel": "Clear the query", "docsearch.searchBox.cancelButtonText": "Cancel", "docsearch.searchBox.cancelButtonAriaLabel": "Cancel", + "docsearch.searchBox.searchInputLabel": "Search", "docsearch.startScreen.recentSearchesTitle": "Recent", "docsearch.startScreen.noRecentSearchesText": "No recent searches", diff --git a/docs/src/content/docs/ko/resources/community-content.mdx b/docs/src/content/docs/ko/resources/community-content.mdx index 24a627ceaf9..57efb505898 100644 --- a/docs/src/content/docs/ko/resources/community-content.mdx +++ b/docs/src/content/docs/ko/resources/community-content.mdx @@ -143,5 +143,11 @@ import YouTubeGrid from '~/components/youtube-grid.astro'; description: '이 비디오에서는 Starlight가 왜 그렇게 멋진지, 그리고 왜 다음 프로젝트에서 Starlight를 사용해 보고 싶은지 설명합니다.', }, + { + href: 'https://www.youtube.com/watch?v=Q1E4Gkt63ko', + title: 'Astro Starlight와 emoji-blast - Chris Swithinbank', + description: + '프레임워크 온 프레임워크인 Astro Starlight의 창시자 Chris가 새로운 emoji-blast 웹사이트를 설정하는 과정을 안내합니다. 🌟 🎇', + }, ]} /> diff --git a/docs/src/content/docs/ko/resources/plugins.mdx b/docs/src/content/docs/ko/resources/plugins.mdx index bbab712531f..7afa62ecf0b 100644 --- a/docs/src/content/docs/ko/resources/plugins.mdx +++ b/docs/src/content/docs/ko/resources/plugins.mdx @@ -73,7 +73,16 @@ Starlight 팀이 지원하는 공식 플러그인과 Starlight 사용자가 관 title="starlight-view-modes" description="문서 웹사이트에 다양한 보기 모드 기능을 추가하세요." /> - + + ## 커뮤니티 도구 및 통합 diff --git a/docs/src/content/docs/pt-br/guides/components.mdx b/docs/src/content/docs/pt-br/guides/components.mdx index 1159d264a01..e372139c1e2 100644 --- a/docs/src/content/docs/pt-br/guides/components.mdx +++ b/docs/src/content/docs/pt-br/guides/components.mdx @@ -418,6 +418,36 @@ import { Steps } from '@astrojs/starlight/components'; +### Emblemas + +import { Badge } from '@astrojs/starlight/components'; + +Use o componente `` para exibir pequenas informações, como status ou etiquetas. + +Passe o conteúdo que deseja exibir para o atributo `text` do componente ``. + +Por padrão, o emblema usará a cor de destaque do tema do seu site. Para usar uma cor de emblema incorporada, defina o atributo `variant` com um dos seguintes valores: `note` (azul), `tip` (roxo), `danger` (vermelho), `caution` (laranja) ou `success` (verde). + +O atributo `size` (padrão: `small`) controla o tamanho do texto do emblema. As opções `medium` e `large` também estão disponíveis para exibir um emblema maior. + +Para personalização adicional, use outros atributos da tag `` como `class` ou `style` com CSS personalizado. + +```mdx title="src/content/docs/example.mdx" +import { Badge } from '@astrojs/starlight/components'; + + + + + +``` + +O código acima gera o seguinte conteúdo na página: + + + + + + ### Ícone import { Icon } from '@astrojs/starlight/components'; @@ -425,7 +455,8 @@ import IconsList from '~/components/icons-list.astro'; Starlight providencia um conjunto comum de ícones que você pode mostrar em seu conteúdo utilizando o componente ``. -Cada `` requer um [`name`](#todos-os-ícones) e pode opcionalmente incluir um atributo `label`, `size` e `color`. +Cada `` requer um [`name`](#todos-os-ícones) e pode opcionalmente incluir um atributo `label` para prover contexto aos leitores de tela. +Os atributos `size` e `color` podem ser utilizados para ajustar a aparência do ícone usando unidades CSS e valores de cores. ```mdx # src/content/docs/exemplo.mdx @@ -433,11 +464,13 @@ Cada `` requer um [`name`](#todos-os-ícones) e pode opcionalmente incluir import { Icon } from '@astrojs/starlight/components'; + ``` O código acima gera o seguinte na página: + #### Todos os ícones diff --git a/docs/src/content/docs/pt-br/resources/plugins.mdx b/docs/src/content/docs/pt-br/resources/plugins.mdx index 3b2c5c01de3..16d027c2c42 100644 --- a/docs/src/content/docs/pt-br/resources/plugins.mdx +++ b/docs/src/content/docs/pt-br/resources/plugins.mdx @@ -58,6 +58,31 @@ Estenda o seu site com os plugins oficiais suportados pelo time Starlight e plug title="starlight-ghostcms" description="Adicione suas postagens do blog GhostCMS ao lado de suas páginas Starlight." /> + + + + + ## Ferramentas da comunidade e integrações @@ -85,6 +110,16 @@ Essas ferramentas da comunidade e integrações podem ser usadas para adicionar + + diff --git a/docs/src/content/docs/pt-br/resources/showcase.mdx b/docs/src/content/docs/pt-br/resources/showcase.mdx index c68c09c1cdf..5a6c3b103db 100644 --- a/docs/src/content/docs/pt-br/resources/showcase.mdx +++ b/docs/src/content/docs/pt-br/resources/showcase.mdx @@ -7,7 +7,7 @@ sidebar: :::tip[Adicione o seu!] Você construiu um site com Starlight? -Abra um PR adicionando um link para esta página! +[Abra um PR](https://github.com/withastro/starlight/blob/main/CONTRIBUTING.md#showcase) adicionando um link para esta página! ::: ## Sites diff --git a/docs/src/content/docs/resources/community-content.mdx b/docs/src/content/docs/resources/community-content.mdx index 164397cd008..6b898acb4ab 100644 --- a/docs/src/content/docs/resources/community-content.mdx +++ b/docs/src/content/docs/resources/community-content.mdx @@ -141,5 +141,11 @@ import YouTubeGrid from '~/components/youtube-grid.astro'; description: 'In this video I go over what makes Starlight so cool and why you may want to give it a try on your next project.', }, + { + href: 'https://www.youtube.com/watch?v=Q1E4Gkt63ko', + title: 'Astro Starlight and emoji-blast with Chris Swithinbank', + description: + "Wherein Chris, the creator of Astro's Starlight framework-on-a-framework, walks me through setting it up for a new emoji-blast website. 🌟 🎇", + }, ]} /> diff --git a/docs/src/content/docs/resources/plugins.mdx b/docs/src/content/docs/resources/plugins.mdx index ffd4c234d8d..3848869ae6b 100644 --- a/docs/src/content/docs/resources/plugins.mdx +++ b/docs/src/content/docs/resources/plugins.mdx @@ -73,7 +73,16 @@ Extend your site with official plugins supported by the Starlight team and commu title="starlight-view-modes" description="Add different view mode capabilities to your documentation website." /> - + + ## Community tools and integrations diff --git a/docs/src/content/docs/ru/guides/components.mdx b/docs/src/content/docs/ru/guides/components.mdx index 9962c35ec0a..c317bba2823 100644 --- a/docs/src/content/docs/ru/guides/components.mdx +++ b/docs/src/content/docs/ru/guides/components.mdx @@ -418,6 +418,36 @@ import { Steps } from '@astrojs/starlight/components'; +### Значки + +import { Badge } from '@astrojs/starlight/components'; + +Используйте компонент `` для отображения небольших фрагментов информации, таких как статус или ярлыки. + +Передайте содержимое, которое вы хотите отобразить, в атрибут `text` компонента ``. + +По умолчанию значок будет использовать акцентный цвет темы вашего сайта. Чтобы использовать встроенный цвет значка, установите атрибут `variant` в одно из следующих значений: `note` (синий), `tip` (фиолетовый), `danger` (красный), `caution` (оранжевый), или `success` (зелёный). + +Атрибут `size` (по умолчанию: `small`) управляет размером текста значка. Для отображения значка большего размера также доступны опции `medium` и `large`. + +Для дальнейшей настройки используйте другие атрибуты ``, такие как `class` или `style`, с помощью пользовательского CSS. + +```mdx title="src/content/docs/example.mdx" +import { Badge } from '@astrojs/starlight/components'; + + + + + +``` + +Вышеуказанный код сформирует следующий HTML: + + + + + + ### Иконки import { Icon } from '@astrojs/starlight/components'; diff --git a/docs/src/content/docs/ru/guides/i18n.mdx b/docs/src/content/docs/ru/guides/i18n.mdx index 3a2e78adcfc..c96bb9ff416 100644 --- a/docs/src/content/docs/ru/guides/i18n.mdx +++ b/docs/src/content/docs/ru/guides/i18n.mdx @@ -67,6 +67,8 @@ Starlight обеспечивает встроенную поддержку мн +Для более продвинутых сценариев использования i18n Starlight также поддерживает настройку интернационализации с помощью [опции `i18n` Astro](https://docs.astro.build/ru/guides/internationalization/#%D0%BD%D0%B0%D1%81%D1%82%D1%80%D0%BE%D0%B9%D0%BA%D0%B0-i18n-%D0%BC%D0%B0%D1%80%D1%88%D1%80%D1%83%D1%82%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8). + ### Использование корневой локали Вы можете использовать «корневую» локаль для отображения языка без префикса i18n в его пути. Например, если русский является вашей корневой локалью, путь к странице на русском языке будет выглядеть как `/about` вместо `/ru/about`. @@ -273,4 +275,18 @@ export const collections = { }; ``` -Дополнительную информацию о схемах коллекции контента см. в разделе [Определение схемы коллекции](https://docs.astro.build/ru/guides/content-collections/#defining-a-collection-schema) в документации Astro. +Дополнительную информацию о схемах коллекции контента см. в разделе [Определение схемы коллекции](https://docs.astro.build/ru/guides/content-collections/#%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D1%81%D1%85%D0%B5%D0%BC%D1%8B-%D0%BA%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D0%B8%D0%B8) в документации Astro. + +## Доступ к текущей локали + +Вы можете использовать [`Astro.currentLocale`](https://docs.astro.build/ru/reference/api-reference/#astrocurrentlocale) для получения текущей локали в компонентах `.astro`. + +Следующий пример считывает текущую локаль и использует её для создания ссылки на страницу о сайте на текущем языке: + +```astro +--- +// src/components/AboutLink.astro +--- + +О сайте +``` diff --git a/docs/src/content/docs/ru/guides/sidebar.mdx b/docs/src/content/docs/ru/guides/sidebar.mdx index 12fb90d2b25..5ba6298a1c1 100644 --- a/docs/src/content/docs/ru/guides/sidebar.mdx +++ b/docs/src/content/docs/ru/guides/sidebar.mdx @@ -294,12 +294,14 @@ starlight({ ]} /> -### Варианты значков +### Варианты значков и индивидуальная стилизация -Настройте стиль значка, используя объект со свойствами `text` и `variant`. +Настройте стиль значка, используя объект со свойствами `text`, `variant` и `class`. `text` представляет содержимое для отображения (например, «Новое»). -Переопределите стиль `default`, который использует акцентный цвет вашего сайта, установив свойство `variant` в одно из следующих значений: `note`, `tip`, `danger`, `caution` или `success`. +По умолчанию значок будет использовать акцентный цвет вашего сайта. Чтобы использовать встроенный стиль значка, установите для свойства `variant` одно из следующих значений: `note`, `tip`, `danger`, `caution` или `success`. + +Кроме того, можно создать собственный стиль значка, задав свойству `class` имя класса CSS. ```js {10} starlight({ diff --git a/docs/src/content/docs/ru/guides/site-search.mdx b/docs/src/content/docs/ru/guides/site-search.mdx index 91ab3612156..0769e6a9e27 100644 --- a/docs/src/content/docs/ru/guides/site-search.mdx +++ b/docs/src/content/docs/ru/guides/site-search.mdx @@ -142,6 +142,7 @@ title: Частично проиндексированная страница "docsearch.searchBox.resetButtonAriaLabel": "Clear the query", "docsearch.searchBox.cancelButtonText": "Cancel", "docsearch.searchBox.cancelButtonAriaLabel": "Cancel", + "docsearch.searchBox.searchInputLabel": "Search", "docsearch.startScreen.recentSearchesTitle": "Recent", "docsearch.startScreen.noRecentSearchesText": "No recent searches", diff --git a/docs/src/content/docs/ru/reference/configuration.mdx b/docs/src/content/docs/ru/reference/configuration.mdx index 397c06d84f5..cd254cb5bae 100644 --- a/docs/src/content/docs/ru/reference/configuration.mdx +++ b/docs/src/content/docs/ru/reference/configuration.mdx @@ -214,7 +214,8 @@ type SidebarItem = { ```ts interface BadgeConfig { text: string; - variant: 'note' | 'tip' | 'caution' | 'danger' | 'success' | 'default'; + variant?: 'note' | 'tip' | 'caution' | 'danger' | 'success' | 'default'; + class?: string; } ``` @@ -567,3 +568,13 @@ starlight({ ``` См. [Справочник по плагинам](/ru/reference/plugins/) для получения подробной информации о создании собственных плагинов. + +### `credits` + +Включите отображение ссылки «Сделано с помощью Starlight» в подвале вашего сайта. + +```js +starlight({ + credits: true, +}); +``` diff --git a/docs/src/content/docs/ru/reference/frontmatter.md b/docs/src/content/docs/ru/reference/frontmatter.md index ac56d6239a3..30027b51711 100644 --- a/docs/src/content/docs/ru/reference/frontmatter.md +++ b/docs/src/content/docs/ru/reference/frontmatter.md @@ -355,7 +355,7 @@ sidebar: Добавьте значок на страницу в боковой панели, если она отображается в автогенерируемой группе ссылок. При использовании строки значок будет отображаться с акцентным цветом по умолчанию. -В качестве опции передайте объект [`BadgeConfig`](/ru/reference/configuration/#badgeconfig) с полями `text` и `variant` для настройки значка. +В качестве опции передайте объект [`BadgeConfig`](/ru/reference/configuration/#badgeconfig) с полями `text`, `variant` и `class` для настройки значка. ```md --- diff --git a/docs/src/content/docs/ru/resources/community-content.mdx b/docs/src/content/docs/ru/resources/community-content.mdx index 8091227f6c6..a0aa2cb83e3 100644 --- a/docs/src/content/docs/ru/resources/community-content.mdx +++ b/docs/src/content/docs/ru/resources/community-content.mdx @@ -138,5 +138,18 @@ import YouTubeGrid from '~/components/youtube-grid.astro'; description: 'Установите Starlight в подкаталоге проекта сайта на Next.js', }, + { + href: 'https://www.youtube.com/watch?v=5pq80drDrNs', + title: + 'Я воссоздал документы Shadcn за 30 минут с помощью этого удивительного инструмента', + description: + 'В этом видео я рассказываю о том, что делает Starlight таким крутым и почему вы можете попробовать его в своем следующем проекте.', + }, + { + href: 'https://www.youtube.com/watch?v=Q1E4Gkt63ko', + title: 'Astro Starlight и взрыв эмоций с Крисом Свитинбанком', + description: + 'В этой статье Крис, создатель Starlight, рассказывает о том, как настроить этот фреймворк для нового сайта, посвящённого эмодзи. 🌟 🎇', + }, ]} /> diff --git a/docs/src/content/docs/ru/resources/plugins.mdx b/docs/src/content/docs/ru/resources/plugins.mdx index 05649adc407..704d63868dd 100644 --- a/docs/src/content/docs/ru/resources/plugins.mdx +++ b/docs/src/content/docs/ru/resources/plugins.mdx @@ -64,9 +64,24 @@ sidebar: description="Добавление возможности масштабирования к изображениям вашей документации." /> + + + diff --git a/docs/src/content/docs/zh-cn/guides/site-search.mdx b/docs/src/content/docs/zh-cn/guides/site-search.mdx index 8b3acf17e74..2350db36103 100644 --- a/docs/src/content/docs/zh-cn/guides/site-search.mdx +++ b/docs/src/content/docs/zh-cn/guides/site-search.mdx @@ -142,6 +142,7 @@ DocSearch 默认只提供了英语 UI 文本。 "docsearch.searchBox.resetButtonAriaLabel": "Clear the query", "docsearch.searchBox.cancelButtonText": "Cancel", "docsearch.searchBox.cancelButtonAriaLabel": "Cancel", + "docsearch.searchBox.searchInputLabel": "Search", "docsearch.startScreen.recentSearchesTitle": "Recent", "docsearch.startScreen.noRecentSearchesText": "No recent searches", diff --git a/docs/src/content/docs/zh-cn/resources/community-content.mdx b/docs/src/content/docs/zh-cn/resources/community-content.mdx index 7e09c5e87d6..d931f9b5d5e 100644 --- a/docs/src/content/docs/zh-cn/resources/community-content.mdx +++ b/docs/src/content/docs/zh-cn/resources/community-content.mdx @@ -140,5 +140,12 @@ import YouTubeGrid from '~/components/youtube-grid.astro'; description: '在这个视频中,我将介绍 Starlight 的酷炫之处以及为什么你可能想在下一个项目中尝试它。', }, + { + href: 'https://www.youtube.com/watch?v=Q1E4Gkt63ko', + title: + '与 Chris Swithinbank 一起试试联动 Astro Starlight 和 emoji-blast ', + description: + 'Astro Starlight 框架的开发者 Chris 引导我完成了一个全新的 emoji-blast 网站。 🌟 🎇', + }, ]} /> diff --git a/docs/src/content/docs/zh-cn/resources/plugins.mdx b/docs/src/content/docs/zh-cn/resources/plugins.mdx index e2b42e10636..5c6ca943687 100644 --- a/docs/src/content/docs/zh-cn/resources/plugins.mdx +++ b/docs/src/content/docs/zh-cn/resources/plugins.mdx @@ -72,6 +72,16 @@ sidebar: title="starlight-view-modes" description="为你的文档网站添加不同的视图模式。" /> + + ## 社区工具和集成 diff --git a/examples/basics/package.json b/examples/basics/package.json index 003b4bf7c63..4d0586b39f2 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/starlight": "^0.24.2", + "@astrojs/starlight": "^0.24.5", "astro": "^4.10.2", "sharp": "^0.32.5" } diff --git a/examples/tailwind/package.json b/examples/tailwind/package.json index 25d34a900d6..8c2691e44be 100644 --- a/examples/tailwind/package.json +++ b/examples/tailwind/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/starlight": "^0.24.2", + "@astrojs/starlight": "^0.24.5", "@astrojs/starlight-tailwind": "^2.0.3", "@astrojs/tailwind": "^5.1.0", "astro": "^4.10.2", diff --git a/packages/starlight/CHANGELOG.md b/packages/starlight/CHANGELOG.md index b2528c32cc4..5f5a100c6f4 100644 --- a/packages/starlight/CHANGELOG.md +++ b/packages/starlight/CHANGELOG.md @@ -1,5 +1,35 @@ # @astrojs/starlight +## 0.24.5 + +### Patch Changes + +- [#2062](https://github.com/withastro/starlight/pull/2062) [`5ac0ac6`](https://github.com/withastro/starlight/commit/5ac0ac6614e3c45d810a1594a2009d3febfa2793) Thanks [@evadecker](https://github.com/evadecker)! - Increase theme and language select inline padding + +- [#2056](https://github.com/withastro/starlight/pull/2056) [`87e9ad0`](https://github.com/withastro/starlight/commit/87e9ad029c9730fca8df66e35828b57cd0872a61) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue preventing remark plugins injected by Starlight plugins to handle Markdown text and leaf directives. + +- [#2063](https://github.com/withastro/starlight/pull/2063) [`3ee1a94`](https://github.com/withastro/starlight/commit/3ee1a9404db25f5776a3c1ecd248614f64db46ae) Thanks [@delucis](https://github.com/delucis)! - Translate `fileTree.directory` and `aside.*` UI string into Norwegian (Bokmål). + +- [#2054](https://github.com/withastro/starlight/pull/2054) [`dbfd3ee`](https://github.com/withastro/starlight/commit/dbfd3eeccacb5f5b77d75213dac3b30dc0be6deb) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue when using the `` component in a custom page with a user-defined `srcDir` configuration. + +## 0.24.4 + +### Patch Changes + +- [#2038](https://github.com/withastro/starlight/pull/2038) [`87f3f92`](https://github.com/withastro/starlight/commit/87f3f925be6f9897b71b09a3041ec6d54be483b2) Thanks [@dragomano](https://github.com/dragomano)! - Updates Russian UI translations + +- [#2043](https://github.com/withastro/starlight/pull/2043) [`53f4cd4`](https://github.com/withastro/starlight/commit/53f4cd443cf31b6135ff16eb74b5f26ee93ee2d5) Thanks [@playmr365](https://github.com/playmr365)! - Updates Czech UI translations + +- [#2041](https://github.com/withastro/starlight/pull/2041) [`8af5a60`](https://github.com/withastro/starlight/commit/8af5a60ab14f4dae7f5a5e4ee535ae927273368b) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes `` numbering bug caused by Chrome v126 CSS counter rewrite + +## 0.24.3 + +### Patch Changes + +- [#2028](https://github.com/withastro/starlight/pull/2028) [`af81ad3`](https://github.com/withastro/starlight/commit/af81ad38fd26c375c0372718fd3e152b7f1a0fa6) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a search dialog height issue in Safari. + +- [#2022](https://github.com/withastro/starlight/pull/2022) [`80f82b1`](https://github.com/withastro/starlight/commit/80f82b15afae1366676e0c25e674210a19606df5) Thanks [@playmr365](https://github.com/playmr365)! - Updates Czech UI translations + ## 0.24.2 ### Patch Changes diff --git a/packages/starlight/__e2e__/collection-config.test.ts b/packages/starlight/__e2e__/collection-config.test.ts new file mode 100644 index 00000000000..5b26f9dc07a --- /dev/null +++ b/packages/starlight/__e2e__/collection-config.test.ts @@ -0,0 +1,12 @@ +import { expect, testFactory } from './test-utils'; + +const test = await testFactory('./fixtures/custom-src-dir/'); + +test('builds a custom page using the `` component and a custom `srcDir`', async ({ + page, + starlight, +}) => { + await starlight.goto('/custom'); + + await expect(page.getByText('Hello')).toBeVisible(); +}); diff --git a/packages/starlight/__e2e__/fixtures/basics/astro.config.mjs b/packages/starlight/__e2e__/fixtures/basics/astro.config.mjs index 9e96cbad3d1..1279050de74 100644 --- a/packages/starlight/__e2e__/fixtures/basics/astro.config.mjs +++ b/packages/starlight/__e2e__/fixtures/basics/astro.config.mjs @@ -5,6 +5,7 @@ export default defineConfig({ integrations: [ starlight({ title: 'Basics', + pagefind: false, }), ], }); diff --git a/packages/starlight/__e2e__/fixtures/custom-src-dir/astro.config.mjs b/packages/starlight/__e2e__/fixtures/custom-src-dir/astro.config.mjs new file mode 100644 index 00000000000..9e759d9ebc9 --- /dev/null +++ b/packages/starlight/__e2e__/fixtures/custom-src-dir/astro.config.mjs @@ -0,0 +1,12 @@ +import starlight from '@astrojs/starlight'; +import { defineConfig } from 'astro/config'; + +export default defineConfig({ + srcDir: './www', + integrations: [ + starlight({ + title: 'Custom src directory', + pagefind: false, + }), + ], +}); diff --git a/packages/starlight/__e2e__/fixtures/custom-src-dir/package.json b/packages/starlight/__e2e__/fixtures/custom-src-dir/package.json new file mode 100644 index 00000000000..b6d71aca99c --- /dev/null +++ b/packages/starlight/__e2e__/fixtures/custom-src-dir/package.json @@ -0,0 +1,9 @@ +{ + "name": "@e2e/custom-src-dir", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/starlight": "workspace:*", + "astro": "^4.10.2" + } +} diff --git a/packages/starlight/__e2e__/fixtures/custom-src-dir/www/content/config.ts b/packages/starlight/__e2e__/fixtures/custom-src-dir/www/content/config.ts new file mode 100644 index 00000000000..45f60b01542 --- /dev/null +++ b/packages/starlight/__e2e__/fixtures/custom-src-dir/www/content/config.ts @@ -0,0 +1,6 @@ +import { defineCollection } from 'astro:content'; +import { docsSchema } from '@astrojs/starlight/schema'; + +export const collections = { + docs: defineCollection({ schema: docsSchema() }), +}; diff --git a/packages/starlight/__e2e__/fixtures/custom-src-dir/www/env.d.ts b/packages/starlight/__e2e__/fixtures/custom-src-dir/www/env.d.ts new file mode 100644 index 00000000000..acef35f175a --- /dev/null +++ b/packages/starlight/__e2e__/fixtures/custom-src-dir/www/env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/packages/starlight/__e2e__/fixtures/custom-src-dir/www/pages/custom.astro b/packages/starlight/__e2e__/fixtures/custom-src-dir/www/pages/custom.astro new file mode 100644 index 00000000000..680eaaef6a7 --- /dev/null +++ b/packages/starlight/__e2e__/fixtures/custom-src-dir/www/pages/custom.astro @@ -0,0 +1,7 @@ +--- +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +--- + + +

Hello

+
diff --git a/packages/starlight/__e2e__/test-utils.ts b/packages/starlight/__e2e__/test-utils.ts index e604732357d..bde93502c42 100644 --- a/packages/starlight/__e2e__/test-utils.ts +++ b/packages/starlight/__e2e__/test-utils.ts @@ -4,6 +4,8 @@ import { build, preview } from 'astro'; export { expect, type Locator } from '@playwright/test'; +process.env.ASTRO_TELEMETRY_DISABLED = 'true'; + // Setup a test environment that will build and start a preview server for a given fixture path and // provide a Starlight Playwright fixture accessible from within all tests. export async function testFactory(fixturePath: string) { diff --git a/packages/starlight/__tests__/basics/config-errors.test.ts b/packages/starlight/__tests__/basics/config-errors.test.ts index e48ea1a74e1..1639bd72e94 100644 --- a/packages/starlight/__tests__/basics/config-errors.test.ts +++ b/packages/starlight/__tests__/basics/config-errors.test.ts @@ -165,7 +165,7 @@ test('errors with bad sidebar config', () => { Invalid config passed to starlight integration Hint: **sidebar.0**: Did not match union. - > Expected type \`{ link: string } | { items: array } | { autogenerate: object }\` + > Expected type \`{ link: string; } | { items: array; } | { autogenerate: object; }\` > Received \`{ "label": "Example", "href": "/" }\`" ` ); @@ -190,7 +190,57 @@ test('errors with bad nested sidebar config', () => { Invalid config passed to starlight integration Hint: **sidebar.0.items.1**: Did not match union. - > Expected type \`{ link: string } | { items: array } | { autogenerate: object }\` + > Expected type \`{ link: string } | { items: array; } | { autogenerate: object; }\` > Received \`{ "label": "Example", "items": [ { "label": "Nested Example 1", "link": "/" }, { "label": "Nested Example 2", "link": true } ] }\`" `); }); + +test('errors with sidebar entry that includes `link` and `items`', () => { + expect(() => + parseStarlightConfigWithFriendlyErrors({ + title: 'Test', + sidebar: [ + { label: 'Parent', link: '/parent', items: [{ label: 'Child', link: '/parent/child' }] }, + ], + }) + ).toThrowErrorMatchingInlineSnapshot(` + "[AstroUserError]: + Invalid config passed to starlight integration + Hint: + **sidebar.0**: Unrecognized key(s) in object: 'items'" + `); +}); + +test('errors with sidebar entry that includes `link` and `autogenerate`', () => { + expect(() => + parseStarlightConfigWithFriendlyErrors({ + title: 'Test', + sidebar: [{ label: 'Parent', link: '/parent', autogenerate: { directory: 'test' } }], + }) + ).toThrowErrorMatchingInlineSnapshot(` + "[AstroUserError]: + Invalid config passed to starlight integration + Hint: + **sidebar.0**: Unrecognized key(s) in object: 'autogenerate'" + `); +}); + +test('errors with sidebar entry that includes `items` and `autogenerate`', () => { + expect(() => + parseStarlightConfigWithFriendlyErrors({ + title: 'Test', + sidebar: [ + { + label: 'Parent', + items: [{ label: 'Child', link: '/parent/child' }], + autogenerate: { directory: 'test' }, + }, + ], + }) + ).toThrowErrorMatchingInlineSnapshot(` + "[AstroUserError]: + Invalid config passed to starlight integration + Hint: + **sidebar.0**: Unrecognized key(s) in object: 'autogenerate'" + `); +}); diff --git a/packages/starlight/__tests__/remark-rehype/asides.test.ts b/packages/starlight/__tests__/remark-rehype/asides.test.ts index cb145e12b5e..a46f8e0d73d 100644 --- a/packages/starlight/__tests__/remark-rehype/asides.test.ts +++ b/packages/starlight/__tests__/remark-rehype/asides.test.ts @@ -1,6 +1,8 @@ import { createMarkdownProcessor } from '@astrojs/markdown-remark'; +import type { Root } from 'mdast'; +import { visit } from 'unist-util-visit'; import { describe, expect, test } from 'vitest'; -import { starlightAsides } from '../../integrations/asides'; +import { starlightAsides, remarkDirectivesRestoration } from '../../integrations/asides'; import { createTranslationSystemFromFs } from '../../utils/translations-fs'; import { StarlightConfigSchema, type StarlightUserConfig } from '../../utils/user-config'; @@ -23,6 +25,9 @@ const processor = await createMarkdownProcessor({ astroConfig: { root: new URL(import.meta.url), srcDir: new URL('./_src/', import.meta.url) }, useTranslations, }), + // The restoration plugin is run after the asides and any other plugin that may have been + // injected by Starlight plugins. + remarkDirectivesRestoration, ], }); @@ -167,13 +172,14 @@ test('runs without locales config', async () => { }, useTranslations, }), + remarkDirectivesRestoration, ], }); const res = await processor.render(':::note\nTest\n::'); expect(res.code.includes('aria-label=Note"')); }); -test('tranforms back unhandled text directives', async () => { +test('transforms back unhandled text directives', async () => { const res = await processor.render( `This is a:test of a sentence with a text:name[content]{key=val} directive.` ); @@ -184,10 +190,47 @@ test('tranforms back unhandled text directives', async () => { `); }); -test('tranforms back unhandled leaf directives', async () => { +test('transforms back unhandled leaf directives', async () => { const res = await processor.render(`::video[Title]{v=xxxxxxxxxxx}`); expect(res.code).toMatchInlineSnapshot(` "

::video[Title]{v="xxxxxxxxxxx"}

" `); }); + +test('lets remark plugin injected by Starlight plugins handle text and leaf directives', async () => { + const processor = await createMarkdownProcessor({ + remarkPlugins: [ + ...starlightAsides({ + starlightConfig, + astroConfig: { + root: new URL(import.meta.url), + srcDir: new URL('./_src/', import.meta.url), + }, + useTranslations, + }), + // A custom remark plugin injected by a Starlight plugin through an Astro integration would + // run before the restoration plugin. + function customRemarkPlugin() { + return function transformer(tree: Root) { + visit(tree, (node, index, parent) => { + if (node.type !== 'textDirective' || typeof index !== 'number' || !parent) return; + if (node.name === 'abbr') { + parent.children.splice(index, 1, { type: 'text', value: 'TEXT FROM REMARK PLUGIN' }); + } + }); + }; + }, + remarkDirectivesRestoration, + ], + }); + + const res = await processor.render( + `This is a:test of a sentence with a :abbr[SL]{name="Starlight"} directive handled by another remark plugin and some other text:name[content]{key=val} directives not handled by any plugin.` + ); + expect(res.code).toMatchInlineSnapshot(` + "

This is a:test + of a sentence with a TEXT FROM REMARK PLUGIN directive handled by another remark plugin and some other text:name[content]{key="val"} + directives not handled by any plugin.

" + `); +}); diff --git a/packages/starlight/__tests__/remark-rehype/rehype-steps.test.ts b/packages/starlight/__tests__/remark-rehype/rehype-steps.test.ts index 36f4082c5bf..a7081023c25 100644 --- a/packages/starlight/__tests__/remark-rehype/rehype-steps.test.ts +++ b/packages/starlight/__tests__/remark-rehype/rehype-steps.test.ts @@ -70,7 +70,7 @@ test('applies `role="list"` to child list', () => { test('does not interfere with other attributes on the child list', () => { const { html } = processSteps('
  1. Step one
'); expect(html).toMatchInlineSnapshot( - `"
  1. Step one
"` + `"
  1. Step one
"` ); }); @@ -87,3 +87,16 @@ test('applies class name and preserves existing classes on a child list', () => `"
  1. Step one
"` ); }); + +test('applies custom property if start attribute is used', () => { + const start = 10; + const { html } = processSteps(`
  1. Step one
`); + expect(html).toContain(`style="--sl-steps-start: ${start - 1}"`); +}); + +test('custom property for start count does not interfere with custom styles', () => { + const { html } = processSteps(`
  1. Step one
`); + expect(html).toMatchInlineSnapshot( + `"
  1. Step one
"` + ); +}); diff --git a/packages/starlight/components/Search.astro b/packages/starlight/components/Search.astro index 0fd2870ae69..713e9415136 100644 --- a/packages/starlight/components/Search.astro +++ b/packages/starlight/components/Search.astro @@ -223,7 +223,7 @@ const pagefindTranslations = { box-shadow: var(--sl-shadow-lg); } dialog[open] { - display: grid; + display: flex; } dialog::backdrop { @@ -234,6 +234,7 @@ const pagefindTranslations = { .dialog-frame { flex-direction: column; + flex-grow: 1; gap: 1rem; padding: 1rem; } diff --git a/packages/starlight/components/Select.astro b/packages/starlight/components/Select.astro index 0975a678939..8be1685985c 100644 --- a/packages/starlight/components/Select.astro +++ b/packages/starlight/components/Select.astro @@ -31,6 +31,7 @@ interface Props { label { --sl-label-icon-size: 0.875rem; --sl-caret-size: 1.25rem; + --sl-inline-padding: 0.5rem; position: relative; display: flex; align-items: center; @@ -62,8 +63,10 @@ interface Props { select { border: 0; padding-block: 0.625rem; - padding-inline: calc(var(--sl-label-icon-size) + 0.25rem) calc(var(--sl-caret-size) + 0.25rem); - width: var(--sl-select-width); + padding-inline: calc(var(--sl-label-icon-size) + var(--sl-inline-padding) + 0.25rem) + calc(var(--sl-caret-size) + var(--sl-inline-padding) + 0.25rem); + margin-inline: calc(var(--sl-inline-padding) * -1); + width: calc(var(--sl-select-width) + var(--sl-inline-padding) * 2); background-color: transparent; text-overflow: ellipsis; color: inherit; diff --git a/packages/starlight/index.ts b/packages/starlight/index.ts index a7876ab80dd..c13c03bcd3f 100644 --- a/packages/starlight/index.ts +++ b/packages/starlight/index.ts @@ -3,7 +3,7 @@ import type { AstroIntegration } from 'astro'; import { spawn } from 'node:child_process'; import { dirname, relative } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { starlightAsides } from './integrations/asides'; +import { starlightAsides, starlightDirectivesRestorationIntegration } from './integrations/asides'; import { starlightExpressiveCode } from './integrations/expressive-code/index'; import { starlightSitemap } from './integrations/sitemap'; import { vitePluginStarlightUserConfig } from './integrations/virtual-user-config'; @@ -73,6 +73,10 @@ export default function StarlightIntegration({ if (!allIntegrations.find(({ name }) => name === '@astrojs/mdx')) { integrations.push(mdx({ optimize: true })); } + // Add Starlight directives restoration integration at the end of the list so that remark + // plugins injected by Starlight plugins through Astro integrations can handle text and + // leaf directives before they are transformed back to their original form. + integrations.push(starlightDirectivesRestorationIntegration()); // Add integrations immediately after Starlight in the config array. // e.g. if a user has `integrations: [starlight(), tailwind()]`, then the order will be diff --git a/packages/starlight/integrations/asides.ts b/packages/starlight/integrations/asides.ts index 2b03b372ee5..3218e509c45 100644 --- a/packages/starlight/integrations/asides.ts +++ b/packages/starlight/integrations/asides.ts @@ -1,6 +1,6 @@ /// -import type { AstroConfig, AstroUserConfig } from 'astro'; +import type { AstroConfig, AstroIntegration, AstroUserConfig } from 'astro'; import { h as _h, s as _s, type Properties } from 'hastscript'; import type { Node, Paragraph as P, Parent, Root } from 'mdast'; import { @@ -146,7 +146,6 @@ function remarkAsides(options: AsidesOptions): Plugin<[], Root> { return; } if (node.type === 'textDirective' || node.type === 'leafDirective') { - transformUnhandledDirective(node, index, parent); return; } const variant = node.name; @@ -210,3 +209,43 @@ type RemarkPlugins = NonNullable['remar export function starlightAsides(options: AsidesOptions): RemarkPlugins { return [remarkDirective, remarkAsides(options)]; } + +export function remarkDirectivesRestoration() { + return function transformer(tree: Root) { + visit(tree, (node, index, parent) => { + if ( + index !== undefined && + parent && + (node.type === 'textDirective' || node.type === 'leafDirective') + ) { + transformUnhandledDirective(node, index, parent); + return; + } + }); + }; +} + +/** + * Directives not handled by Starlight are transformed back to their original form to avoid + * breaking user content. + * To allow remark plugins injected by Starlight plugins through Astro integrations to handle + * such directives, we need to restore unhandled text and leaf directives back to their original + * form only after all these other plugins have run. + * To do so, we run a remark plugin restoring these directives back to their original form from + * another Astro integration that runs after all the ones that may have been injected by Starlight + * plugins. + */ +export function starlightDirectivesRestorationIntegration(): AstroIntegration { + return { + name: 'starlight-directives-restoration', + hooks: { + 'astro:config:setup': ({ updateConfig }) => { + updateConfig({ + markdown: { + remarkPlugins: [remarkDirectivesRestoration], + }, + }); + }, + }, + }; +} diff --git a/packages/starlight/integrations/virtual-user-config.ts b/packages/starlight/integrations/virtual-user-config.ts index b51f8e3877d..d955ad50c43 100644 --- a/packages/starlight/integrations/virtual-user-config.ts +++ b/packages/starlight/integrations/virtual-user-config.ts @@ -50,7 +50,7 @@ export function vitePluginStarlightUserConfig( : 'export const logos = {};', 'virtual:starlight/collection-config': `let userCollections; try { - userCollections = (await import('/src/content/config.ts')).collections; + userCollections = (await import('${new URL('./content/config.ts', srcDir).pathname}')).collections; } catch {} export const collections = userCollections;`, ...virtualComponentModules, diff --git a/packages/starlight/package.json b/packages/starlight/package.json index ed352f4278c..020256f807d 100644 --- a/packages/starlight/package.json +++ b/packages/starlight/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/starlight", - "version": "0.24.2", + "version": "0.24.5", "description": "Build beautiful, high-performance documentation websites with Astro", "scripts": { "test": "vitest", @@ -180,7 +180,7 @@ }, "devDependencies": { "@astrojs/markdown-remark": "^5.1.0", - "@playwright/test": "^1.44.1", + "@playwright/test": "^1.45.0", "@types/node": "^18.16.19", "@vitest/coverage-v8": "^1.6.0", "astro": "^4.10.2", diff --git a/packages/starlight/playwright.config.ts b/packages/starlight/playwright.config.ts index 01098ea8b0d..257348a1e66 100644 --- a/packages/starlight/playwright.config.ts +++ b/packages/starlight/playwright.config.ts @@ -12,4 +12,6 @@ export default defineConfig({ }, ], testMatch: '__e2e__/*.test.ts', + timeout: 40 * 1_000, + workers: 1, }); diff --git a/packages/starlight/schemas/sidebar.ts b/packages/starlight/schemas/sidebar.ts index 86eb7f87e48..41b1c3ae29f 100644 --- a/packages/starlight/schemas/sidebar.ts +++ b/packages/starlight/schemas/sidebar.ts @@ -33,7 +33,7 @@ const SidebarLinkItemSchema = SidebarBaseSchema.extend({ link: z.string(), /** HTML attributes to add to the link item. */ attrs: SidebarLinkItemHTMLAttributesSchema(), -}); +}).strict(); export type SidebarLinkItem = z.infer; const AutoSidebarGroupSchema = SidebarGroupSchema.extend({ @@ -50,7 +50,7 @@ const AutoSidebarGroupSchema = SidebarGroupSchema.extend({ /** How many directories deep to include from this directory in the sidebar. Default: `Infinity`. */ // depth: z.number().optional(), }), -}); +}).strict(); export type AutoSidebarGroup = z.infer; type ManualSidebarGroupInput = z.input & { @@ -80,7 +80,7 @@ const ManualSidebarGroupSchema: z.ZodType< items: z.lazy(() => z.union([SidebarLinkItemSchema, ManualSidebarGroupSchema, AutoSidebarGroupSchema]).array() ), -}); +}).strict(); export const SidebarItemSchema = z.union([ SidebarLinkItemSchema, diff --git a/packages/starlight/translations/cs.json b/packages/starlight/translations/cs.json index f3a83731b18..7ec5014c05e 100644 --- a/packages/starlight/translations/cs.json +++ b/packages/starlight/translations/cs.json @@ -18,12 +18,25 @@ "page.lastUpdated": "Poslední aktualizace:", "page.previousLink": "Předchozí", "page.nextLink": "Další", - "page.draft": "This content is a draft and will not be included in production builds.", - "404.text": "Stránka nenalezena. Zkontrolujte adresu URL nebo zkuste použít vyhledávací pole.", - "aside.note": "Note", + "page.draft": "Tento obsah je koncept a nebude zahrnutý v produkčním sestavení.", + "404.text": "Stránka nenalezena. Zkontrolujte adresu nebo zkuste použít vyhledávač", + "aside.note": "Poznámka", "aside.tip": "Tip", - "aside.caution": "Caution", - "aside.danger": "Danger", - "fileTree.directory": "Directory", - "builtWithStarlight.label": "Built with Starlight" + "aside.caution": "Upozornění", + "aside.danger": "Nebezpečí", + "fileTree.directory": "Adresář", + "builtWithStarlight.label": "Postavené s Starlight", + "expressiveCode.copyButtonCopied": "Zkopírováno!", + "expressiveCode.copyButtonTooltip": "Kopíruj do schránky", + "expressiveCode.terminalWindowFallbackTitle": "Terminál", + "pagefind.clear_search": "Vyčistit", + "pagefind.load_more": "Načíst další výsledky", + "pagefind.search_label": "Vyhledat stránku", + "pagefind.filters_label": "Filtry", + "pagefind.zero_results": "Žádný výsledek pro: [SEARCH_TERM]", + "pagefind.many_results": "počet výsledků: [COUNT] pro: [SEARCH_TERM]", + "pagefind.one_result": "[COUNT] výsledek pro: [SEARCH_TERM]", + "pagefind.alt_search": "Žádné výsledky pro [SEARCH_TERM]. Namísto toho zobrazuji výsledky pro: [DIFFERENT_TERM]", + "pagefind.search_suggestion": "Žádný výsledek pro [SEARCH_TERM]. Zkus nějaké z těchto hledání:", + "pagefind.searching": "Hledám [SEARCH_TERM]..." } diff --git a/packages/starlight/translations/nb.json b/packages/starlight/translations/nb.json index f4b05755dab..14099cda092 100644 --- a/packages/starlight/translations/nb.json +++ b/packages/starlight/translations/nb.json @@ -20,10 +20,10 @@ "page.nextLink": "Neste", "page.draft": "This content is a draft and will not be included in production builds.", "404.text": "Siden ble ikke funnet. Sjekk URL-en eller prøv å bruke søkefeltet.", - "aside.note": "Note", - "aside.tip": "Tip", - "aside.caution": "Caution", - "aside.danger": "Danger", - "fileTree.directory": "Directory", + "aside.note": "Merknad", + "aside.tip": "Tips", + "aside.caution": "Advarsel", + "aside.danger": "Fare", + "fileTree.directory": "Mappe", "builtWithStarlight.label": "Laget med Starlight" } diff --git a/packages/starlight/translations/ru.json b/packages/starlight/translations/ru.json index 9b91bed3a72..4175f290c4e 100644 --- a/packages/starlight/translations/ru.json +++ b/packages/starlight/translations/ru.json @@ -28,5 +28,5 @@ "expressiveCode.copyButtonCopied": "Скопировано!", "expressiveCode.copyButtonTooltip": "Копировать", "expressiveCode.terminalWindowFallbackTitle": "Окно терминала", - "builtWithStarlight.label": "Built with Starlight" + "builtWithStarlight.label": "Сделано с помощью Starlight" } diff --git a/packages/starlight/translations/uk.json b/packages/starlight/translations/uk.json index 8f6cf52bfd0..eba7051d7f0 100644 --- a/packages/starlight/translations/uk.json +++ b/packages/starlight/translations/uk.json @@ -3,7 +3,7 @@ "search.label": "Пошук", "search.ctrlKey": "Ctrl", "search.cancelLabel": "Скасувати", - "search.devWarning": "Пошук доступний лише у виробничих зборках. \nСпробуйте зібрати та переглянути сайт, щоби протестувати його локально", + "search.devWarning": "Пошук доступний лише у виробничих збірках. \nСпробуйте зібрати та переглянути сайт, щоби протестувати його локально", "themeSelect.accessibleLabel": "Обрати тему", "themeSelect.dark": "Темна", "themeSelect.light": "Світла", @@ -18,12 +18,12 @@ "page.lastUpdated": "Останнє оновлення:", "page.previousLink": "Назад", "page.nextLink": "Далі", - "page.draft": "This content is a draft and will not be included in production builds.", + "page.draft": "Цей контент є чернеткою і не буде включений до виробничих збірок.", "404.text": "Сторінку не знайдено. Перевірте URL або спробуйте скористатися пошуком.", "aside.note": "Заувага", "aside.tip": "Порада", "aside.caution": "Обережно", "aside.danger": "Небезпечно", - "fileTree.directory": "Directory", - "builtWithStarlight.label": "Built with Starlight" + "fileTree.directory": "Каталог", + "builtWithStarlight.label": "Створено з Starlight" } diff --git a/packages/starlight/user-components/Steps.astro b/packages/starlight/user-components/Steps.astro index ffd65a35c6d..66562555437 100644 --- a/packages/starlight/user-components/Steps.astro +++ b/packages/starlight/user-components/Steps.astro @@ -13,10 +13,12 @@ const { html } = processSteps(content); --bullet-margin: 0.375rem; list-style: none; + counter-reset: steps-counter var(--sl-steps-start, 0); padding-inline-start: 0; } .sl-steps > li { + counter-increment: steps-counter; position: relative; padding-inline-start: calc(var(--bullet-size) + 1rem); /* HACK: Keeps any `margin-bottom` inside the `
  • `’s padding box to avoid gaps in the hairline border. */ @@ -31,7 +33,7 @@ const { html } = processSteps(content); /* Custom list marker element. */ .sl-steps > li::before { - content: counter(list-item); + content: counter(steps-counter); position: absolute; top: 0; inset-inline-start: 0; diff --git a/packages/starlight/user-components/rehype-steps.ts b/packages/starlight/user-components/rehype-steps.ts index ff9c9593f85..184df00ef08 100644 --- a/packages/starlight/user-components/rehype-steps.ts +++ b/packages/starlight/user-components/rehype-steps.ts @@ -44,6 +44,14 @@ const stepsProcessor = rehype() } else { rootElement.properties.className.push('sl-steps'); } + + // Add the `start` attribute as a CSS custom property so we can use it as the starting index + // of the steps custom counter. + if (typeof rootElement.properties.start === 'number') { + const styles = [`--sl-steps-start: ${rootElement.properties.start - 1}`]; + if (rootElement.properties.style) styles.push(String(rootElement.properties.style)); + rootElement.properties.style = styles.join(';'); + } }; }); diff --git a/packages/starlight/vitest.config.ts b/packages/starlight/vitest.config.ts index 5440eaa3347..70ec5159a03 100644 --- a/packages/starlight/vitest.config.ts +++ b/packages/starlight/vitest.config.ts @@ -1,20 +1,4 @@ -import { defineConfig } from 'vitest/config'; - -// Copy of https://github.com/vitest-dev/vitest/blob/8693449b412743f20a63fd9bfa1a9054aa74613f/packages/vitest/src/defaults.ts#L13C1-L26C1 -const defaultCoverageExcludes = [ - 'coverage/**', - 'dist/**', - 'packages/*/test?(s)/**', - '**/*.d.ts', - 'cypress/**', - 'test?(s)/**', - 'test?(-*).?(c|m)[jt]s?(x)', - '**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)', - '**/__tests__/**', - '**/__e2e__/**', - '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,playwright}.config.*', - '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}', -]; +import { coverageConfigDefaults, defineConfig } from 'vitest/config'; export default defineConfig({ test: { @@ -22,7 +6,9 @@ export default defineConfig({ all: true, reportsDirectory: './__coverage__', exclude: [ - ...defaultCoverageExcludes, + ...coverageConfigDefaults.exclude, + '**/__e2e__/**', + 'playwright.config.*', '**/vitest.*', 'components.ts', 'types.ts', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f5f0f83a65e..37078d8d1cb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,8 +45,8 @@ importers: specifier: workspace:* version: link:../packages/starlight '@lunariajs/core': - specifier: ^0.1.0 - version: 0.1.0 + specifier: ^0.1.1 + version: 0.1.1 '@types/culori': specifier: ^2.0.0 version: 2.0.0 @@ -73,7 +73,7 @@ importers: examples/basics: dependencies: '@astrojs/starlight': - specifier: ^0.24.2 + specifier: ^0.24.5 version: link:../../packages/starlight astro: specifier: ^4.10.2 @@ -85,7 +85,7 @@ importers: examples/tailwind: dependencies: '@astrojs/starlight': - specifier: ^0.24.2 + specifier: ^0.24.5 version: link:../../packages/starlight '@astrojs/starlight-tailwind': specifier: ^2.0.3 @@ -195,8 +195,8 @@ importers: specifier: ^5.1.0 version: 5.1.0 '@playwright/test': - specifier: ^1.44.1 - version: 1.44.1 + specifier: ^1.45.0 + version: 1.45.0 '@types/node': specifier: ^18.16.19 version: 18.16.19 @@ -219,6 +219,15 @@ importers: specifier: ^4.10.2 version: 4.10.2(@types/node@18.16.19)(typescript@5.4.5) + packages/starlight/__e2e__/fixtures/custom-src-dir: + dependencies: + '@astrojs/starlight': + specifier: workspace:* + version: link:../../.. + astro: + specifier: ^4.10.2 + version: 4.10.2(@types/node@18.16.19)(typescript@5.4.5) + packages/tailwind: dependencies: '@astrojs/starlight': @@ -1725,8 +1734,8 @@ packages: resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==} dev: false - /@lunariajs/core@0.1.0: - resolution: {integrity: sha512-UP2K3fjgmPP4eN92ZcreAzWitRfeqhMMSHeh2GK2FtzReYWoHeth7cogzNv9Glb64UA2PFJkZ3fU5DAdX53w+g==} + /@lunariajs/core@0.1.1: + resolution: {integrity: sha512-sAqM9+DVsLe3xHM9wu2pEnKGYMs/bWS9qpR+CGHol3RihOELnOQTzHddXbdB1MtgesbI8dnQuG64Ocd8KkWsng==} engines: {node: '>=18.17.0'} hasBin: true dependencies: @@ -1856,12 +1865,12 @@ packages: dev: false optional: true - /@playwright/test@1.44.1: - resolution: {integrity: sha512-1hZ4TNvD5z9VuhNJ/walIjvMVvYkZKf71axoF/uiAqpntQJXpG64dlXhoDXE3OczPuTuvjf/M5KWFg5VAVUS3Q==} - engines: {node: '>=16'} + /@playwright/test@1.45.0: + resolution: {integrity: sha512-TVYsfMlGAaxeUllNkywbwek67Ncf8FRGn8ZlRdO291OL3NjG9oMbfVhyP82HQF0CZLMrYsvesqoUekxdWuF9Qw==} + engines: {node: '>=18'} hasBin: true dependencies: - playwright: 1.44.1 + playwright: 1.45.0 dev: true /@rollup/rollup-android-arm-eabi@4.17.2: @@ -5841,18 +5850,18 @@ packages: pathe: 1.1.2 dev: true - /playwright-core@1.44.1: - resolution: {integrity: sha512-wh0JWtYTrhv1+OSsLPgFzGzt67Y7BE/ZS3jEqgGBlp2ppp1ZDj8c+9IARNW4dwf1poq5MgHreEM2KV/GuR4cFA==} - engines: {node: '>=16'} + /playwright-core@1.45.0: + resolution: {integrity: sha512-lZmHlFQ0VYSpAs43dRq1/nJ9G/6SiTI7VPqidld9TDefL9tX87bTKExWZZUF5PeRyqtXqd8fQi2qmfIedkwsNQ==} + engines: {node: '>=18'} hasBin: true dev: true - /playwright@1.44.1: - resolution: {integrity: sha512-qr/0UJ5CFAtloI3avF95Y0L1xQo6r3LQArLIg/z/PoGJ6xa+EwzrwO5lpNr/09STxdHuUoP2mvuELJS+hLdtgg==} - engines: {node: '>=16'} + /playwright@1.45.0: + resolution: {integrity: sha512-4z3ac3plDfYzGB6r0Q3LF8POPR20Z8D0aXcxbJvmfMgSSq1hkcgvFRXJk9rUq5H/MJ0Ktal869hhOdI/zUTeLA==} + engines: {node: '>=18'} hasBin: true dependencies: - playwright-core: 1.44.1 + playwright-core: 1.45.0 optionalDependencies: fsevents: 2.3.2 dev: true