@astrojs/starlight 0.10.4 → 0.11.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/404.astro +9 -4
- package/CHANGELOG.md +59 -0
- package/components/Badge.astro +1 -0
- package/components/Banner.astro +4 -4
- package/components/ContentPanel.astro +4 -0
- package/components/EditLink.astro +5 -24
- package/components/FallbackContentNotice.astro +2 -5
- package/components/Footer.astro +5 -32
- package/components/{HeadSEO.astro → Head.astro} +10 -14
- package/components/Header.astro +26 -16
- package/components/Hero.astro +6 -9
- package/components/Icons.ts +4 -0
- package/components/LanguageSelect.astro +1 -4
- package/components/LastUpdated.astro +5 -24
- package/components/MarkdownContent.astro +4 -0
- package/components/MobileMenuFooter.astro +17 -0
- package/components/MobileMenuToggle.astro +2 -4
- package/components/{TableOfContents/MobileTableOfContents.astro → MobileTableOfContents.astro} +26 -29
- package/components/Page.astro +120 -0
- package/{layout → components}/PageFrame.astro +16 -8
- package/components/{RightSidebarPanel.astro → PageSidebar.astro} +21 -9
- package/components/PageTitle.astro +16 -0
- package/components/{PrevNextLinks.astro → Pagination.astro} +3 -9
- package/components/Search.astro +5 -5
- package/components/Sidebar.astro +7 -36
- package/components/SidebarSublist.astro +8 -2
- package/components/SiteTitle.astro +1 -20
- package/components/SkipLink.astro +3 -5
- package/components/SocialIcons.astro +5 -34
- package/components/TableOfContents/TableOfContentsList.astro +1 -1
- package/components/TableOfContents/starlight-toc.ts +3 -1
- package/components/TableOfContents.astro +12 -15
- package/components/ThemeProvider.astro +1 -0
- package/components/ThemeSelect.astro +1 -4
- package/{layout → components}/TwoColumnContent.astro +2 -4
- package/constants.ts +4 -0
- package/index.astro +4 -2
- package/index.ts +10 -15
- package/integrations/virtual-user-config.ts +3 -0
- package/package.json +132 -3
- package/props.ts +1 -0
- package/schema.ts +3 -0
- package/schemas/components.ts +256 -0
- package/schemas/sidebar.ts +89 -0
- package/schemas/social.ts +65 -0
- package/style/reset.css +1 -1
- package/translations/index.ts +2 -0
- package/translations/vi.json +22 -0
- package/{components/TableOfContents → utils}/generateToC.ts +2 -1
- package/utils/navigation.ts +22 -5
- package/utils/route-data.ts +97 -0
- package/utils/routing.ts +10 -0
- package/utils/user-config.ts +15 -102
- package/utils/validateLogoImports.ts +21 -0
- package/virtual.d.ts +37 -0
- package/components/RightSidebar.astro +0 -36
- package/layout/Page.astro +0 -132
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/starlight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Build beautiful, high-performance documentation websites with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -22,18 +22,147 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": "./index.ts",
|
|
24
24
|
"./components": "./components.ts",
|
|
25
|
+
"./components/Badge.astro": {
|
|
26
|
+
"types": "./components/Badge.astro.tsx",
|
|
27
|
+
"import": "./components/Badge.astro"
|
|
28
|
+
},
|
|
29
|
+
"./components/LanguageSelect.astro": {
|
|
30
|
+
"types": "./components/LanguageSelect.astro.tsx",
|
|
31
|
+
"import": "./components/LanguageSelect.astro"
|
|
32
|
+
},
|
|
33
|
+
"./components/Select.astro": {
|
|
34
|
+
"types": "./components/Select.astro.tsx",
|
|
35
|
+
"import": "./components/Select.astro"
|
|
36
|
+
},
|
|
37
|
+
"./components/Banner.astro": {
|
|
38
|
+
"types": "./components/Banner.astro.tsx",
|
|
39
|
+
"import": "./components/Banner.astro"
|
|
40
|
+
},
|
|
41
|
+
"./components/LastUpdated.astro": {
|
|
42
|
+
"types": "./components/LastUpdated.astro.tsx",
|
|
43
|
+
"import": "./components/LastUpdated.astro"
|
|
44
|
+
},
|
|
45
|
+
"./components/Sidebar.astro": {
|
|
46
|
+
"types": "./components/Sidebar.astro.tsx",
|
|
47
|
+
"import": "./components/Sidebar.astro"
|
|
48
|
+
},
|
|
49
|
+
"./components/CallToAction.astro": {
|
|
50
|
+
"types": "./components/CallToAction.astro.tsx",
|
|
51
|
+
"import": "./components/CallToAction.astro"
|
|
52
|
+
},
|
|
53
|
+
"./components/MarkdownContent.astro": {
|
|
54
|
+
"types": "./components/MarkdownContent.astro.tsx",
|
|
55
|
+
"import": "./components/MarkdownContent.astro"
|
|
56
|
+
},
|
|
57
|
+
"./components/SidebarSublist.astro": {
|
|
58
|
+
"types": "./components/SidebarSublist.astro.tsx",
|
|
59
|
+
"import": "./components/SidebarSublist.astro"
|
|
60
|
+
},
|
|
61
|
+
"./components/ContentPanel.astro": {
|
|
62
|
+
"types": "./components/ContentPanel.astro.tsx",
|
|
63
|
+
"import": "./components/ContentPanel.astro"
|
|
64
|
+
},
|
|
65
|
+
"./components/MobileMenuFooter.astro": {
|
|
66
|
+
"types": "./components/MobileMenuFooter.astro.tsx",
|
|
67
|
+
"import": "./components/MobileMenuFooter.astro"
|
|
68
|
+
},
|
|
69
|
+
"./components/SiteTitle.astro": {
|
|
70
|
+
"types": "./components/SiteTitle.astro.tsx",
|
|
71
|
+
"import": "./components/SiteTitle.astro"
|
|
72
|
+
},
|
|
73
|
+
"./components/EditLink.astro": {
|
|
74
|
+
"types": "./components/EditLink.astro.tsx",
|
|
75
|
+
"import": "./components/EditLink.astro"
|
|
76
|
+
},
|
|
77
|
+
"./components/MobileMenuToggle.astro": {
|
|
78
|
+
"types": "./components/MobileMenuToggle.astro.tsx",
|
|
79
|
+
"import": "./components/MobileMenuToggle.astro"
|
|
80
|
+
},
|
|
81
|
+
"./components/SkipLink.astro": {
|
|
82
|
+
"types": "./components/SkipLink.astro.tsx",
|
|
83
|
+
"import": "./components/SkipLink.astro"
|
|
84
|
+
},
|
|
85
|
+
"./components/MobileTableOfContents.astro": {
|
|
86
|
+
"types": "./components/MobileTableOfContents.astro.tsx",
|
|
87
|
+
"import": "./components/MobileTableOfContents.astro"
|
|
88
|
+
},
|
|
89
|
+
"./components/SocialIcons.astro": {
|
|
90
|
+
"types": "./components/SocialIcons.astro.tsx",
|
|
91
|
+
"import": "./components/SocialIcons.astro"
|
|
92
|
+
},
|
|
93
|
+
"./components/FallbackContentNotice.astro": {
|
|
94
|
+
"types": "./components/FallbackContentNotice.astro.tsx",
|
|
95
|
+
"import": "./components/FallbackContentNotice.astro"
|
|
96
|
+
},
|
|
97
|
+
"./components/Page.astro": {
|
|
98
|
+
"types": "./components/Page.astro.tsx",
|
|
99
|
+
"import": "./components/Page.astro"
|
|
100
|
+
},
|
|
101
|
+
"./components/Footer.astro": {
|
|
102
|
+
"types": "./components/Footer.astro.tsx",
|
|
103
|
+
"import": "./components/Footer.astro"
|
|
104
|
+
},
|
|
105
|
+
"./components/PageFrame.astro": {
|
|
106
|
+
"types": "./components/PageFrame.astro.tsx",
|
|
107
|
+
"import": "./components/PageFrame.astro"
|
|
108
|
+
},
|
|
109
|
+
"./components/TableOfContents.astro": {
|
|
110
|
+
"types": "./components/TableOfContents.astro.tsx",
|
|
111
|
+
"import": "./components/TableOfContents.astro"
|
|
112
|
+
},
|
|
113
|
+
"./components/Head.astro": {
|
|
114
|
+
"types": "./components/Head.astro.tsx",
|
|
115
|
+
"import": "./components/Head.astro"
|
|
116
|
+
},
|
|
117
|
+
"./components/PageSidebar.astro": {
|
|
118
|
+
"types": "./components/PageSidebar.astro.tsx",
|
|
119
|
+
"import": "./components/PageSidebar.astro"
|
|
120
|
+
},
|
|
121
|
+
"./components/ThemeProvider.astro": {
|
|
122
|
+
"types": "./components/ThemeProvider.astro.tsx",
|
|
123
|
+
"import": "./components/ThemeProvider.astro"
|
|
124
|
+
},
|
|
125
|
+
"./components/Header.astro": {
|
|
126
|
+
"types": "./components/Header.astro.tsx",
|
|
127
|
+
"import": "./components/Header.astro"
|
|
128
|
+
},
|
|
129
|
+
"./components/PageTitle.astro": {
|
|
130
|
+
"types": "./components/PageTitle.astro.tsx",
|
|
131
|
+
"import": "./components/PageTitle.astro"
|
|
132
|
+
},
|
|
133
|
+
"./components/ThemeSelect.astro": {
|
|
134
|
+
"types": "./components/ThemeSelect.astro.tsx",
|
|
135
|
+
"import": "./components/ThemeSelect.astro"
|
|
136
|
+
},
|
|
137
|
+
"./components/Hero.astro": {
|
|
138
|
+
"types": "./components/Hero.astro.tsx",
|
|
139
|
+
"import": "./components/Hero.astro"
|
|
140
|
+
},
|
|
141
|
+
"./components/Pagination.astro": {
|
|
142
|
+
"types": "./components/Pagination.astro.tsx",
|
|
143
|
+
"import": "./components/Pagination.astro"
|
|
144
|
+
},
|
|
145
|
+
"./components/TwoColumnContent.astro": {
|
|
146
|
+
"types": "./components/TwoColumnContent.astro.tsx",
|
|
147
|
+
"import": "./components/TwoColumnContent.astro"
|
|
148
|
+
},
|
|
149
|
+
"./components/Search.astro": {
|
|
150
|
+
"types": "./components/Search.astro.tsx",
|
|
151
|
+
"import": "./components/Search.astro"
|
|
152
|
+
},
|
|
153
|
+
"./props": "./props.ts",
|
|
25
154
|
"./schema": "./schema.ts",
|
|
26
155
|
"./types": "./types.ts",
|
|
27
156
|
"./index.astro": "./index.astro",
|
|
28
157
|
"./404.astro": "./404.astro"
|
|
29
158
|
},
|
|
30
159
|
"peerDependencies": {
|
|
31
|
-
"astro": "^3.
|
|
160
|
+
"astro": "^3.2.0"
|
|
32
161
|
},
|
|
33
162
|
"devDependencies": {
|
|
34
163
|
"@types/node": "^18.16.19",
|
|
35
164
|
"@vitest/coverage-v8": "^0.33.0",
|
|
36
|
-
"astro": "^3.2.
|
|
165
|
+
"astro": "^3.2.3",
|
|
37
166
|
"vitest": "^0.33.0"
|
|
38
167
|
},
|
|
39
168
|
"dependencies": {
|
package/props.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { StarlightRouteData as Props } from './utils/route-data';
|
package/schema.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { PrevNextLinkConfigSchema } from './schemas/prevNextLink';
|
|
|
5
5
|
import { TableOfContentsSchema } from './schemas/tableOfContents';
|
|
6
6
|
import { Icons } from './components/Icons';
|
|
7
7
|
import { BadgeConfigSchema } from './schemas/badge';
|
|
8
|
+
import { SidebarLinkItemHTMLAttributesSchema } from './schemas/sidebar';
|
|
8
9
|
export { i18nSchema } from './schemas/i18n';
|
|
9
10
|
|
|
10
11
|
type IconName = keyof typeof Icons;
|
|
@@ -139,6 +140,8 @@ export function docsSchema() {
|
|
|
139
140
|
* Passing only a string defaults to the 'default' variant which uses the site accent color.
|
|
140
141
|
*/
|
|
141
142
|
badge: BadgeConfigSchema(),
|
|
143
|
+
/** HTML attributes to add to the sidebar link. */
|
|
144
|
+
attrs: SidebarLinkItemHTMLAttributesSchema(),
|
|
142
145
|
})
|
|
143
146
|
.default({}),
|
|
144
147
|
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
|
|
3
|
+
export function ComponentConfigSchema() {
|
|
4
|
+
return z
|
|
5
|
+
.object({
|
|
6
|
+
/*
|
|
7
|
+
HEAD ----------------------------------------------------------------------------------------
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Component rendered inside each page’s `<head>`.
|
|
12
|
+
* Includes important tags including `<title>`, and `<meta charset="utf-8">`.
|
|
13
|
+
*
|
|
14
|
+
* Override this component as a last resort. Prefer the `head` option Starlight config if possible.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Head.astro `Head` default implementation}
|
|
17
|
+
*/
|
|
18
|
+
Head: z.string().default('@astrojs/starlight/components/Head.astro'),
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Component rendered inside `<head>` that sets up dark/light theme support.
|
|
22
|
+
* The default implementation includes an inline script and a `<template>` used by the
|
|
23
|
+
* script in `ThemeSelect.astro`.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/ThemeProvider.astro `ThemeProvider` default implementation}
|
|
26
|
+
*/
|
|
27
|
+
ThemeProvider: z.string().default('@astrojs/starlight/components/ThemeProvider.astro'),
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
BODY ----------------------------------------------------------------------------------------
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Component rendered as the first element inside `<body>` which links to the main page
|
|
35
|
+
* content for accessibility. The default implementation is hidden until a user focuses it
|
|
36
|
+
* by tabbing with their keyboard.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/SkipLink.astro `SkipLink` default implementation}
|
|
39
|
+
*/
|
|
40
|
+
SkipLink: z.string().default('@astrojs/starlight/components/SkipLink.astro'),
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
LAYOUT --------------------------------------------------------------------------------------
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Layout component wrapped around most of the page content.
|
|
48
|
+
* The default implementation sets up the header–sidebar–main layout and includes
|
|
49
|
+
* `header` and `sidebar` named slots along with a default slot for the main content.
|
|
50
|
+
* It also renders `<MobileMenuToggle />` to support toggling the sidebar navigation
|
|
51
|
+
* on small (mobile) viewports.
|
|
52
|
+
*
|
|
53
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro `PageFrame` default implementation}
|
|
54
|
+
*/
|
|
55
|
+
PageFrame: z.string().default('@astrojs/starlight/components/PageFrame.astro'),
|
|
56
|
+
/**
|
|
57
|
+
* Component rendered inside `<PageFrame>` that is responsible for toggling the
|
|
58
|
+
* sidebar navigation on small (mobile) viewports.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/MobileMenuToggle.astro `MobileMenuToggle` default implementation}
|
|
61
|
+
*/
|
|
62
|
+
MobileMenuToggle: z.string().default('@astrojs/starlight/components/MobileMenuToggle.astro'),
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Layout component wrapped around the main content column and right sidebar (table of contents).
|
|
66
|
+
* The default implementation handles the switch between a single-column, small-viewport layout
|
|
67
|
+
* and a two-column, larger-viewport layout.
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/TwoColumnContent.astro `TwoColumnContent` default implementation}
|
|
70
|
+
*/
|
|
71
|
+
TwoColumnContent: z.string().default('@astrojs/starlight/components/TwoColumnContent.astro'),
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
HEADER --------------------------------------------------------------------------------------
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Header component displayed at the top of every page.
|
|
79
|
+
* The default implementation displays `<SiteTitle />`, `<Search />`, `<SocialIcons />`,
|
|
80
|
+
* `<ThemeSelect />`, and `<LanguageSelect />`.
|
|
81
|
+
*
|
|
82
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Header.astro `Header` default implementation}
|
|
83
|
+
*/
|
|
84
|
+
Header: z.string().default('@astrojs/starlight/components/Header.astro'),
|
|
85
|
+
/**
|
|
86
|
+
* Component rendered at the start of the site header to render the site title.
|
|
87
|
+
* The default implementation includes logic for rendering logos defined in Starlight config.
|
|
88
|
+
*
|
|
89
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/SiteTitle.astro `SiteTitle` default implementation}
|
|
90
|
+
*/
|
|
91
|
+
SiteTitle: z.string().default('@astrojs/starlight/components/SiteTitle.astro'),
|
|
92
|
+
/**
|
|
93
|
+
* Component used to render Starlight’s search UI. The default implementation includes the
|
|
94
|
+
* button in the header and the code for displaying a search modal when it is clicked.
|
|
95
|
+
*
|
|
96
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Search.astro `Search` default implementation}
|
|
97
|
+
*/
|
|
98
|
+
Search: z.string().default('@astrojs/starlight/components/Search.astro'),
|
|
99
|
+
/**
|
|
100
|
+
* Component rendered in the site header including social icon links. The default
|
|
101
|
+
* implementation uses the `social` option in Starlight config to render icons and links.
|
|
102
|
+
*
|
|
103
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/SocialIcons.astro `SocialIcons` default implementation}
|
|
104
|
+
*/
|
|
105
|
+
SocialIcons: z.string().default('@astrojs/starlight/components/SocialIcons.astro'),
|
|
106
|
+
/**
|
|
107
|
+
* Component rendered in the site header that allows users to select their preferred color scheme.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/ThemeSelect.astro `ThemeSelect` default implementation}
|
|
110
|
+
*/
|
|
111
|
+
ThemeSelect: z.string().default('@astrojs/starlight/components/ThemeSelect.astro'),
|
|
112
|
+
/**
|
|
113
|
+
* Component rendered in the site header that allows users to switch to a different language.
|
|
114
|
+
*
|
|
115
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/LanguageSelect.astro `LanguageSelect` default implementation}
|
|
116
|
+
*/
|
|
117
|
+
LanguageSelect: z.string().default('@astrojs/starlight/components/LanguageSelect.astro'),
|
|
118
|
+
|
|
119
|
+
/*
|
|
120
|
+
SIDEBAR -------------------------------------------------------------------------------------
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Component rendered before page content that contains global navigation.
|
|
125
|
+
* The default implementation displays as a sidebar on wide enough viewports and inside a
|
|
126
|
+
* drop-down menu on small (mobile) viewports. It also renders `<MobileMenuFooter />` to
|
|
127
|
+
* show additional items inside the mobile menu.
|
|
128
|
+
*
|
|
129
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Sidebar.astro `Sidebar` default implementation}
|
|
130
|
+
*/
|
|
131
|
+
Sidebar: z.string().default('@astrojs/starlight/components/Sidebar.astro'),
|
|
132
|
+
/**
|
|
133
|
+
* Component rendered at the bottom of the mobile drop-down menu.
|
|
134
|
+
* The default implementation renders `<ThemeSelect />` and `<LanguageSelect />`.
|
|
135
|
+
*
|
|
136
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/MobileMenuFooter.astro `MobileMenuFooter` default implementation}
|
|
137
|
+
*/
|
|
138
|
+
MobileMenuFooter: z.string().default('@astrojs/starlight/components/MobileMenuFooter.astro'),
|
|
139
|
+
|
|
140
|
+
/*
|
|
141
|
+
TOC -----------------------------------------------------------------------------------------
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Component rendered before the main page’s content to display a table of contents.
|
|
146
|
+
* The default implementation renders `<TableOfContents />` and `<MobileTableOfContents />`.
|
|
147
|
+
*
|
|
148
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageSidebar.astro `PageSidebar` default implementation}
|
|
149
|
+
*/
|
|
150
|
+
PageSidebar: z.string().default('@astrojs/starlight/components/PageSidebar.astro'),
|
|
151
|
+
/**
|
|
152
|
+
* Component that renders the current page’s table of contents on wider viewports.
|
|
153
|
+
*
|
|
154
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/TableOfContents.astro `TableOfContents` default implementation}
|
|
155
|
+
*/
|
|
156
|
+
TableOfContents: z.string().default('@astrojs/starlight/components/TableOfContents.astro'),
|
|
157
|
+
/**
|
|
158
|
+
* Component that renders the current page’s table of contents on small (mobile) viewports.
|
|
159
|
+
*
|
|
160
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/MobileTableOfContents.astro `MobileTableOfContents` default implementation}
|
|
161
|
+
*/
|
|
162
|
+
MobileTableOfContents: z
|
|
163
|
+
.string()
|
|
164
|
+
.default('@astrojs/starlight/components/MobileTableOfContents.astro'),
|
|
165
|
+
|
|
166
|
+
/*
|
|
167
|
+
CONTENT HEADER ------------------------------------------------------------------------------
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Banner component rendered at the top of each page. The default implementation uses the
|
|
172
|
+
* page’s `banner` frontmatter value to decide whether or not to render.
|
|
173
|
+
*
|
|
174
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Banner.astro `Banner` default implementation}
|
|
175
|
+
*/
|
|
176
|
+
Banner: z.string().default('@astrojs/starlight/components/Banner.astro'),
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Layout component used to wrap sections of the main content column.
|
|
180
|
+
*
|
|
181
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/ContentPanel.astro `ContentPanel` default implementation}
|
|
182
|
+
*/
|
|
183
|
+
ContentPanel: z.string().default('@astrojs/starlight/components/ContentPanel.astro'),
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Component containing the `<h1>` element for the current page.
|
|
187
|
+
*
|
|
188
|
+
* Implementations should ensure they set `id="_top"` on the `<h1>` element as in the default
|
|
189
|
+
* implementation.
|
|
190
|
+
*
|
|
191
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageTitle.astro `PageTitle` default implementation}
|
|
192
|
+
*/
|
|
193
|
+
PageTitle: z.string().default('@astrojs/starlight/components/PageTitle.astro'),
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Notice displayed to users on pages where a translation for the current language is not
|
|
197
|
+
* available. Only used on multilingual sites.
|
|
198
|
+
*
|
|
199
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/FallbackContentNotice.astro `FallbackContentNotice` default implementation}
|
|
200
|
+
*/
|
|
201
|
+
FallbackContentNotice: z
|
|
202
|
+
.string()
|
|
203
|
+
.default('@astrojs/starlight/components/FallbackContentNotice.astro'),
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Component rendered at the top of the page when `hero` is set in frontmatter. The default
|
|
207
|
+
* implementation shows a large title, tagline, and call-to-action links alongside an optional image.
|
|
208
|
+
*
|
|
209
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Hero.astro `Hero` default implementation}
|
|
210
|
+
*/
|
|
211
|
+
Hero: z.string().default('@astrojs/starlight/components/Hero.astro'),
|
|
212
|
+
|
|
213
|
+
/*
|
|
214
|
+
CONTENT -------------------------------------------------------------------------------------
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Component rendered around each page’s main content.
|
|
219
|
+
* The default implementation sets up basic styles to apply to Markdown content.
|
|
220
|
+
*
|
|
221
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/MarkdownContent.astro `MarkdownContent` default implementation}
|
|
222
|
+
*/
|
|
223
|
+
MarkdownContent: z.string().default('@astrojs/starlight/components/MarkdownContent.astro'),
|
|
224
|
+
|
|
225
|
+
/*
|
|
226
|
+
CONTENT FOOTER ------------------------------------------------------------------------------
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Footer component displayed at the bottom of each documentation page.
|
|
231
|
+
* The default implementation displays `<LastUpdated />`, `<Pagination />`, and `<EditLink />`.
|
|
232
|
+
*
|
|
233
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Footer.astro `Footer` default implementation}
|
|
234
|
+
*/
|
|
235
|
+
Footer: z.string().default('@astrojs/starlight/components/Footer.astro'),
|
|
236
|
+
/**
|
|
237
|
+
* Component rendered in the page footer to display the last-updated date.
|
|
238
|
+
*
|
|
239
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/LastUpdated.astro `LastUpdated` default implementation}
|
|
240
|
+
*/
|
|
241
|
+
LastUpdated: z.string().default('@astrojs/starlight/components/LastUpdated.astro'),
|
|
242
|
+
/**
|
|
243
|
+
* Component rendered in the page footer to display navigation arrows between previous/next pages.
|
|
244
|
+
*
|
|
245
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/Pagination.astro `Pagination` default implementation}
|
|
246
|
+
*/
|
|
247
|
+
Pagination: z.string().default('@astrojs/starlight/components/Pagination.astro'),
|
|
248
|
+
/**
|
|
249
|
+
* Component rendered in the page footer to display a link to where the page can be edited.
|
|
250
|
+
*
|
|
251
|
+
* @see {@link https://github.com/withastro/starlight/blob/main/packages/starlight/components/EditLink.astro `EditLink` default implementation}
|
|
252
|
+
*/
|
|
253
|
+
EditLink: z.string().default('@astrojs/starlight/components/EditLink.astro'),
|
|
254
|
+
})
|
|
255
|
+
.default({});
|
|
256
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { AstroBuiltinAttributes } from 'astro';
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
import { z } from 'astro/zod';
|
|
4
|
+
import { BadgeConfigSchema } from './badge';
|
|
5
|
+
|
|
6
|
+
const SidebarBaseSchema = z.object({
|
|
7
|
+
/** The visible label for this item in the sidebar. */
|
|
8
|
+
label: z.string(),
|
|
9
|
+
/** Translations of the `label` for each supported language. */
|
|
10
|
+
translations: z.record(z.string()).default({}),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const SidebarGroupSchema = SidebarBaseSchema.extend({
|
|
14
|
+
/** Whether this item should be collapsed by default. */
|
|
15
|
+
collapsed: z.boolean().default(false),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// HTML attributes that can be added to an anchor element, validated as
|
|
19
|
+
// `Record<string, string | number | boolean | undefined>` but typed as `HTMLAttributes<'a'>`
|
|
20
|
+
// for user convenience.
|
|
21
|
+
const linkHTMLAttributesSchema = z.record(
|
|
22
|
+
z.union([z.string(), z.number(), z.boolean(), z.undefined()])
|
|
23
|
+
) as z.Schema<Omit<HTMLAttributes<'a'>, keyof AstroBuiltinAttributes | 'children'>>;
|
|
24
|
+
export type LinkHTMLAttributes = z.infer<typeof linkHTMLAttributesSchema>;
|
|
25
|
+
|
|
26
|
+
export const SidebarLinkItemHTMLAttributesSchema = () => linkHTMLAttributesSchema.default({});
|
|
27
|
+
|
|
28
|
+
const SidebarLinkItemSchema = SidebarBaseSchema.extend({
|
|
29
|
+
/** The link to this item’s content. Can be a relative link to local files or the full URL of an external page. */
|
|
30
|
+
link: z.string(),
|
|
31
|
+
/** Adds a badge to the link item */
|
|
32
|
+
badge: BadgeConfigSchema(),
|
|
33
|
+
/** HTML attributes to add to the link item. */
|
|
34
|
+
attrs: SidebarLinkItemHTMLAttributesSchema(),
|
|
35
|
+
});
|
|
36
|
+
export type SidebarLinkItem = z.infer<typeof SidebarLinkItemSchema>;
|
|
37
|
+
|
|
38
|
+
const AutoSidebarGroupSchema = SidebarGroupSchema.extend({
|
|
39
|
+
/** Enable autogenerating a sidebar category from a specific docs directory. */
|
|
40
|
+
autogenerate: z.object({
|
|
41
|
+
/** The directory to generate sidebar items for. */
|
|
42
|
+
directory: z.string(),
|
|
43
|
+
/**
|
|
44
|
+
* Whether the autogenerated subgroups should be collapsed by default.
|
|
45
|
+
* Defaults to the `AutoSidebarGroup` `collapsed` value.
|
|
46
|
+
*/
|
|
47
|
+
collapsed: z.boolean().optional(),
|
|
48
|
+
// TODO: not supported by Docusaurus but would be good to have
|
|
49
|
+
/** How many directories deep to include from this directory in the sidebar. Default: `Infinity`. */
|
|
50
|
+
// depth: z.number().optional(),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
export type AutoSidebarGroup = z.infer<typeof AutoSidebarGroupSchema>;
|
|
54
|
+
|
|
55
|
+
type ManualSidebarGroupInput = z.input<typeof SidebarGroupSchema> & {
|
|
56
|
+
/** Array of links and subcategories to display in this category. */
|
|
57
|
+
items: Array<
|
|
58
|
+
| z.input<typeof SidebarLinkItemSchema>
|
|
59
|
+
| z.input<typeof AutoSidebarGroupSchema>
|
|
60
|
+
| ManualSidebarGroupInput
|
|
61
|
+
>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type ManualSidebarGroupOutput = z.output<typeof SidebarGroupSchema> & {
|
|
65
|
+
/** Array of links and subcategories to display in this category. */
|
|
66
|
+
items: Array<
|
|
67
|
+
| z.output<typeof SidebarLinkItemSchema>
|
|
68
|
+
| z.output<typeof AutoSidebarGroupSchema>
|
|
69
|
+
| ManualSidebarGroupOutput
|
|
70
|
+
>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const ManualSidebarGroupSchema: z.ZodType<
|
|
74
|
+
ManualSidebarGroupOutput,
|
|
75
|
+
z.ZodTypeDef,
|
|
76
|
+
ManualSidebarGroupInput
|
|
77
|
+
> = SidebarGroupSchema.extend({
|
|
78
|
+
/** Array of links and subcategories to display in this category. */
|
|
79
|
+
items: z.lazy(() =>
|
|
80
|
+
z.union([SidebarLinkItemSchema, ManualSidebarGroupSchema, AutoSidebarGroupSchema]).array()
|
|
81
|
+
),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const SidebarItemSchema = z.union([
|
|
85
|
+
SidebarLinkItemSchema,
|
|
86
|
+
ManualSidebarGroupSchema,
|
|
87
|
+
AutoSidebarGroupSchema,
|
|
88
|
+
]);
|
|
89
|
+
export type SidebarItem = z.infer<typeof SidebarItemSchema>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
|
|
3
|
+
export const SocialLinksSchema = () =>
|
|
4
|
+
z
|
|
5
|
+
.record(
|
|
6
|
+
z.enum([
|
|
7
|
+
'twitter',
|
|
8
|
+
'mastodon',
|
|
9
|
+
'github',
|
|
10
|
+
'gitlab',
|
|
11
|
+
'bitbucket',
|
|
12
|
+
'discord',
|
|
13
|
+
'gitter',
|
|
14
|
+
'codeberg',
|
|
15
|
+
'codePen',
|
|
16
|
+
'youtube',
|
|
17
|
+
'threads',
|
|
18
|
+
'linkedin',
|
|
19
|
+
'twitch',
|
|
20
|
+
'microsoftTeams',
|
|
21
|
+
'instagram',
|
|
22
|
+
'stackOverflow',
|
|
23
|
+
'x.com',
|
|
24
|
+
'telegram',
|
|
25
|
+
'rss',
|
|
26
|
+
'facebook',
|
|
27
|
+
'email',
|
|
28
|
+
]),
|
|
29
|
+
// Link to the respective social profile for this site
|
|
30
|
+
z.string().url()
|
|
31
|
+
)
|
|
32
|
+
.transform((links) => {
|
|
33
|
+
const labelledLinks: Partial<Record<keyof typeof links, { label: string; url: string }>> = {};
|
|
34
|
+
for (const _k in links) {
|
|
35
|
+
const key = _k as keyof typeof links;
|
|
36
|
+
const url = links[key];
|
|
37
|
+
if (!url) continue;
|
|
38
|
+
const label = {
|
|
39
|
+
github: 'GitHub',
|
|
40
|
+
gitlab: 'GitLab',
|
|
41
|
+
bitbucket: 'Bitbucket',
|
|
42
|
+
discord: 'Discord',
|
|
43
|
+
gitter: 'Gitter',
|
|
44
|
+
twitter: 'Twitter',
|
|
45
|
+
mastodon: 'Mastodon',
|
|
46
|
+
codeberg: 'Codeberg',
|
|
47
|
+
codePen: 'CodePen',
|
|
48
|
+
youtube: 'YouTube',
|
|
49
|
+
threads: 'Threads',
|
|
50
|
+
linkedin: 'LinkedIn',
|
|
51
|
+
twitch: 'Twitch',
|
|
52
|
+
microsoftTeams: 'Microsoft Teams',
|
|
53
|
+
instagram: 'Instagram',
|
|
54
|
+
stackOverflow: 'Stack Overflow',
|
|
55
|
+
'x.com': 'X',
|
|
56
|
+
telegram: 'Telegram',
|
|
57
|
+
rss: 'RSS',
|
|
58
|
+
facebook: 'Facebook',
|
|
59
|
+
email: 'Email',
|
|
60
|
+
}[key];
|
|
61
|
+
labelledLinks[key] = { label, url };
|
|
62
|
+
}
|
|
63
|
+
return labelledLinks;
|
|
64
|
+
})
|
|
65
|
+
.optional();
|
package/style/reset.css
CHANGED
package/translations/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import zh from './zh.json';
|
|
|
19
19
|
import ko from './ko.json';
|
|
20
20
|
import sv from './sv.json';
|
|
21
21
|
import ru from './ru.json';
|
|
22
|
+
import vi from './vi.json';
|
|
22
23
|
|
|
23
24
|
const { parse } = builtinI18nSchema();
|
|
24
25
|
|
|
@@ -44,5 +45,6 @@ export default Object.fromEntries(
|
|
|
44
45
|
ko,
|
|
45
46
|
sv,
|
|
46
47
|
ru,
|
|
48
|
+
vi,
|
|
47
49
|
}).map(([key, dict]) => [key, parse(dict)])
|
|
48
50
|
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skipLink.label": "Bỏ qua nội dung",
|
|
3
|
+
"search.label": "Tìm kiếm",
|
|
4
|
+
"search.shortcutLabel": "(Nhấn / để Tìm kiếm)",
|
|
5
|
+
"search.cancelLabel": "Thoát",
|
|
6
|
+
"search.devWarning": "Tìm kiếm không khả dụng khi đang trong môi trường lập trình. \nThử xuất bản website và tìm kiếm.",
|
|
7
|
+
"themeSelect.accessibleLabel": "Chọn giao diện",
|
|
8
|
+
"themeSelect.dark": "Tối",
|
|
9
|
+
"themeSelect.light": "Sáng",
|
|
10
|
+
"themeSelect.auto": "Tự động",
|
|
11
|
+
"languageSelect.accessibleLabel": "Chọn ngôn ngữ",
|
|
12
|
+
"menuButton.accessibleLabel": "Menu",
|
|
13
|
+
"sidebarNav.accessibleLabel": "Chính",
|
|
14
|
+
"tableOfContents.onThisPage": "Tóm tắt",
|
|
15
|
+
"tableOfContents.overview": "Tổng quát",
|
|
16
|
+
"i18n.untranslatedContent": "Nội dung này không tồn tại trong ngôn ngữ của bạn",
|
|
17
|
+
"page.editLink": "Chỉnh sửa trang",
|
|
18
|
+
"page.lastUpdated": "Cập nhật lần cuối:",
|
|
19
|
+
"page.previousLink": "Tiếp",
|
|
20
|
+
"page.nextLink": "Trước",
|
|
21
|
+
"404.text": "Không tìm thấy trang. Kiểm tra URL hoặc thử sử dụng thanh tìm kiếm."
|
|
22
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MarkdownHeading } from 'astro';
|
|
2
|
+
import { PAGE_TITLE_ID } from '../constants';
|
|
2
3
|
|
|
3
4
|
export interface TocItem extends MarkdownHeading {
|
|
4
5
|
children: TocItem[];
|
|
@@ -16,7 +17,7 @@ export function generateToC(
|
|
|
16
17
|
{ minHeadingLevel, maxHeadingLevel, title }: TocOpts
|
|
17
18
|
) {
|
|
18
19
|
headings = headings.filter(({ depth }) => depth >= minHeadingLevel && depth <= maxHeadingLevel);
|
|
19
|
-
const toc: Array<TocItem> = [{ depth: 2, slug:
|
|
20
|
+
const toc: Array<TocItem> = [{ depth: 2, slug: PAGE_TITLE_ID, text: title, children: [] }];
|
|
20
21
|
for (const heading of headings) injectChild(toc, { ...heading, children: [] });
|
|
21
22
|
return toc;
|
|
22
23
|
}
|