@astrojs/starlight 0.21.4 → 0.21.5
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 +12 -0
- package/components/Icons.ts +1 -0
- package/integrations/shared/pathToLocale.ts +2 -1
- package/package.json +1 -1
- package/user-components/Tabs.astro +4 -4
- package/user-components/file-tree-icons.ts +1 -0
- package/user-components/rehype-file-tree.ts +1 -1
- package/utils/user-config.ts +12 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.21.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1728](https://github.com/withastro/starlight/pull/1728) [`0a75680d`](https://github.com/withastro/starlight/commit/0a75680ddd2f3325ab9ad7ac910f7c884b89a9ed) Thanks [@delucis](https://github.com/delucis)! - Adds 1 new icon: `pkl`
|
|
8
|
+
|
|
9
|
+
- [#1709](https://github.com/withastro/starlight/pull/1709) [`c5cd1811`](https://github.com/withastro/starlight/commit/c5cd181186b42422f3e47052bf8182cb490bda6b) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a UI strings translation issue for sites configured with a single non-root language different from English.
|
|
10
|
+
|
|
11
|
+
- [#1723](https://github.com/withastro/starlight/pull/1723) [`3b29b3ab`](https://github.com/withastro/starlight/commit/3b29b3ab824f538f27e20310cb08786a92c7bd65) Thanks [@OliverSpeir](https://github.com/OliverSpeir)! - Fixes accessibility by using `aria-selected="false"` for inactive tabs instead of removing `aria-selected="true"` in the tablist of Starlight’s `<Tabs>` component
|
|
12
|
+
|
|
13
|
+
- [#1706](https://github.com/withastro/starlight/pull/1706) [`f171ac4d`](https://github.com/withastro/starlight/commit/f171ac4d6396eb2538598d85957670df50938b6a) Thanks [@jorenbroekema](https://github.com/jorenbroekema)! - Fixes some minor type errors
|
|
14
|
+
|
|
3
15
|
## 0.21.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/components/Icons.ts
CHANGED
|
@@ -125,6 +125,7 @@ export const BuiltInIcons = {
|
|
|
125
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
126
|
starlight:
|
|
127
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"/>',
|
|
128
|
+
pkl: '<path fill-rule="evenodd" d="M18.7 1.8 18 5a9 9 0 0 1 2 2.4l3.2.2c.4 1 .6 2 .7 3.1L21 12.2a9 9 0 0 1-.7 3l1.9 2.7c-.6 1-1.2 1.7-2 2.5l-3-1.3c-.9.6-1.9 1-2.9 1.4l-.9 3c-1 .2-2.1.2-3.2 0l-.8-3c-1-.4-2-.8-2.9-1.5l-3 1.3a12 12 0 0 1-2-2.5l2-2.6a9 9 0 0 1-.8-3L0 10.5c.1-1.1.3-2.1.7-3.1L4 7.3A9 9 0 0 1 6 5l-.6-3.2c1-.6 2-1 3-1.3l2 2.4c1.1-.2 2.2-.2 3.2 0L15.8.4c1 .3 2 .8 2.9 1.4Zm1 9.8c0 4.2-3.3 7.5-7.5 7.5a7.5 7.5 0 0 1-7.6-7.5c0-4.1 3.4-7.5 7.6-7.5 4.2 0 7.6 3.4 7.6 7.5Z"></path><path fill-opacity=".5" d="M11.4 10.8c-6.6-2.7-3.6-5.5.4-5.5 4.3 0 7.8 2.5 1.2 5.5a2 2 0 0 1-1.6 0Zm.4 1.9c1 7-3 5.8-5 2.5-2.1-3.7-1.7-8 4.2-3.9a2 2 0 0 1 .8 1.4Zm6.2 1.7c2-3.3 1-7.3-4.7-3a2 2 0 0 0-.8 1.4c-.7 7.1 3.3 5.4 5.5 1.7Z"/>',
|
|
128
129
|
};
|
|
129
130
|
|
|
130
131
|
export const Icons = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AstroConfig } from 'astro';
|
|
1
2
|
import type { StarlightConfig } from '../../types';
|
|
2
3
|
|
|
3
4
|
function slugToLocale(
|
|
@@ -17,7 +18,7 @@ export function pathToLocale(
|
|
|
17
18
|
astroConfig,
|
|
18
19
|
}: {
|
|
19
20
|
starlightConfig: { locales: StarlightConfig['locales'] };
|
|
20
|
-
astroConfig: { root:
|
|
21
|
+
astroConfig: { root: AstroConfig['root']; srcDir: AstroConfig['srcDir'] };
|
|
21
22
|
}
|
|
22
23
|
): string | undefined {
|
|
23
24
|
const srcDir = new URL(astroConfig.srcDir, astroConfig.root);
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ const { html, panels } = processPanels(panelHtml);
|
|
|
17
17
|
role="tab"
|
|
18
18
|
href={'#' + panelId}
|
|
19
19
|
id={tabId}
|
|
20
|
-
aria-selected={idx === 0
|
|
20
|
+
aria-selected={idx === 0 ? 'true' : 'false'}
|
|
21
21
|
tabindex={idx !== 0 ? -1 : 0}
|
|
22
22
|
>
|
|
23
23
|
{icon && <Icon name={icon} />}
|
|
@@ -61,7 +61,7 @@ const { html, panels } = processPanels(panelHtml);
|
|
|
61
61
|
color: var(--sl-color-gray-3);
|
|
62
62
|
outline-offset: var(--sl-outline-offset-inside);
|
|
63
63
|
}
|
|
64
|
-
.tab [role='tab'][aria-selected] {
|
|
64
|
+
.tab [role='tab'][aria-selected='true'] {
|
|
65
65
|
color: var(--sl-color-white);
|
|
66
66
|
border-color: var(--sl-color-text-accent);
|
|
67
67
|
font-weight: 600;
|
|
@@ -87,7 +87,7 @@ const { html, panels } = processPanels(panelHtml);
|
|
|
87
87
|
// Handle clicks for mouse users
|
|
88
88
|
tab.addEventListener('click', (e) => {
|
|
89
89
|
e.preventDefault();
|
|
90
|
-
const currentTab = tablist.querySelector('[aria-selected]');
|
|
90
|
+
const currentTab = tablist.querySelector('[aria-selected="true"]');
|
|
91
91
|
if (e.currentTarget !== currentTab) {
|
|
92
92
|
this.switchTab(e.currentTarget as HTMLAnchorElement, i);
|
|
93
93
|
}
|
|
@@ -122,7 +122,7 @@ const { html, panels } = processPanels(panelHtml);
|
|
|
122
122
|
|
|
123
123
|
// Mark all tabs as unselected and hide all tab panels.
|
|
124
124
|
this.tabs.forEach((tab) => {
|
|
125
|
-
tab.
|
|
125
|
+
tab.setAttribute('aria-selected', 'false');
|
|
126
126
|
tab.setAttribute('tabindex', '-1');
|
|
127
127
|
});
|
|
128
128
|
this.panels.forEach((oldPanel) => {
|
|
@@ -168,7 +168,7 @@ function getFileIcon(fileName: string) {
|
|
|
168
168
|
|
|
169
169
|
/** Return the icon name for a file based on its file name. */
|
|
170
170
|
function getFileIconName(fileName: string) {
|
|
171
|
-
let icon = definitions.files[fileName];
|
|
171
|
+
let icon: string | undefined = definitions.files[fileName];
|
|
172
172
|
if (icon) return icon;
|
|
173
173
|
icon = getFileIconTypeFromExtension(fileName);
|
|
174
174
|
if (icon) return icon;
|
package/utils/user-config.ts
CHANGED
|
@@ -212,16 +212,20 @@ const UserConfigSchema = z.object({
|
|
|
212
212
|
|
|
213
213
|
export const StarlightConfigSchema = UserConfigSchema.strict().transform(
|
|
214
214
|
({ locales, defaultLocale, ...config }, ctx) => {
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
const configuredLocales = Object.keys(locales ?? {});
|
|
216
|
+
|
|
217
|
+
// This is a multilingual site (more than one locale configured) or a monolingual site with
|
|
218
|
+
// only one locale configured (not a root locale).
|
|
219
|
+
// Monolingual sites with only one non-root locale needs their configuration to be defined in
|
|
220
|
+
// `config.locales` so that slugs can be correctly generated by taking into consideration the
|
|
221
|
+
// base path at which a language is served which is the key of the `config.locales` object.
|
|
222
|
+
if (locales !== undefined && configuredLocales.length >= 1) {
|
|
217
223
|
// Make sure we can find the default locale and if not, help the user set it.
|
|
218
224
|
// We treat the root locale as the default if present and no explicit default is set.
|
|
219
225
|
const defaultLocaleConfig = locales[defaultLocale || 'root'];
|
|
220
226
|
|
|
221
227
|
if (!defaultLocaleConfig) {
|
|
222
|
-
const availableLocales =
|
|
223
|
-
.map((l) => `"${l}"`)
|
|
224
|
-
.join(', ');
|
|
228
|
+
const availableLocales = configuredLocales.map((l) => `"${l}"`).join(', ');
|
|
225
229
|
ctx.addIssue({
|
|
226
230
|
code: 'custom',
|
|
227
231
|
message:
|
|
@@ -235,14 +239,15 @@ export const StarlightConfigSchema = UserConfigSchema.strict().transform(
|
|
|
235
239
|
return {
|
|
236
240
|
...config,
|
|
237
241
|
/** Flag indicating if this site has multiple locales set up. */
|
|
238
|
-
isMultilingual:
|
|
242
|
+
isMultilingual: configuredLocales.length > 1,
|
|
239
243
|
/** Full locale object for this site’s default language. */
|
|
240
244
|
defaultLocale: { ...defaultLocaleConfig, locale: defaultLocale },
|
|
241
245
|
locales,
|
|
242
246
|
} as const;
|
|
243
247
|
}
|
|
244
248
|
|
|
245
|
-
// This is a monolingual site, so things are
|
|
249
|
+
// This is a monolingual site with no locales configured or only a root locale, so things are
|
|
250
|
+
// pretty simple.
|
|
246
251
|
return {
|
|
247
252
|
...config,
|
|
248
253
|
/** Flag indicating if this site has multiple locales set up. */
|