@astrojs/starlight 0.31.1 → 0.32.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/CHANGELOG.md +93 -0
- package/components/Banner.astro +1 -3
- package/components/ContentPanel.astro +0 -4
- package/components/DraftContentNotice.astro +0 -1
- package/components/EditLink.astro +1 -2
- package/components/FallbackContentNotice.astro +0 -1
- package/components/Footer.astro +3 -5
- package/components/Head.astro +1 -2
- package/components/Header.astro +5 -6
- package/components/Hero.astro +1 -2
- package/components/LanguageSelect.astro +2 -3
- package/components/LastUpdated.astro +1 -3
- package/components/MarkdownContent.astro +0 -1
- package/components/MobileMenuFooter.astro +3 -4
- package/components/MobileMenuToggle.astro +0 -1
- package/components/MobileTableOfContents.astro +1 -2
- package/components/Page.astro +32 -32
- package/components/PageFrame.astro +2 -3
- package/components/PageSidebar.astro +3 -5
- package/components/PageTitle.astro +1 -2
- package/components/Pagination.astro +1 -2
- package/components/Search.astro +17 -3
- package/components/Sidebar.astro +3 -5
- package/components/SidebarPersister.astro +1 -2
- package/components/SidebarSublist.astro +2 -1
- package/components/SiteTitle.astro +1 -2
- package/components/SkipLink.astro +0 -1
- package/components/SocialIcons.astro +0 -1
- package/components/StarlightPage.astro +7 -3
- package/components/TableOfContents.astro +1 -2
- package/components/ThemeProvider.astro +0 -1
- package/components/ThemeSelect.astro +0 -1
- package/components/TwoColumnContent.astro +1 -5
- package/index.ts +7 -9
- package/integrations/asides.ts +4 -7
- package/integrations/expressive-code/index.ts +15 -10
- package/integrations/shared/{pathToLocale.ts → absolutePathToLang.ts} +7 -5
- package/integrations/virtual-user-config.ts +27 -0
- package/locals.d.ts +26 -0
- package/locals.ts +36 -2
- package/package.json +5 -3
- package/props.ts +13 -1
- package/route-data.ts +11 -0
- package/routes/common.astro +5 -11
- package/routes/ssr/index.astro +1 -1
- package/routes/static/404.astro +1 -41
- package/routes/static/index.astro +1 -4
- package/schemas/pagefind.ts +97 -33
- package/types.ts +1 -0
- package/utils/i18n.ts +0 -20
- package/utils/navigation.ts +19 -36
- package/utils/plugins.ts +316 -141
- package/utils/{route-data.ts → routing/data.ts} +56 -30
- package/utils/{routing.ts → routing/index.ts} +6 -44
- package/utils/routing/middleware.ts +81 -0
- package/utils/routing/types.ts +96 -0
- package/utils/slugs.ts +2 -10
- package/utils/starlight-page.ts +2 -10
- package/utils/user-config.ts +8 -0
- package/virtual-internal.d.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,98 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2390](https://github.com/withastro/starlight/pull/2390) [`f493361`](https://github.com/withastro/starlight/commit/f493361d7b64a3279980e0f046c3a52196ab94e0) Thanks [@delucis](https://github.com/delucis)! - Moves route data to `Astro.locals` instead of passing it down via component props
|
|
8
|
+
|
|
9
|
+
⚠️ **Breaking change:**
|
|
10
|
+
Previously, all of Starlight’s templating components, including user or plugin overrides, had access to a data object for the current route via `Astro.props`.
|
|
11
|
+
This data is now available as `Astro.locals.starlightRoute` instead.
|
|
12
|
+
|
|
13
|
+
To update, refactor any component overrides you have:
|
|
14
|
+
|
|
15
|
+
- Remove imports of `@astrojs/starlight/props`, which is now deprecated.
|
|
16
|
+
- Update code that accesses `Astro.props` to use `Astro.locals.starlightRoute` instead.
|
|
17
|
+
- Remove any spreading of `{...Astro.props}` into child components, which is no longer required.
|
|
18
|
+
|
|
19
|
+
In the following example, a custom override for Starlight’s `LastUpdated` component is updated for the new style:
|
|
20
|
+
|
|
21
|
+
```diff
|
|
22
|
+
---
|
|
23
|
+
import Default from '@astrojs/starlight/components/LastUpdated.astro';
|
|
24
|
+
- import type { Props } from '@astrojs/starlight/props';
|
|
25
|
+
|
|
26
|
+
- const { lastUpdated } = Astro.props;
|
|
27
|
+
+ const { lastUpdated } = Astro.locals.starlightRoute;
|
|
28
|
+
|
|
29
|
+
const updatedThisYear = lastUpdated?.getFullYear() === new Date().getFullYear();
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
{updatedThisYear && (
|
|
33
|
+
- <Default {...Astro.props}><slot /></Default>
|
|
34
|
+
+ <Default><slot /></Default>
|
|
35
|
+
)}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
_Community Starlight plugins may also need to be manually updated to work with Starlight 0.32. If you encounter any issues, please reach out to the plugin author to see if it is a known issue or if an updated version is being worked on._
|
|
39
|
+
|
|
40
|
+
- [#2578](https://github.com/withastro/starlight/pull/2578) [`f895f75`](https://github.com/withastro/starlight/commit/f895f75b17f36c826cc871ba1826e5ae1dff44ca) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Deprecates the Starlight plugin `setup` hook in favor of the new `config:setup` hook which provides the same functionality.
|
|
41
|
+
|
|
42
|
+
⚠️ **BREAKING CHANGE:**
|
|
43
|
+
|
|
44
|
+
The Starlight plugin `setup` hook is now deprecated and will be removed in a future release. Please update your plugins to use the new `config:setup` hook instead.
|
|
45
|
+
|
|
46
|
+
```diff
|
|
47
|
+
export default {
|
|
48
|
+
name: 'plugin-with-translations',
|
|
49
|
+
hooks: {
|
|
50
|
+
- 'setup'({ config }) {
|
|
51
|
+
+ 'config:setup'({ config }) {
|
|
52
|
+
// Your plugin configuration setup code
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- [#2578](https://github.com/withastro/starlight/pull/2578) [`f895f75`](https://github.com/withastro/starlight/commit/f895f75b17f36c826cc871ba1826e5ae1dff44ca) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Exposes the built-in localization system in the Starlight plugin `config:setup` hook.
|
|
59
|
+
|
|
60
|
+
⚠️ **BREAKING CHANGE:**
|
|
61
|
+
|
|
62
|
+
This addition changes how Starlight plugins add or update translation strings used in Starlight’s localization APIs.
|
|
63
|
+
Plugins previously using the [`injectTranslations()`](https://starlight.astro.build/reference/plugins/#injecttranslations) callback function from the plugin [`config:setup`](https://starlight.astro.build/reference/plugins/#configsetup) hook should now use the same function available in the [`i18n:setup`](https://starlight.astro.build/reference/plugins/#i18nsetup) hook.
|
|
64
|
+
|
|
65
|
+
```diff
|
|
66
|
+
export default {
|
|
67
|
+
name: 'plugin-with-translations',
|
|
68
|
+
hooks: {
|
|
69
|
+
- 'config:setup'({ injectTranslations }) {
|
|
70
|
+
+ 'i18n:setup'({ injectTranslations }) {
|
|
71
|
+
injectTranslations({
|
|
72
|
+
en: {
|
|
73
|
+
'myPlugin.doThing': 'Do the thing',
|
|
74
|
+
},
|
|
75
|
+
fr: {
|
|
76
|
+
'myPlugin.doThing': 'Faire le truc',
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- [#2858](https://github.com/withastro/starlight/pull/2858) [`2df9d05`](https://github.com/withastro/starlight/commit/2df9d05fe7b61282809aa85a1d77662fdd3b748f) Thanks [@XREvo](https://github.com/XREvo)! - Adds support for Pagefind’s multisite search features
|
|
85
|
+
|
|
86
|
+
- [#2578](https://github.com/withastro/starlight/pull/2578) [`f895f75`](https://github.com/withastro/starlight/commit/f895f75b17f36c826cc871ba1826e5ae1dff44ca) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds a new [`HookParameters`](https://starlight.astro.build/reference/plugins/#hooks) utility type to get the type of a plugin hook’s arguments.
|
|
87
|
+
|
|
88
|
+
- [#2578](https://github.com/withastro/starlight/pull/2578) [`f895f75`](https://github.com/withastro/starlight/commit/f895f75b17f36c826cc871ba1826e5ae1dff44ca) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds a new [`useTranslations()`](https://starlight.astro.build/reference/plugins/#usetranslations) callback function to the Starlight plugin `config:setup` hook to generate a utility function to access UI strings for a given language.
|
|
89
|
+
|
|
90
|
+
- [#2578](https://github.com/withastro/starlight/pull/2578) [`f895f75`](https://github.com/withastro/starlight/commit/f895f75b17f36c826cc871ba1826e5ae1dff44ca) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds a new [`absolutePathToLang()`](https://starlight.astro.build/reference/plugins/#absolutepathtolang) callback function to the Starlight plugin `config:setup` to get the language for a given absolute file path.
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- [#2848](https://github.com/withastro/starlight/pull/2848) [`9b32ba9`](https://github.com/withastro/starlight/commit/9b32ba967c5741354bc99ba0bcff3f454b8117ad) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes styling of [filter](https://pagefind.app/docs/filtering/) and [metadata](https://pagefind.app/docs/metadata/) elements in Pagefind search UI.
|
|
95
|
+
|
|
3
96
|
## 0.31.1
|
|
4
97
|
|
|
5
98
|
### Patch Changes
|
package/components/Banner.astro
CHANGED
package/components/Footer.astro
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
---
|
|
2
|
-
import type { Props } from '../props';
|
|
3
|
-
|
|
4
2
|
import EditLink from 'virtual:starlight/components/EditLink';
|
|
5
3
|
import LastUpdated from 'virtual:starlight/components/LastUpdated';
|
|
6
4
|
import Pagination from 'virtual:starlight/components/Pagination';
|
|
@@ -10,10 +8,10 @@ import { Icon } from '../components';
|
|
|
10
8
|
|
|
11
9
|
<footer class="sl-flex">
|
|
12
10
|
<div class="meta sl-flex">
|
|
13
|
-
<EditLink
|
|
14
|
-
<LastUpdated
|
|
11
|
+
<EditLink />
|
|
12
|
+
<LastUpdated />
|
|
15
13
|
</div>
|
|
16
|
-
<Pagination
|
|
14
|
+
<Pagination />
|
|
17
15
|
|
|
18
16
|
{
|
|
19
17
|
config.credits && (
|
package/components/Head.astro
CHANGED
|
@@ -7,9 +7,8 @@ import type { HeadConfigSchema } from '../schemas/head';
|
|
|
7
7
|
import { fileWithBase } from '../utils/base';
|
|
8
8
|
import { createHead } from '../utils/head';
|
|
9
9
|
import { localizedUrl } from '../utils/localizedUrl';
|
|
10
|
-
import type { Props } from '../props';
|
|
11
10
|
|
|
12
|
-
const { entry, lang, siteTitle } = Astro.
|
|
11
|
+
const { entry, lang, siteTitle } = Astro.locals.starlightRoute;
|
|
13
12
|
const { data } = entry;
|
|
14
13
|
|
|
15
14
|
const canonical = Astro.site ? new URL(Astro.url.pathname, Astro.site) : undefined;
|
package/components/Header.astro
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
import config from 'virtual:starlight/user-config';
|
|
3
|
-
import type { Props } from '../props';
|
|
4
3
|
|
|
5
4
|
import LanguageSelect from 'virtual:starlight/components/LanguageSelect';
|
|
6
5
|
import Search from 'virtual:starlight/components/Search';
|
|
@@ -17,17 +16,17 @@ const shouldRenderSearch =
|
|
|
17
16
|
|
|
18
17
|
<div class="header sl-flex">
|
|
19
18
|
<div class="title-wrapper sl-flex">
|
|
20
|
-
<SiteTitle
|
|
19
|
+
<SiteTitle />
|
|
21
20
|
</div>
|
|
22
21
|
<div class="sl-flex print:hidden">
|
|
23
|
-
{shouldRenderSearch && <Search
|
|
22
|
+
{shouldRenderSearch && <Search />}
|
|
24
23
|
</div>
|
|
25
24
|
<div class="sl-hidden md:sl-flex print:hidden right-group">
|
|
26
25
|
<div class="sl-flex social-icons">
|
|
27
|
-
<SocialIcons
|
|
26
|
+
<SocialIcons />
|
|
28
27
|
</div>
|
|
29
|
-
<ThemeSelect
|
|
30
|
-
<LanguageSelect
|
|
28
|
+
<ThemeSelect />
|
|
29
|
+
<LanguageSelect />
|
|
31
30
|
</div>
|
|
32
31
|
</div>
|
|
33
32
|
|
package/components/Hero.astro
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { Image } from 'astro:assets';
|
|
3
3
|
import { PAGE_TITLE_ID } from '../constants';
|
|
4
|
-
import type { Props } from '../props';
|
|
5
4
|
import LinkButton from '../user-components/LinkButton.astro';
|
|
6
5
|
|
|
7
|
-
const { data } = Astro.
|
|
6
|
+
const { data } = Astro.locals.starlightRoute.entry;
|
|
8
7
|
const { title = data.title, tagline, image, actions = [] } = data.hero || {};
|
|
9
8
|
|
|
10
9
|
const imageAttrs = {
|
|
@@ -3,7 +3,6 @@ import context from 'virtual:starlight/project-context';
|
|
|
3
3
|
import config from 'virtual:starlight/user-config';
|
|
4
4
|
import { localizedUrl } from '../utils/localizedUrl';
|
|
5
5
|
import Select from './Select.astro';
|
|
6
|
-
import type { Props } from '../props';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Get the equivalent of the current page path for the passed locale.
|
|
@@ -19,10 +18,10 @@ function localizedPathname(locale: string | undefined): string {
|
|
|
19
18
|
<Select
|
|
20
19
|
icon="translate"
|
|
21
20
|
label={Astro.locals.t('languageSelect.accessibleLabel')}
|
|
22
|
-
value={localizedPathname(Astro.
|
|
21
|
+
value={localizedPathname(Astro.locals.starlightRoute.locale)}
|
|
23
22
|
options={Object.entries(config.locales).map(([code, locale]) => ({
|
|
24
23
|
value: localizedPathname(code),
|
|
25
|
-
selected: code === Astro.
|
|
24
|
+
selected: code === Astro.locals.starlightRoute.locale,
|
|
26
25
|
label: locale!.label,
|
|
27
26
|
}))}
|
|
28
27
|
width="7em"
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import LanguageSelect from 'virtual:starlight/components/LanguageSelect';
|
|
3
3
|
import SocialIcons from 'virtual:starlight/components/SocialIcons';
|
|
4
4
|
import ThemeSelect from 'virtual:starlight/components/ThemeSelect';
|
|
5
|
-
import type { Props } from '../props';
|
|
6
5
|
---
|
|
7
6
|
|
|
8
7
|
<div class="mobile-preferences sl-flex">
|
|
9
8
|
<div class="sl-flex social-icons">
|
|
10
|
-
<SocialIcons
|
|
9
|
+
<SocialIcons />
|
|
11
10
|
</div>
|
|
12
|
-
<ThemeSelect
|
|
13
|
-
<LanguageSelect
|
|
11
|
+
<ThemeSelect />
|
|
12
|
+
<LanguageSelect />
|
|
14
13
|
</div>
|
|
15
14
|
|
|
16
15
|
<style>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import Icon from '../user-components/Icon.astro';
|
|
3
3
|
import TableOfContentsList from './TableOfContents/TableOfContentsList.astro';
|
|
4
|
-
import type { Props } from '../props';
|
|
5
4
|
|
|
6
|
-
const { toc } = Astro.
|
|
5
|
+
const { toc } = Astro.locals.starlightRoute;
|
|
7
6
|
---
|
|
8
7
|
|
|
9
8
|
{
|
package/components/Page.astro
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
---
|
|
2
|
-
import type { Props } from '../props';
|
|
3
|
-
|
|
4
2
|
// Built-in CSS styles.
|
|
5
3
|
import '../style/props.css';
|
|
6
4
|
import '../style/reset.css';
|
|
@@ -33,23 +31,25 @@ import 'virtual:starlight/user-css';
|
|
|
33
31
|
|
|
34
32
|
import printHref from '../style/print.css?url&no-inline';
|
|
35
33
|
|
|
34
|
+
const { starlightRoute } = Astro.locals;
|
|
35
|
+
|
|
36
36
|
const pagefindEnabled =
|
|
37
|
-
|
|
38
|
-
!
|
|
39
|
-
|
|
37
|
+
starlightRoute.entry.slug !== '404' &&
|
|
38
|
+
!starlightRoute.entry.slug.endsWith('/404') &&
|
|
39
|
+
starlightRoute.entry.data.pagefind !== false;
|
|
40
40
|
|
|
41
41
|
const htmlDataAttributes: DOMStringMap = { 'data-theme': 'dark' };
|
|
42
|
-
if (Boolean(
|
|
43
|
-
if (
|
|
44
|
-
if (Boolean(
|
|
42
|
+
if (Boolean(starlightRoute.toc)) htmlDataAttributes['data-has-toc'] = '';
|
|
43
|
+
if (starlightRoute.hasSidebar) htmlDataAttributes['data-has-sidebar'] = '';
|
|
44
|
+
if (Boolean(starlightRoute.entry.data.hero)) htmlDataAttributes['data-has-hero'] = '';
|
|
45
45
|
|
|
46
46
|
const mainDataAttributes: DOMStringMap = {};
|
|
47
47
|
if (pagefindEnabled) mainDataAttributes['data-pagefind-body'] = '';
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
-
<html lang={
|
|
50
|
+
<html lang={starlightRoute.lang} dir={starlightRoute.dir} {...htmlDataAttributes}>
|
|
51
51
|
<head>
|
|
52
|
-
<Head
|
|
52
|
+
<Head />
|
|
53
53
|
<style>
|
|
54
54
|
html:not([data-has-toc]) {
|
|
55
55
|
--sl-mobile-toc-height: 0rem;
|
|
@@ -76,45 +76,45 @@ if (pagefindEnabled) mainDataAttributes['data-pagefind-body'] = '';
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
</style>
|
|
79
|
-
<ThemeProvider
|
|
79
|
+
<ThemeProvider />
|
|
80
80
|
<link rel="stylesheet" href={printHref} media="print" />
|
|
81
81
|
</head>
|
|
82
82
|
<body>
|
|
83
|
-
<SkipLink
|
|
84
|
-
<PageFrame
|
|
85
|
-
<Header slot="header"
|
|
86
|
-
{
|
|
83
|
+
<SkipLink />
|
|
84
|
+
<PageFrame>
|
|
85
|
+
<Header slot="header" />
|
|
86
|
+
{starlightRoute.hasSidebar && <Sidebar slot="sidebar" />}
|
|
87
87
|
<script src="./SidebarPersistState"></script>
|
|
88
|
-
<TwoColumnContent
|
|
89
|
-
<PageSidebar slot="right-sidebar"
|
|
88
|
+
<TwoColumnContent>
|
|
89
|
+
<PageSidebar slot="right-sidebar" />
|
|
90
90
|
<main
|
|
91
91
|
{...mainDataAttributes}
|
|
92
|
-
lang={
|
|
93
|
-
dir={
|
|
92
|
+
lang={starlightRoute.entryMeta.lang}
|
|
93
|
+
dir={starlightRoute.entryMeta.dir}
|
|
94
94
|
>
|
|
95
95
|
{/* TODO: Revisit how this logic flows. */}
|
|
96
|
-
<Banner
|
|
96
|
+
<Banner />
|
|
97
97
|
{
|
|
98
|
-
|
|
99
|
-
<ContentPanel
|
|
100
|
-
<Hero
|
|
101
|
-
<MarkdownContent
|
|
98
|
+
starlightRoute.entry.data.hero ? (
|
|
99
|
+
<ContentPanel>
|
|
100
|
+
<Hero />
|
|
101
|
+
<MarkdownContent>
|
|
102
102
|
<slot />
|
|
103
103
|
</MarkdownContent>
|
|
104
|
-
<Footer
|
|
104
|
+
<Footer />
|
|
105
105
|
</ContentPanel>
|
|
106
106
|
) : (
|
|
107
107
|
<>
|
|
108
|
-
<ContentPanel
|
|
109
|
-
<PageTitle
|
|
110
|
-
{
|
|
111
|
-
{
|
|
108
|
+
<ContentPanel>
|
|
109
|
+
<PageTitle />
|
|
110
|
+
{starlightRoute.entry.data.draft && <DraftContentNotice />}
|
|
111
|
+
{starlightRoute.isFallback && <FallbackContentNotice />}
|
|
112
112
|
</ContentPanel>
|
|
113
|
-
<ContentPanel
|
|
114
|
-
<MarkdownContent
|
|
113
|
+
<ContentPanel>
|
|
114
|
+
<MarkdownContent>
|
|
115
115
|
<slot />
|
|
116
116
|
</MarkdownContent>
|
|
117
|
-
<Footer
|
|
117
|
+
<Footer />
|
|
118
118
|
</ContentPanel>
|
|
119
119
|
</>
|
|
120
120
|
)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import MobileMenuToggle from 'virtual:starlight/components/MobileMenuToggle';
|
|
3
|
-
import type { Props } from '../props';
|
|
4
3
|
|
|
5
|
-
const { hasSidebar } = Astro.
|
|
4
|
+
const { hasSidebar } = Astro.locals.starlightRoute;
|
|
6
5
|
---
|
|
7
6
|
|
|
8
7
|
<div class="page sl-flex">
|
|
@@ -10,7 +9,7 @@ const { hasSidebar } = Astro.props;
|
|
|
10
9
|
{
|
|
11
10
|
hasSidebar && (
|
|
12
11
|
<nav class="sidebar print:hidden" aria-label={Astro.locals.t('sidebarNav.accessibleLabel')}>
|
|
13
|
-
<MobileMenuToggle
|
|
12
|
+
<MobileMenuToggle />
|
|
14
13
|
<div id="starlight__sidebar" class="sidebar-pane">
|
|
15
14
|
<div class="sidebar-content sl-flex">
|
|
16
15
|
<slot name="sidebar" />
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
import type { Props } from '../props';
|
|
3
|
-
|
|
4
2
|
import MobileTableOfContents from 'virtual:starlight/components/MobileTableOfContents';
|
|
5
3
|
import TableOfContents from 'virtual:starlight/components/TableOfContents';
|
|
6
4
|
---
|
|
7
5
|
|
|
8
6
|
{
|
|
9
|
-
Astro.
|
|
7
|
+
Astro.locals.starlightRoute.toc && (
|
|
10
8
|
<>
|
|
11
9
|
<div class="lg:sl-hidden">
|
|
12
|
-
<MobileTableOfContents
|
|
10
|
+
<MobileTableOfContents />
|
|
13
11
|
</div>
|
|
14
12
|
<div class="right-sidebar-panel sl-hidden lg:sl-block">
|
|
15
13
|
<div class="sl-container">
|
|
16
|
-
<TableOfContents
|
|
14
|
+
<TableOfContents />
|
|
17
15
|
</div>
|
|
18
16
|
</div>
|
|
19
17
|
</>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import Icon from '../user-components/Icon.astro';
|
|
3
|
-
import type { Props } from '../props';
|
|
4
3
|
|
|
5
|
-
const { dir, pagination } = Astro.
|
|
4
|
+
const { dir, pagination } = Astro.locals.starlightRoute;
|
|
6
5
|
const { prev, next } = pagination;
|
|
7
6
|
const isRtl = dir === 'rtl';
|
|
8
7
|
---
|
package/components/Search.astro
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import '@pagefind/default-ui/css/ui.css';
|
|
3
3
|
import Icon from '../user-components/Icon.astro';
|
|
4
4
|
import project from 'virtual:starlight/project-context';
|
|
5
|
-
import type { Props } from '../props';
|
|
6
5
|
|
|
7
6
|
const pagefindTranslations = {
|
|
8
7
|
placeholder: Astro.locals.t('search.label'),
|
|
@@ -256,15 +255,20 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash
|
|
|
256
255
|
}
|
|
257
256
|
|
|
258
257
|
#starlight__search {
|
|
259
|
-
--pagefind-ui-primary: var(--sl-color-
|
|
258
|
+
--pagefind-ui-primary: var(--sl-color-text);
|
|
260
259
|
--pagefind-ui-text: var(--sl-color-gray-2);
|
|
261
260
|
--pagefind-ui-font: var(--__sl-font);
|
|
262
261
|
--pagefind-ui-background: var(--sl-color-black);
|
|
263
262
|
--pagefind-ui-border: var(--sl-color-gray-5);
|
|
264
263
|
--pagefind-ui-border-width: 1px;
|
|
264
|
+
--pagefind-ui-tag: var(--sl-color-gray-5);
|
|
265
265
|
--sl-search-cancel-space: 5rem;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
:root[data-theme='light'] #starlight__search {
|
|
269
|
+
--pagefind-ui-tag: var(--sl-color-gray-6);
|
|
270
|
+
}
|
|
271
|
+
|
|
268
272
|
@media (min-width: 50rem) {
|
|
269
273
|
#starlight__search {
|
|
270
274
|
--sl-search-cancel-space: 0px;
|
|
@@ -439,7 +443,7 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash
|
|
|
439
443
|
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' viewBox='0 0 16 1000' preserveAspectRatio='xMinYMin slice'%3E%3Cpath d='M8 0v1000m6-988H8'/%3E%3C/svg%3E")
|
|
440
444
|
0% 0% / 100% no-repeat;
|
|
441
445
|
}
|
|
442
|
-
#starlight__search .pagefind-ui__result-nested:last-
|
|
446
|
+
#starlight__search .pagefind-ui__result-nested:last-of-type::before {
|
|
443
447
|
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 16 16'%3E%3Cpath d='M8 0v12m6 0H8'/%3E%3C/svg%3E");
|
|
444
448
|
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 16 16'%3E%3Cpath d='M8 0v12m6 0H8'/%3E%3C/svg%3E");
|
|
445
449
|
}
|
|
@@ -466,4 +470,14 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash
|
|
|
466
470
|
background-color: transparent;
|
|
467
471
|
font-weight: 600;
|
|
468
472
|
}
|
|
473
|
+
|
|
474
|
+
#starlight__search .pagefind-ui__filter-value::before {
|
|
475
|
+
border-color: var(--sl-color-text-invert);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
#starlight__search .pagefind-ui__result-tags {
|
|
479
|
+
background-color: var(--sl-color-black);
|
|
480
|
+
margin-top: 0;
|
|
481
|
+
padding: var(--sl-search-result-nested-pad-block) var(--sl-search-result-pad-inline-end);
|
|
482
|
+
}
|
|
469
483
|
</style>
|
package/components/Sidebar.astro
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
import type { Props } from '../props';
|
|
3
|
-
|
|
4
2
|
import MobileMenuFooter from 'virtual:starlight/components/MobileMenuFooter';
|
|
5
3
|
import SidebarPersister from './SidebarPersister.astro';
|
|
6
4
|
import SidebarSublist from './SidebarSublist.astro';
|
|
7
5
|
|
|
8
|
-
const { sidebar } = Astro.
|
|
6
|
+
const { sidebar } = Astro.locals.starlightRoute;
|
|
9
7
|
---
|
|
10
8
|
|
|
11
|
-
<SidebarPersister
|
|
9
|
+
<SidebarPersister>
|
|
12
10
|
<SidebarSublist sublist={sidebar} />
|
|
13
11
|
</SidebarPersister>
|
|
14
12
|
|
|
15
13
|
<div class="md:sl-hidden">
|
|
16
|
-
<MobileMenuFooter
|
|
14
|
+
<MobileMenuFooter />
|
|
17
15
|
</div>
|
|
@@ -19,10 +19,9 @@
|
|
|
19
19
|
@see https://github.com/withastro/starlight/pull/2633
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import type { Props } from '../props';
|
|
23
22
|
import { getSidebarHash } from '../utils/navigation';
|
|
24
23
|
|
|
25
|
-
const hash = getSidebarHash(Astro.
|
|
24
|
+
const hash = getSidebarHash(Astro.locals.starlightRoute.sidebar);
|
|
26
25
|
|
|
27
26
|
declare global {
|
|
28
27
|
interface Window {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { flattenSidebar
|
|
2
|
+
import { flattenSidebar } from '../utils/navigation';
|
|
3
|
+
import type { SidebarEntry } from '../utils/routing/types';
|
|
3
4
|
import Icon from '../user-components/Icon.astro';
|
|
4
5
|
import Badge from '../user-components/Badge.astro';
|
|
5
6
|
import SidebarRestorePoint from './SidebarRestorePoint.astro';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { logos } from 'virtual:starlight/user-images';
|
|
3
3
|
import config from 'virtual:starlight/user-config';
|
|
4
|
-
|
|
5
|
-
const { siteTitle, siteTitleHref } = Astro.props;
|
|
4
|
+
const { siteTitle, siteTitleHref } = Astro.locals.starlightRoute;
|
|
6
5
|
---
|
|
7
6
|
|
|
8
7
|
<a href={siteTitleHref} class="site-title sl-flex">
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import config from 'virtual:starlight/user-config';
|
|
3
3
|
import Icon from '../user-components/Icon.astro';
|
|
4
|
-
import type { Props } from '../props';
|
|
5
4
|
|
|
6
5
|
type Platform = keyof NonNullable<typeof config.social>;
|
|
7
6
|
type SocialConfig = NonNullable<NonNullable<typeof config.social>[Platform]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { attachRouteDataAndRunMiddleware } from '../utils/routing/middleware';
|
|
2
3
|
import {
|
|
3
4
|
generateStarlightPageRouteData,
|
|
4
5
|
type StarlightPageProps as Props,
|
|
@@ -6,8 +7,11 @@ import {
|
|
|
6
7
|
import Page from './Page.astro';
|
|
7
8
|
|
|
8
9
|
export type StarlightPageProps = Props;
|
|
10
|
+
|
|
11
|
+
await attachRouteDataAndRunMiddleware(
|
|
12
|
+
Astro,
|
|
13
|
+
await generateStarlightPageRouteData({ props: Astro.props, url: Astro.url })
|
|
14
|
+
);
|
|
9
15
|
---
|
|
10
16
|
|
|
11
|
-
<Page
|
|
12
|
-
<slot />
|
|
13
|
-
</Page>
|
|
17
|
+
<Page><slot /></Page>
|