@astrojs/starlight 0.21.2 → 0.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.21.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1703](https://github.com/withastro/starlight/pull/1703) [`b26238f2`](https://github.com/withastro/starlight/commit/b26238f22990dcf8ba002bea6a50c66f20ad5786) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes aside custom titles rendering for nested asides.
8
+
9
+ - [#1708](https://github.com/withastro/starlight/pull/1708) [`a72cb966`](https://github.com/withastro/starlight/commit/a72cb96600798c1fbc7558f8fd24556ca442d312) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes translation issues with Expressive Code when using a default language other than English
10
+
11
+ ## 0.21.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#1622](https://github.com/withastro/starlight/pull/1622) [`3a074bad`](https://github.com/withastro/starlight/commit/3a074bad6c139bb9d6169d95ec79bc0fc1ecbdfe) Thanks [@SamuelLHuber](https://github.com/SamuelLHuber)! - Adds 1 new icon: `farcaster`
16
+
17
+ - [#1616](https://github.com/withastro/starlight/pull/1616) [`a86f9b71`](https://github.com/withastro/starlight/commit/a86f9b71b795fb6dcd0409ca568e43d25525b964) Thanks [@dragomano](https://github.com/dragomano)! - Updates Russian UI strings
18
+
19
+ - [#1698](https://github.com/withastro/starlight/pull/1698) [`67b892fd`](https://github.com/withastro/starlight/commit/67b892fd5290dfd0eeb95f4e60b6427bdc82110f) Thanks [@liruifengv](https://github.com/liruifengv)! - Adds 1 new icon: `starlight`
20
+
21
+ - [#1687](https://github.com/withastro/starlight/pull/1687) [`6fa9ea7e`](https://github.com/withastro/starlight/commit/6fa9ea7e8d4d601cf8f49b61dafb1ebb557d1718) Thanks [@mingjunlu](https://github.com/mingjunlu)! - Translates `fileTree.directory` UI string into Traditional Chinese.
22
+
3
23
  ## 0.21.2
4
24
 
5
25
  ### Patch Changes
@@ -64,6 +64,8 @@ export const BuiltInIcons = {
64
64
  '<path d="M1 1.5a.8.8 0 0 0-.7.9l3.2 19.3c0 .5.5.8 1 .8h15.2c.4 0 .7-.2.8-.6l3.2-19.5a.7.7 0 0 0-.8-.9H1zm13.4 14H9.6l-1.3-7h7.3l-1.2 7z"/>',
65
65
  codePen:
66
66
  '<path d="M23.5 7.5 12.5.2a1 1 0 0 0-1 0L.4 7.5a1 1 0 0 0-.5.8v7.4c0 .3.2.6.5.8l11 7.3c.3.3.7.3 1 0l11-7.3c.3-.2.5-.5.5-.8V8.3a1 1 0 0 0-.5-.8zM13 3l8.1 5.3-3.6 2.5-4.5-3V3zm-2 0v4.8l-4.5 3-3.6-2.5 8-5.3zm-9 7.3L4.7 12l-2.5 1.7v-3.4zM11 21l-8.1-5.3 3.6-2.5 4.5 3V21zm1-6.6L8.4 12 12 9.6l3.6 2.4-3.6 2.4zm1 6.6v-4.8l4.5-3 3.6 2.5-8 5.3zm9-7.3L19.3 12l2.5-1.7v3.4z"/>',
67
+ farcaster:
68
+ '<path d="M6.187 3.733h11.627v16.533h-1.707v-7.573h-.017a4.107 4.107 0 0 0-8.18 0h-.017v7.573H6.186z"/><path d="m3.093 6.08.693 2.347h.587v9.493a.533.533 0 0 0-.533.533v.64h-.107a.533.533 0 0 0-.533.533v.64h5.973v-.64a.533.533 0 0 0-.533-.533h-.107v-.64A.533.533 0 0 0 8 17.92h-.64V6.08zM16.213 17.92a.533.533 0 0 0-.533.533v.64h-.107a.533.533 0 0 0-.533.533v.64h5.973v-.64a.533.533 0 0 0-.533-.533h-.107v-.64a.533.533 0 0 0-.533-.533V8.427h.587l.693-2.347h-4.267v11.84z"/>',
67
69
  discord:
68
70
  '<path d="M20.32 4.37a19.8 19.8 0 0 0-4.93-1.51 13.78 13.78 0 0 0-.64 1.28 18.27 18.27 0 0 0-5.5 0 12.64 12.64 0 0 0-.64-1.28h-.05A19.74 19.74 0 0 0 3.64 4.4 20.26 20.26 0 0 0 .11 18.09l.02.02a19.9 19.9 0 0 0 6.04 3.03l.04-.02a14.24 14.24 0 0 0 1.23-2.03.08.08 0 0 0-.05-.07 13.1 13.1 0 0 1-1.9-.92.08.08 0 0 1 .02-.1 10.2 10.2 0 0 0 .41-.31h.04a14.2 14.2 0 0 0 12.1 0l.04.01a9.63 9.63 0 0 0 .4.32.08.08 0 0 1-.03.1 12.29 12.29 0 0 1-1.9.91.08.08 0 0 0-.02.1 15.97 15.97 0 0 0 1.27 2.01h.04a19.84 19.84 0 0 0 6.03-3.05v-.03a20.12 20.12 0 0 0-3.57-13.69ZM8.02 15.33c-1.18 0-2.16-1.08-2.16-2.42 0-1.33.96-2.42 2.16-2.42 1.21 0 2.18 1.1 2.16 2.42 0 1.34-.96 2.42-2.16 2.42Zm7.97 0c-1.18 0-2.15-1.08-2.15-2.42 0-1.33.95-2.42 2.15-2.42 1.22 0 2.18 1.1 2.16 2.42 0 1.34-.94 2.42-2.16 2.42Z"/>',
69
71
  gitter:
@@ -121,6 +123,8 @@ export const BuiltInIcons = {
121
123
  homebrew:
122
124
  '<path d="M7.94 0a.21.21 0 0 0-.2.16c-.32 1.1.17 2.15.83 2.93.15.18.31.35.48.5a2.04 2.04 0 0 0-.67.02c-1.18.24-2.2.99-2.74 2.53a3.9 3.9 0 0 0-.2 1.47 1.56 1.56 0 0 0-1.16 1.5 1.59 1.59 0 0 0 1.23 1.55l.03 12.04c0 .2.1.38.26.48a.21.21 0 0 0 .01 0c.54.32 2.05.82 5.21.82 3.24 0 4.7-.68 5.18-1.04a.57.57 0 0 0 .22-.45v-1.6a.14.14 0 0 1 .14-.14h1.32a1.83 1.83 0 0 0 1.83-1.82v-5.8a1.83 1.83 0 0 0-1.82-1.83h-1.33a.14.14 0 0 1-.14-.15v-.57a1.57 1.57 0 0 0 1.36-1.56c0-.81-.63-1.49-1.42-1.56a4.34 4.34 0 0 0-.74-2.58 3.1 3.1 0 0 0-2.28-1.32c-.5-.02-.84.12-1.13.25-.21.1-.42.18-.67.22 0-1.28.95-1.98.95-1.98a.21.21 0 0 0 .05-.3s-.09-.12-.21-.26c-.12-.13-.27-.3-.47-.38a.21.21 0 0 0-.08-.01.21.21 0 0 0-.14.05 4.3 4.3 0 0 0-.88 1.1 3.42 3.42 0 0 0-.13.28 3.5 3.5 0 0 0-.38-.85A4.44 4.44 0 0 0 8.02.02.21.21 0 0 0 7.94 0zm.15.52c.85.38 1.43.83 1.8 1.4.27.45.42.97.48 1.6a3.07 3.07 0 0 0-.01.45 6.9 6.9 0 0 1-.17-.05 5.49 5.49 0 0 1-1.3-1.1c-.54-.66-.93-1.46-.8-2.3m3.71 1.1c.07.05.14.1.21.18l.06.07a2.97 2.97 0 0 0-.95 2.45.21.21 0 0 0 .22.2c.47-.02.78-.17 1.06-.3.27-.13.5-.23.93-.21.87.02 1.64.71 1.94 1.13.3.45.65 1 .66 2.36a1.66 1.66 0 0 0-.41.14 1.94 1.94 0 0 0-1.77-1.16 1.94 1.94 0 0 0-1.87 1.45 1.78 1.78 0 0 0-1.36-.64c-.48 0-.9.2-1.23.52a1.87 1.87 0 0 0-1.85-1.63c-.65 0-1.22.34-1.55.84a3.1 3.1 0 0 1 .16-.73c.5-1.44 1.35-2.05 2.42-2.26.36-.07.66 0 .99.1.32.1.67.26 1.09.34a.21.21 0 0 0 .25-.25c-.11-.67.07-1.26.34-1.74a3.71 3.71 0 0 1 .66-.86m-4.36 5A1.44 1.44 0 0 1 8.8 8.53a.21.21 0 0 0 .17.28.21.21 0 0 0 .24-.15 1.37 1.37 0 0 1 2.62 0 .21.21 0 0 0 .41-.1 1.5 1.5 0 0 1 1.5-1.66c.69 0 1.26.44 1.45 1.05a.21.21 0 0 0 .26.15l.15-.04a.21.21 0 0 0 .05-.02 1.14 1.14 0 0 1 1.7 1 1.14 1.14 0 0 1-.98 1.12 2.21 2.21 0 0 0-.49.13 10.65 10.65 0 0 1-1.18.36.21.21 0 0 0-.16.2 1.28 1.28 0 0 1-.14.47 2.07 2.07 0 0 0-.24 1.11v.15a.44.44 0 0 1-.16.36.67.67 0 0 1-.43.14.59.59 0 0 1-.59-.59.8.8 0 0 0-.38-.68 1.28 1.28 0 0 1-.53-.64.21.21 0 0 0-.21-.14 19.47 19.47 0 0 1-5.37-.6 9 9 0 0 0-.84-.2 1.16 1.16 0 0 1-.94-1.13c0-.62.5-1.11 1.1-1.14a.21.21 0 0 0 .21-.17A1.44 1.44 0 0 1 7.44 6.6m8.55 4.1v.46c0 .32.26.57.57.57h1.33a1.4 1.4 0 0 1 1.4 1.4v5.8a1.4 1.4 0 0 1-1.4 1.4h-1.32a.57.57 0 0 0-.58.57v1.6c0 .05-.02.08-.05.11-.35.26-1.75.95-4.92.95-3.1 0-4.59-.52-4.99-.75a.14.14 0 0 1-.06-.12l-.03-11.95.43.1.39.1v10.37c0 .13.07.25.18.31.45.22 1.77.74 4.07.74 2.32 0 3.6-.63 4.02-.89a.36.36 0 0 0 .17-.3v-10.2l.79-.26m-8 .9a.5.5 0 0 1 .5.48v8.58a.5.5 0 0 1-.49.5.5.5 0 0 1-.5-.5V12.1a.5.5 0 0 1 .5-.49zm8.66 1.13a.66.66 0 0 0-.66.66v5.21a.66.66 0 0 0 .66.66h1.14a.66.66 0 0 0 .66-.66v-5.2a.66.66 0 0 0-.66-.67zm0 .43h1.14a.23.23 0 0 1 .23.23v5.21a.23.23 0 0 1-.23.23h-1.14a.23.23 0 0 1-.23-.23v-5.2a.23.23 0 0 1 .23-.24"/>',
123
125
  nix: '<path d="M7.4 1.6H6l-.7 1.1L7 5.5H3.7L2.4 7.8h11.7l-1.3-2.3H9.6l-2.2-4zm6.1 0h-2.7l5.9 10.1L18 9.4l-1.6-2.8 2.3-3.8-.7-1.2h-1.3L15 4.3l-1.6-2.7zm7 4.2-6 10.1h2.8l1.6-2.8h4.4L24 12l-.7-1.2h-3.1l1.6-2.7-1.4-2.3zM9.4 8H6.6L5 10.8H.7L0 12l.7 1.2h3.1l-1.6 2.7 1.4 2.3zm-2.2 4.2L6 14.6l1.6 2.8-2.3 3.8.7 1.2h1.3L9 19.7l1.6 2.7h2.7zm2.6 3.9 1.3 2.3h3.2l2.2 3.9H18l.7-1.2-1.6-2.7h3.2l1.3-2.3z"/>',
126
+ starlight:
127
+ '<path fill-rule="evenodd" d="M15.19 6.75 12 0 8.81 6.75l-.19.38-1.68-1.88a1.2 1.2 0 1 0-1.69 1.69L7.13 8.8h-.38L0 12l6.75 3.19h.38l-1.88 1.87a1.2 1.2 0 1 0 1.69 1.69l1.68-1.88.2.38L12 24l3.19-6.75v-.38l1.69 1.88a1.2 1.2 0 1 0 1.68-1.69l-1.68-1.68.37-.2L24 12l-6.75-3.19-.38-.19 1.7-1.68a1.2 1.2 0 1 0-1.7-1.69L15.2 7.13v-.38ZM12 7.13l-.38.93a8.18 8.18 0 0 1-3.56 3.56l-.94.38.94.38a8.18 8.18 0 0 1 3.56 3.56l.38.94.38-.94a8.18 8.18 0 0 1 3.56-3.56l.94-.38-.94-.38a8.18 8.18 0 0 1-3.56-3.56L12 7.12Z"/><path d="M22.12 3.56a1.2 1.2 0 1 0-1.68-1.69l-.57.57a1.2 1.2 0 0 0 1.7 1.68l.55-.56Zm-18 .75c-.37.38-1.12.38-1.68 0l-.57-.56a1.2 1.2 0 0 1 1.7-1.69l.55.56c.57.38.57 1.13 0 1.7Zm0 15.38c-.37-.38-1.12-.38-1.68 0l-.57.56a1.2 1.2 0 1 0 1.7 1.69l.55-.57c.57-.37.57-1.12 0-1.68Zm18 .75a1.2 1.2 0 1 1-1.68 1.68l-.57-.56a1.2 1.2 0 0 1 1.7-1.69l.55.57Z"/>',
124
128
  };
125
129
 
126
130
  export const Icons = {
@@ -12,7 +12,6 @@ import {
12
12
  import { toMarkdown } from 'mdast-util-to-markdown';
13
13
  import remarkDirective from 'remark-directive';
14
14
  import type { Plugin, Transformer } from 'unified';
15
- import { remove } from 'unist-util-remove';
16
15
  import { visit } from 'unist-util-visit';
17
16
  import type { StarlightConfig } from '../types';
18
17
  import type { createTranslationSystemFromFs } from '../utils/translations-fs';
@@ -153,23 +152,24 @@ function remarkAsides(options: AsidesOptions): Plugin<[], Root> {
153
152
  const variant = node.name;
154
153
  if (!isAsideVariant(variant)) return;
155
154
 
156
- // remark-directive converts a container’s “label” to a paragraph in
157
- // its children, but we want to pass it as the title prop to <Aside>, so
158
- // we iterate over the children, find a directive label, store it for the
159
- // title prop, and remove the paragraph from children.
155
+ // remark-directive converts a container’s “label” to a paragraph added as the head of its
156
+ // children with the `directiveLabel` property set to true. We want to pass it as the title
157
+ // prop to <Aside>, so when we find a directive label, we store it for the title prop and
158
+ // remove the paragraph from the container’s children.
160
159
  let title = t(`aside.${variant}`);
161
- remove(node, (child): boolean | void => {
162
- if (child.data && 'directiveLabel' in child.data && child.data.directiveLabel) {
163
- if (
164
- 'children' in child &&
165
- Array.isArray(child.children) &&
166
- 'value' in child.children[0]
167
- ) {
168
- title = child.children[0].value;
169
- }
170
- return true;
160
+ const firstChild = node.children[0];
161
+ if (
162
+ firstChild?.type === 'paragraph' &&
163
+ firstChild.data &&
164
+ 'directiveLabel' in firstChild.data
165
+ ) {
166
+ const firstGrandChild = firstChild.children[0];
167
+ if (firstGrandChild?.type === 'text') {
168
+ title = firstGrandChild.value;
171
169
  }
172
- });
170
+ // The first paragraph contains a directive label, we can safely remove it.
171
+ node.children.splice(0, 1);
172
+ }
173
173
 
174
174
  const aside = h(
175
175
  'aside',
@@ -77,7 +77,6 @@ export function getStarlightEcConfigPreprocessor({
77
77
  return (input): AstroExpressiveCodeOptions => {
78
78
  const astroConfig = input.astroConfig;
79
79
  const ecConfig = input.ecConfig as StarlightExpressiveCodeOptions;
80
- const { locales } = starlightConfig;
81
80
 
82
81
  const {
83
82
  themes: themesInput,
@@ -111,7 +110,7 @@ export function getStarlightEcConfigPreprocessor({
111
110
  });
112
111
 
113
112
  // Add Expressive Code UI translations (if any) for all defined locales
114
- if (useTranslations) addTranslations(locales, useTranslations);
113
+ if (useTranslations) addTranslations(starlightConfig, useTranslations);
115
114
 
116
115
  return {
117
116
  themes,
@@ -124,6 +123,7 @@ export function getStarlightEcConfigPreprocessor({
124
123
  }
125
124
  return theme;
126
125
  },
126
+ defaultLocale: starlightConfig.defaultLocale?.lang ?? starlightConfig.defaultLocale?.locale,
127
127
  themeCssSelector: (theme, { styleVariants }) => {
128
128
  // If one dark and one light theme are available, and the user has not disabled it,
129
129
  // generate theme CSS selectors compatible with Starlight's dark mode switch
@@ -1,26 +1,37 @@
1
1
  import { pluginFramesTexts } from 'astro-expressive-code';
2
2
  import type { StarlightConfig } from '../../types';
3
3
  import type { createTranslationSystemFromFs } from '../../utils/translations-fs';
4
+ import { localeToLang } from '../shared/localeToLang';
4
5
 
5
6
  export function addTranslations(
6
- locales: StarlightConfig['locales'],
7
+ config: StarlightConfig,
7
8
  useTranslations: ReturnType<typeof createTranslationSystemFromFs>
8
9
  ) {
9
- for (const locale in locales) {
10
- const lang = locales[locale]?.lang;
11
- if (!lang) continue;
12
-
13
- const t = useTranslations(locale);
14
- const translationKeys = [
15
- 'expressiveCode.copyButtonCopied',
16
- 'expressiveCode.copyButtonTooltip',
17
- 'expressiveCode.terminalWindowFallbackTitle',
18
- ] as const;
19
- translationKeys.forEach((key) => {
20
- const translation = t(key);
21
- if (!translation) return;
22
- const ecId = key.replace(/^expressiveCode\./, '');
23
- pluginFramesTexts.overrideTexts(lang, { [ecId]: translation });
24
- });
10
+ addTranslationsForLocale(config.defaultLocale.locale, config, useTranslations);
11
+ if (config.isMultilingual) {
12
+ for (const locale in config.locales) {
13
+ if (locale === config.defaultLocale.locale || locale === 'root') continue;
14
+ addTranslationsForLocale(locale, config, useTranslations);
15
+ }
25
16
  }
26
17
  }
18
+
19
+ function addTranslationsForLocale(
20
+ locale: string | undefined,
21
+ config: StarlightConfig,
22
+ useTranslations: ReturnType<typeof createTranslationSystemFromFs>
23
+ ) {
24
+ const lang = localeToLang(config, locale);
25
+ const t = useTranslations(locale);
26
+ const translationKeys = [
27
+ 'expressiveCode.copyButtonCopied',
28
+ 'expressiveCode.copyButtonTooltip',
29
+ 'expressiveCode.terminalWindowFallbackTitle',
30
+ ] as const;
31
+ translationKeys.forEach((key) => {
32
+ const translation = t(key);
33
+ if (!translation) return;
34
+ const ecId = key.replace(/^expressiveCode\./, '');
35
+ pluginFramesTexts.overrideTexts(lang, { [ecId]: translation });
36
+ });
37
+ }
@@ -0,0 +1,11 @@
1
+ import type { StarlightConfig } from '../../types';
2
+
3
+ /**
4
+ * Get the BCP-47 language tag for the given locale.
5
+ * @param locale Locale string or `undefined` for the root locale.
6
+ */
7
+ export function localeToLang(config: StarlightConfig, locale: string | undefined): string {
8
+ const lang = locale ? config.locales?.[locale]?.lang : config.locales?.root?.lang;
9
+ const defaultLang = config.defaultLocale?.lang || config.defaultLocale?.locale;
10
+ return lang || defaultLang || 'en';
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.21.2",
3
+ "version": "0.21.4",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
@@ -194,7 +194,6 @@
194
194
  "rehype": "^13.0.1",
195
195
  "remark-directive": "^3.0.0",
196
196
  "unified": "^11.0.4",
197
- "unist-util-remove": "^4.0.0",
198
197
  "unist-util-visit": "^5.0.0",
199
198
  "vfile": "^6.0.1"
200
199
  },
@@ -1,11 +1,11 @@
1
1
  {
2
- "skipLink.label": "Пропустить до содержимого",
2
+ "skipLink.label": "Перейти к содержимому",
3
3
  "search.label": "Поиск",
4
- "search.shortcutLabel": "(Нажмите / для Поиска)",
4
+ "search.shortcutLabel": "(Нажмите / для поиска)",
5
5
  "search.cancelLabel": "Отменить",
6
6
  "search.devWarning": "Поиск доступен только в производственных сборках. \nПопробуйте выполнить сборку и просмотреть сайт, чтобы протестировать его локально.",
7
7
  "themeSelect.accessibleLabel": "Выберите тему",
8
- "themeSelect.dark": "Темная",
8
+ "themeSelect.dark": "Тёмная",
9
9
  "themeSelect.light": "Светлая",
10
10
  "themeSelect.auto": "Авто",
11
11
  "languageSelect.accessibleLabel": "Выберите язык",
@@ -18,10 +18,10 @@
18
18
  "page.lastUpdated": "Последнее обновление:",
19
19
  "page.previousLink": "Предыдущая",
20
20
  "page.nextLink": "Следующая",
21
- "404.text": "Страница не найдена. Проверьтье URL или используйте поиск по сайту",
21
+ "404.text": "Страница не найдена. Проверьте URL или используйте поиск по сайту.",
22
22
  "aside.note": "Заметка",
23
23
  "aside.tip": "Знали ли вы?",
24
24
  "aside.caution": "Осторожно",
25
25
  "aside.danger": "Опасно",
26
- "fileTree.directory": "Directory"
26
+ "fileTree.directory": "Директория"
27
27
  }
@@ -23,5 +23,5 @@
23
23
  "aside.tip": "提示",
24
24
  "aside.caution": "警告",
25
25
  "aside.danger": "危險",
26
- "fileTree.directory": "Directory"
26
+ "fileTree.directory": "目錄"
27
27
  }