@astrojs/starlight 0.30.3 → 0.30.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 +19 -1
- package/components/Icons.ts +15 -0
- package/components/Page.astro +9 -6
- package/package.json +1 -1
- package/schemas/social.ts +6 -0
- package/user-components/Tabs.astro +1 -0
- package/utils/navigation.ts +6 -7
- package/utils/path.ts +6 -0
- package/utils/translations.ts +13 -2
- package/virtual-internal.d.ts +0 -13
- package/virtual.d.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.30.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2757](https://github.com/withastro/starlight/pull/2757) [`e7b0e74`](https://github.com/withastro/starlight/commit/e7b0e742dffb7c4a8f4619297e4bd6e5a8015edb) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a UI string translation issue for languages with a region subtag.
|
|
8
|
+
|
|
9
|
+
- [#2760](https://github.com/withastro/starlight/pull/2760) [`aec9edd`](https://github.com/withastro/starlight/commit/aec9edd14827a45fbc92d82db83dd713571e0c2d) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds 5 new icons: `left-caret`, `up-arrow`, `down-arrow`, `download`, and `cloud-download`.
|
|
10
|
+
|
|
11
|
+
## 0.30.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#2747](https://github.com/withastro/starlight/pull/2747) [`474c27e`](https://github.com/withastro/starlight/commit/474c27e28d79794ac78d36e3384f0c0da6f2dfed) Thanks [@bbag](https://github.com/bbag)! - Ensures `<Tab>` component toggling is stable when smooth scrolling is enabled via custom CSS
|
|
16
|
+
|
|
17
|
+
- [#2740](https://github.com/withastro/starlight/pull/2740) [`0e169c9`](https://github.com/withastro/starlight/commit/0e169c9fd9fbfc16d86225db6b00448edf39ffad) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue preventing Pagefind to be disabled using the `pagefind` frontmatter field.
|
|
18
|
+
|
|
19
|
+
- [#2732](https://github.com/withastro/starlight/pull/2732) [`a10b466`](https://github.com/withastro/starlight/commit/a10b46680810882b029dd1d578cc86e22bc97af5) Thanks [@Sidnioulz](https://github.com/Sidnioulz)! - Adds Storybook, Confluence and Jira social icons
|
|
20
|
+
|
|
3
21
|
## 0.30.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -640,7 +658,7 @@
|
|
|
640
658
|
|
|
641
659
|
- [#1837](https://github.com/withastro/starlight/pull/1837) [`a33a1223`](https://github.com/withastro/starlight/commit/a33a12231772c1dc4b7cc2db3477a6802f3ef53e) Thanks [@delucis](https://github.com/delucis)! - Adds three new icons: `comment`, `comment-alt`, `heart`
|
|
642
660
|
|
|
643
|
-
- [#1842](https://github.com/withastro/starlight/pull/1842) [`c7838636`](https://github.com/withastro/starlight/commit/c7838636edb8d60a2422ce76a2db511b9cebbb70) Thanks [@delucis](https://github.com/delucis)! - Moves the `href` used in the site title link to Starlight’s route data object. This makes it possible for overrides to change the title link while reusing Starlight’s default component
|
|
661
|
+
- [#1842](https://github.com/withastro/starlight/pull/1842) [`c7838636`](https://github.com/withastro/starlight/commit/c7838636edb8d60a2422ce76a2db511b9cebbb70) Thanks [@delucis](https://github.com/delucis)! - Moves the `href` used in the site title link to Starlight’s route data object. This makes it possible for overrides to change the title link while reusing Starlight’s default component implementation.
|
|
644
662
|
|
|
645
663
|
- [#1840](https://github.com/withastro/starlight/pull/1840) [`cb85563c`](https://github.com/withastro/starlight/commit/cb85563c9a3d4eb2925ad884e6a4e8698a15381b) Thanks [@MiahaCybersec](https://github.com/MiahaCybersec)! - Adds 1 new icon: `hackerone`
|
|
646
664
|
|
package/components/Icons.ts
CHANGED
|
@@ -7,6 +7,12 @@ export const BuiltInIcons = {
|
|
|
7
7
|
'<path d="M17 9.17a1 1 0 0 0-1.41 0L12 12.71 8.46 9.17a1 1 0 1 0-1.41 1.42l4.24 4.24a1.002 1.002 0 0 0 1.42 0L17 10.59a1.002 1.002 0 0 0 0-1.42Z"/>',
|
|
8
8
|
'right-caret':
|
|
9
9
|
'<path d="m14.83 11.29-4.24-4.24a1 1 0 1 0-1.42 1.41L12.71 12l-3.54 3.54a1 1 0 0 0 0 1.41 1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29l4.24-4.24a1.002 1.002 0 0 0 0-1.42Z"/>',
|
|
10
|
+
'left-caret':
|
|
11
|
+
'<path d="m11.29 12 3.54-3.54a1 1 0 0 0 0-1.41 1 1 0 0 0-1.42 0l-4.24 4.24a1 1 0 0 0 0 1.42L13.41 17a1 1 0 0 0 .71.29 1 1 0 0 0 .71-.29 1 1 0 0 0 0-1.41Z"/>',
|
|
12
|
+
'up-arrow':
|
|
13
|
+
'<path d="m17.71 11.29-5-5a1 1 0 0 0-.33-.21 1 1 0 0 0-.76 0 1 1 0 0 0-.33.21l-5 5a1 1 0 0 0 1.42 1.42L11 9.41V17a1 1 0 0 0 2 0V9.41l3.29 3.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42Z"/>',
|
|
14
|
+
'down-arrow':
|
|
15
|
+
'<path d="M17.71 11.29a1 1 0 0 0-1.42 0L13 14.59V7a1 1 0 0 0-2 0v7.59l-3.29-3.3a1 1 0 0 0-1.42 1.42l5 5a1 1 0 0 0 .33.21.94.94 0 0 0 .76 0 1 1 0 0 0 .33-.21l5-5a1 1 0 0 0 0-1.42Z"/>',
|
|
10
16
|
'right-arrow':
|
|
11
17
|
'<path d="M17.92 11.62a1.001 1.001 0 0 0-.21-.33l-5-5a1.003 1.003 0 1 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1.002 1.002 0 0 0 .325 1.639 1 1 0 0 0 1.095-.219l5-5a1 1 0 0 0 .21-.33 1 1 0 0 0 0-.76Z"/>',
|
|
12
18
|
'left-arrow':
|
|
@@ -25,6 +31,10 @@ export const BuiltInIcons = {
|
|
|
25
31
|
'<path d="m21.32 9.55-1.89-.63.89-1.78A1 1 0 0 0 20.13 6L18 3.87a1 1 0 0 0-1.15-.19l-1.78.89-.63-1.89A1 1 0 0 0 13.5 2h-3a1 1 0 0 0-.95.68l-.63 1.89-1.78-.89A1 1 0 0 0 6 3.87L3.87 6a1 1 0 0 0-.19 1.15l.89 1.78-1.89.63a1 1 0 0 0-.68.94v3a1 1 0 0 0 .68.95l1.89.63-.89 1.78A1 1 0 0 0 3.87 18L6 20.13a1 1 0 0 0 1.15.19l1.78-.89.63 1.89a1 1 0 0 0 .95.68h3a1 1 0 0 0 .95-.68l.63-1.89 1.78.89a1 1 0 0 0 1.13-.19L20.13 18a1 1 0 0 0 .19-1.15l-.89-1.78 1.89-.63a1 1 0 0 0 .68-.94v-3a1 1 0 0 0-.68-.95ZM20 12.78l-1.2.4A2 2 0 0 0 17.64 16l.57 1.14-1.1 1.1-1.11-.6a2 2 0 0 0-2.79 1.16l-.4 1.2h-1.59l-.4-1.2A2 2 0 0 0 8 17.64l-1.14.57-1.1-1.1.6-1.11a2 2 0 0 0-1.16-2.82l-1.2-.4v-1.56l1.2-.4A2 2 0 0 0 6.36 8l-.57-1.11 1.1-1.1L8 6.36a2 2 0 0 0 2.82-1.16l.4-1.2h1.56l.4 1.2A2 2 0 0 0 16 6.36l1.14-.57 1.1 1.1-.6 1.11a2 2 0 0 0 1.16 2.79l1.2.4v1.59ZM12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm0 6a2 2 0 1 1 0-4 2 2 0 0 1 0 4Z"/>',
|
|
26
32
|
external:
|
|
27
33
|
'<path d="M19.33 10.18a1 1 0 0 1-.77 0 1 1 0 0 1-.62-.93l.01-1.83-8.2 8.2a1 1 0 0 1-1.41-1.42l8.2-8.2H14.7a1 1 0 0 1 0-2h4.25a1 1 0 0 1 1 1v4.25a1 1 0 0 1-.62.93Z"/><path d="M11 4a1 1 0 1 1 0 2H7a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1v-4a1 1 0 1 1 2 0v4a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h4Z"/>',
|
|
34
|
+
download:
|
|
35
|
+
'<path d="M8.29 13.29a1 1 0 0 0 0 1.42l3 3a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0-1.42-1.42L13 14.59V3a1 1 0 0 0-2 0v11.59l-1.29-1.3a1 1 0 0 0-1.42 0ZM18 9h-2a1 1 0 0 0 0 2h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h2a1 1 0 0 0 0-2H6a3 3 0 0 0-3 3v7a3 3 0 0 0 3 3h12a3 3 0 0 0 3-3v-7a3 3 0 0 0-3-3Z"/>',
|
|
36
|
+
'cloud-download':
|
|
37
|
+
'<path d="M14.29 17.29 13 18.59V13a1 1 0 0 0-2 0v5.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21.94.94 0 0 0 .76 0 1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42Zm4.13-11.07A7 7 0 0 0 5.06 8.11 4 4 0 0 0 6 16a1 1 0 0 0 0-2 2 2 0 0 1 0-4 1 1 0 0 0 1-1 5 5 0 0 1 9.73-1.61 1 1 0 0 0 .78.67 3 3 0 0 1 .24 5.84 1 1 0 1 0 .5 1.94 5 5 0 0 0 .17-9.62Z"/>',
|
|
28
38
|
moon: '<path d="M21.64 13a1 1 0 0 0-1.05-.14 8.049 8.049 0 0 1-3.37.73 8.15 8.15 0 0 1-8.14-8.1 8.59 8.59 0 0 1 .25-2A1 1 0 0 0 8 2.36a10.14 10.14 0 1 0 14 11.69 1 1 0 0 0-.36-1.05Zm-9.5 6.69A8.14 8.14 0 0 1 7.08 5.22v.27a10.15 10.15 0 0 0 10.14 10.14 9.784 9.784 0 0 0 2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 3.6a6.1 6.1 0 0 0 3 1c1.5 0 2.8-.5 3.7-1.5.7-.6 1.1-1.5 1.1-2.2V20l-.6.7zM19.7 9l-.1.2-1.2.8a5.2 5.2 0 0 1-1.5.5 5.2 5.2 0 0 1-.8 0l.1.4V12a4.6 4.6 0 0 0 1.5-.3A4.4 4.4 0 0 0 19 11l.1-.1a4.5 4.5 0 0 0 .8-1.1 2.6 2.6 0 0 0 .3-1.1v-.1l-.2.1-.4.6zm0 4.3a6 6 0 0 1-.1.1 5.2 5.2 0 0 1-3.3 1.5v1.4a4.5 4.5 0 0 0 2.8-1.2l1-1.2.2-1v-.1l-.2.2a4.8 4.8 0 0 1-.4.5zm0-2.1-.1.1a4.8 4.8 0 0 1-.6.5 5.2 5.2 0 0 1-2.7 1v1.4A4.5 4.5 0 0 0 19 13h.1a4.2 4.2 0 0 0 .8-1.2l.3-.9v-.3a4 4 0 0 1-.2.2l-.4.5z"/>',
|
|
177
|
+
confluence:
|
|
178
|
+
'<path d="M.85 18.07.1 19.32a.76.76 0 0 0-.1.28.76.76 0 0 0 .02.28.75.75 0 0 0 .33.46l4.97 3.07a.76.76 0 0 0 .86-.03.75.75 0 0 0 .2-.23l.73-1.23c1.97-3.23 3.97-2.83 7.54-1.14l4.93 2.34a.76.76 0 0 0 .6.03.76.76 0 0 0 .43-.4l2.36-5.35a.75.75 0 0 0 .02-.57.77.77 0 0 0-.38-.43c-1.04-.49-3.1-1.45-4.96-2.36C10.9 10.8 5.2 11 .85 18.07Z"/><path d="m23.15 5.94.75-1.25a.77.77 0 0 0 .08-.57.76.76 0 0 0-.13-.27.76.76 0 0 0-.22-.2L18.67.6a.76.76 0 0 0-.29-.1.77.77 0 0 0-.57.13.77.77 0 0 0-.2.23l-.73 1.22c-1.98 3.25-3.96 2.86-7.53 1.16L4.42.89a.78.78 0 0 0-.59-.03.76.76 0 0 0-.26.15.76.76 0 0 0-.18.24L1.02 6.61a.77.77 0 0 0-.02.57c.04.1.09.18.15.25a.76.76 0 0 0 .24.18c1.04.5 3.11 1.45 4.96 2.36 6.73 3.26 12.44 3.04 16.8-4.03z"/>',
|
|
179
|
+
jira: '<path d="M7.75 16.3H5.62C2.4 16.3.09 14.31.09 11.43h11.47c.6 0 .98.42.98 1.02V24c-2.87 0-4.79-2.32-4.79-5.56Zm5.67-5.74h-2.14c-3.21 0-5.52-1.94-5.52-4.82h11.47c.6 0 1.01.38 1.01.98v11.54c-2.87 0-4.82-2.32-4.82-5.56zm5.7-5.7h-2.14c-3.21 0-5.52-1.97-5.52-4.86h11.47c.6 0 .98.42.98.99v11.54c-2.87 0-4.8-2.32-4.8-5.56z"/>',
|
|
180
|
+
storybook:
|
|
181
|
+
'<path d="m20.35 0-1.32.08.1 2.78a.18.18 0 0 1-.3.14l-.9-.7-1.05.8a.18.18 0 0 1-.25-.03.18.18 0 0 1-.04-.12l.12-2.72-13.21.82A1.2 1.2 0 0 0 2.37 2.3l.74 19.82a1.2 1.2 0 0 0 1.15 1.16l16.11.72h.06c.66 0 1.2-.54 1.2-1.2V1.12A1.2 1.2 0 0 0 20.35 0zm-7.99 4.08c3.14 0 4.86 1.68 4.86 4.88-.42.33-3.59.56-3.59.09.07-1.8-.73-1.87-1.18-1.87-.42 0-1.13.12-1.13 1.08 0 2.37 6.1 2.24 6.1 7.02 0 2.69-2.18 4.17-4.97 4.17-2.87 0-5.38-1.16-5.1-5.2.11-.47 3.77-.35 3.77 0-.05 1.67.33 2.16 1.29 2.16.73 0 1.07-.4 1.07-1.09 0-2.43-6.02-2.51-6.02-6.97 0-2.56 1.76-4.27 4.9-4.27z"/>',
|
|
167
182
|
};
|
|
168
183
|
|
|
169
184
|
export const Icons = {
|
package/components/Page.astro
CHANGED
|
@@ -36,13 +36,16 @@ const pagefindEnabled =
|
|
|
36
36
|
!Astro.props.entry.slug.endsWith('/404') &&
|
|
37
37
|
Astro.props.entry.data.pagefind !== false;
|
|
38
38
|
|
|
39
|
-
const
|
|
40
|
-
if (Boolean(Astro.props.toc))
|
|
41
|
-
if (Astro.props.hasSidebar)
|
|
42
|
-
if (Boolean(Astro.props.entry.data.hero))
|
|
39
|
+
const htmlDataAttributes: DOMStringMap = { 'data-theme': 'dark' };
|
|
40
|
+
if (Boolean(Astro.props.toc)) htmlDataAttributes['data-has-toc'] = '';
|
|
41
|
+
if (Astro.props.hasSidebar) htmlDataAttributes['data-has-sidebar'] = '';
|
|
42
|
+
if (Boolean(Astro.props.entry.data.hero)) htmlDataAttributes['data-has-hero'] = '';
|
|
43
|
+
|
|
44
|
+
const mainDataAttributes: DOMStringMap = {};
|
|
45
|
+
if (pagefindEnabled) mainDataAttributes['data-pagefind-body'] = '';
|
|
43
46
|
---
|
|
44
47
|
|
|
45
|
-
<html lang={Astro.props.lang} dir={Astro.props.dir} {...
|
|
48
|
+
<html lang={Astro.props.lang} dir={Astro.props.dir} {...htmlDataAttributes}>
|
|
46
49
|
<head>
|
|
47
50
|
<Head {...Astro.props} />
|
|
48
51
|
<style>
|
|
@@ -82,7 +85,7 @@ if (Boolean(Astro.props.entry.data.hero)) dataAttributes['data-has-hero'] = '';
|
|
|
82
85
|
<TwoColumnContent {...Astro.props}>
|
|
83
86
|
<PageSidebar slot="right-sidebar" {...Astro.props} />
|
|
84
87
|
<main
|
|
85
|
-
|
|
88
|
+
{...mainDataAttributes}
|
|
86
89
|
lang={Astro.props.entryMeta.lang}
|
|
87
90
|
dir={Astro.props.entryMeta.dir}
|
|
88
91
|
>
|
package/package.json
CHANGED
package/schemas/social.ts
CHANGED
|
@@ -38,6 +38,9 @@ export const socialLinks = [
|
|
|
38
38
|
'nostr',
|
|
39
39
|
'backstage',
|
|
40
40
|
'farcaster',
|
|
41
|
+
'confluence',
|
|
42
|
+
'jira',
|
|
43
|
+
'storybook',
|
|
41
44
|
] as const;
|
|
42
45
|
|
|
43
46
|
export const SocialLinksSchema = () =>
|
|
@@ -91,6 +94,9 @@ export const SocialLinksSchema = () =>
|
|
|
91
94
|
nostr: 'Nostr',
|
|
92
95
|
backstage: 'Backstage',
|
|
93
96
|
farcaster: 'Farcaster',
|
|
97
|
+
confluence: 'Confluence',
|
|
98
|
+
jira: 'Jira',
|
|
99
|
+
storybook: 'Storybook',
|
|
94
100
|
}[key];
|
|
95
101
|
labelledLinks[key] = { label, url };
|
|
96
102
|
}
|
package/utils/navigation.ts
CHANGED
|
@@ -13,7 +13,12 @@ import type {
|
|
|
13
13
|
import { createPathFormatter } from './createPathFormatter';
|
|
14
14
|
import { formatPath } from './format-path';
|
|
15
15
|
import { BuiltInDefaultLocale, pickLang } from './i18n';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ensureLeadingSlash,
|
|
18
|
+
ensureTrailingSlash,
|
|
19
|
+
stripExtension,
|
|
20
|
+
stripLeadingAndTrailingSlashes,
|
|
21
|
+
} from './path';
|
|
17
22
|
import { getLocaleRoutes, routes, type Route } from './routing';
|
|
18
23
|
import { localeToLang, localizedId, slugToPathname } from './slugs';
|
|
19
24
|
import type { StarlightConfig } from './user-config';
|
|
@@ -510,12 +515,6 @@ function applyPrevNextLinkConfig(
|
|
|
510
515
|
return paginationEnabled ? link : undefined;
|
|
511
516
|
}
|
|
512
517
|
|
|
513
|
-
/** Remove the extension from a path. */
|
|
514
|
-
function stripExtension(path: string) {
|
|
515
|
-
const periodIndex = path.lastIndexOf('.');
|
|
516
|
-
return path.slice(0, periodIndex > -1 ? periodIndex : undefined);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
518
|
/** Get a sidebar badge for a given item. */
|
|
520
519
|
function getSidebarBadge(
|
|
521
520
|
config: I18nBadgeConfig,
|
package/utils/path.ts
CHANGED
|
@@ -50,3 +50,9 @@ export function ensureHtmlExtension(path: string) {
|
|
|
50
50
|
}
|
|
51
51
|
return ensureLeadingSlash(path);
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
/** Remove the extension from a path. */
|
|
55
|
+
export function stripExtension(path: string) {
|
|
56
|
+
const periodIndex = path.lastIndexOf('.');
|
|
57
|
+
return path.slice(0, periodIndex > -1 ? periodIndex : undefined);
|
|
58
|
+
}
|
package/utils/translations.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { getCollection, type CollectionEntry, type DataCollectionKey } from 'astro:content';
|
|
2
2
|
import config from 'virtual:starlight/user-config';
|
|
3
|
+
import project from 'virtual:starlight/project-context';
|
|
3
4
|
import pluginTranslations from 'virtual:starlight/plugin-translations';
|
|
4
5
|
import type { i18nSchemaOutput } from '../schemas/i18n';
|
|
5
6
|
import { createTranslationSystem } from './createTranslationSystem';
|
|
6
7
|
import type { RemoveIndexSignature } from './types';
|
|
8
|
+
import { getCollectionPathFromRoot } from './collection';
|
|
9
|
+
import { stripExtension, stripLeadingSlash } from './path';
|
|
7
10
|
|
|
8
11
|
// @ts-ignore - This may be a type error in projects without an i18n collection and running
|
|
9
12
|
// `tsc --noEmit` in their project. Note that it is not possible to inline this type in
|
|
10
13
|
// `UserI18nSchema` because this would break types for users having multiple data collections.
|
|
11
14
|
type i18nCollection = CollectionEntry<'i18n'>;
|
|
12
15
|
|
|
16
|
+
const i18nCollectionPathFromRoot = getCollectionPathFromRoot('i18n', project);
|
|
17
|
+
|
|
13
18
|
export type UserI18nSchema = 'i18n' extends DataCollectionKey
|
|
14
19
|
? i18nCollection extends { data: infer T }
|
|
15
20
|
? i18nSchemaOutput & T
|
|
@@ -17,14 +22,20 @@ export type UserI18nSchema = 'i18n' extends DataCollectionKey
|
|
|
17
22
|
: i18nSchemaOutput;
|
|
18
23
|
export type UserI18nKeys = keyof RemoveIndexSignature<UserI18nSchema>;
|
|
19
24
|
|
|
20
|
-
/** Get all translation data from the i18n collection, keyed by `
|
|
25
|
+
/** Get all translation data from the i18n collection, keyed by `lang`, which are BCP-47 language tags. */
|
|
21
26
|
async function loadTranslations() {
|
|
22
27
|
// Briefly override `console.warn()` to silence logging when a project has no i18n collection.
|
|
23
28
|
const warn = console.warn;
|
|
24
29
|
console.warn = () => {};
|
|
25
30
|
const userTranslations: Record<string, UserI18nSchema> = Object.fromEntries(
|
|
26
31
|
// @ts-ignore — may be a type error in projects without an i18n collection
|
|
27
|
-
(await getCollection('i18n')).map(({ id, data }) =>
|
|
32
|
+
(await getCollection('i18n')).map(({ id, data, filePath }) => {
|
|
33
|
+
const lang =
|
|
34
|
+
project.legacyCollections || !filePath
|
|
35
|
+
? id
|
|
36
|
+
: stripExtension(stripLeadingSlash(filePath.replace(i18nCollectionPathFromRoot, '')));
|
|
37
|
+
return [lang, data] as const;
|
|
38
|
+
})
|
|
28
39
|
);
|
|
29
40
|
// Restore the original warn implementation.
|
|
30
41
|
console.warn = warn;
|
package/virtual-internal.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
declare module 'virtual:starlight/project-context' {
|
|
2
|
-
const ProjectContext: {
|
|
3
|
-
root: string;
|
|
4
|
-
srcDir: string;
|
|
5
|
-
trailingSlash: import('astro').AstroConfig['trailingSlash'];
|
|
6
|
-
build: {
|
|
7
|
-
format: import('astro').AstroConfig['build']['format'];
|
|
8
|
-
};
|
|
9
|
-
legacyCollections: boolean;
|
|
10
|
-
};
|
|
11
|
-
export default ProjectContext;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
1
|
declare module 'virtual:starlight/git-info' {
|
|
15
2
|
export function getNewestCommitDate(file: string): Date;
|
|
16
3
|
}
|
package/virtual.d.ts
CHANGED
|
@@ -7,3 +7,18 @@ declare module 'virtual:starlight/plugin-translations' {
|
|
|
7
7
|
const PluginTranslations: import('./utils/plugins').PluginTranslations;
|
|
8
8
|
export default PluginTranslations;
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
// TODO: Move back to `virtual-internal.d.ts` when possible. For example, when dropping support for
|
|
12
|
+
// legacy collections, `utils/translations.ts` would no longer need to import project context.
|
|
13
|
+
declare module 'virtual:starlight/project-context' {
|
|
14
|
+
const ProjectContext: {
|
|
15
|
+
root: string;
|
|
16
|
+
srcDir: string;
|
|
17
|
+
trailingSlash: import('astro').AstroConfig['trailingSlash'];
|
|
18
|
+
build: {
|
|
19
|
+
format: import('astro').AstroConfig['build']['format'];
|
|
20
|
+
};
|
|
21
|
+
legacyCollections: boolean;
|
|
22
|
+
};
|
|
23
|
+
export default ProjectContext;
|
|
24
|
+
}
|