starlight-versions 0.1.0 → 0.3.0
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/components/VersionSearch.astro +9 -9
- package/libs/starlight.ts +12 -1
- package/package.json +2 -2
|
@@ -13,12 +13,12 @@ import starlightVersionsConfig from 'virtual:starlight-versions-config'
|
|
|
13
13
|
|
|
14
14
|
import { getVersionFromSlug, getVersionIdentifier, getVersionURL } from '../libs/versions'
|
|
15
15
|
|
|
16
|
-
const { entry
|
|
16
|
+
const { entry } = Astro.props
|
|
17
17
|
|
|
18
18
|
const pagefindTranslations = {
|
|
19
|
-
placeholder:
|
|
19
|
+
placeholder: Astro.locals.t('search.label'),
|
|
20
20
|
...Object.fromEntries(
|
|
21
|
-
Object.entries(
|
|
21
|
+
Object.entries(Astro.locals.t.all())
|
|
22
22
|
.filter(([key]) => key.startsWith('pagefind.'))
|
|
23
23
|
.map(([key, value]) => [key.replace('pagefind.', ''), value]),
|
|
24
24
|
),
|
|
@@ -35,20 +35,20 @@ const pageVersionIdentifier = getVersionIdentifier(pageVersion)
|
|
|
35
35
|
data-pagefind-filter={`version:${pageVersionIdentifier}`}
|
|
36
36
|
>
|
|
37
37
|
<button data-open-modal disabled>
|
|
38
|
-
<Icon name="magnifier" label={
|
|
39
|
-
<span class="sl-hidden md:sl-block" aria-hidden="true">{
|
|
40
|
-
<Icon name="forward-slash" class="sl-hidden md:sl-block" label={
|
|
38
|
+
<Icon name="magnifier" label={Astro.locals.t('search.label')} />
|
|
39
|
+
<span class="sl-hidden md:sl-block" aria-hidden="true">{Astro.locals.t('search.label')}</span>
|
|
40
|
+
<Icon name="forward-slash" class="sl-hidden md:sl-block" label={Astro.locals.t('search.shortcutLabel')} />
|
|
41
41
|
</button>
|
|
42
42
|
|
|
43
|
-
<dialog style="padding:0" aria-label={
|
|
43
|
+
<dialog style="padding:0" aria-label={Astro.locals.t('search.label')}>
|
|
44
44
|
<div class="dialog-frame sl-flex">
|
|
45
45
|
<button data-close-modal class="sl-flex md:sl-hidden">
|
|
46
|
-
{
|
|
46
|
+
{Astro.locals.t('search.cancelLabel')}
|
|
47
47
|
</button>
|
|
48
48
|
{
|
|
49
49
|
import.meta.env.DEV ? (
|
|
50
50
|
<div style="margin: auto; text-align: center; white-space: pre-line;" dir="ltr">
|
|
51
|
-
<p>{
|
|
51
|
+
<p>{Astro.locals.t('search.devWarning')}</p>
|
|
52
52
|
</div>
|
|
53
53
|
) : (
|
|
54
54
|
<div class="search-container">
|
package/libs/starlight.ts
CHANGED
|
@@ -41,7 +41,9 @@ export function addPrefixToSidebarConfig(
|
|
|
41
41
|
sidebar: NonNullable<StarlightSidebarUserConfig>,
|
|
42
42
|
): NonNullable<StarlightSidebarUserConfig> {
|
|
43
43
|
return sidebar.map((item) => {
|
|
44
|
-
if ('
|
|
44
|
+
if (typeof item === 'string') {
|
|
45
|
+
return addPrefixToSlug(prefix, item)
|
|
46
|
+
} else if ('items' in item) {
|
|
45
47
|
return {
|
|
46
48
|
...item,
|
|
47
49
|
items: addPrefixToSidebarConfig(prefix, item.items),
|
|
@@ -54,6 +56,11 @@ export function addPrefixToSidebarConfig(
|
|
|
54
56
|
directory: path.posix.join(prefix, item.autogenerate.directory),
|
|
55
57
|
},
|
|
56
58
|
}
|
|
59
|
+
} else if ('slug' in item) {
|
|
60
|
+
return {
|
|
61
|
+
...item,
|
|
62
|
+
slug: addPrefixToSlug(prefix, item.slug),
|
|
63
|
+
}
|
|
57
64
|
} else if (isAbsoluteLink(item.link)) {
|
|
58
65
|
return item
|
|
59
66
|
}
|
|
@@ -68,6 +75,10 @@ export function addPrefixToSidebarConfig(
|
|
|
68
75
|
})
|
|
69
76
|
}
|
|
70
77
|
|
|
78
|
+
function addPrefixToSlug(prefix: string, slug: string) {
|
|
79
|
+
return `${prefix}/${slug}`
|
|
80
|
+
}
|
|
81
|
+
|
|
71
82
|
type StarlightFrontmatter = z.input<ReturnType<ReturnType<typeof docsSchema>>> & {
|
|
72
83
|
slug?: string
|
|
73
84
|
hero?: StarlightFrontmatteHero
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starlight-versions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Starlight plugin to version documentation pages.",
|
|
6
6
|
"author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"vitest": "^1.6.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@astrojs/starlight": ">=0.
|
|
43
|
+
"@astrojs/starlight": ">=0.28.0"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=18"
|