@astrojs/starlight 0.12.0 → 0.12.1
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/MarkdownContent.astro +2 -123
- package/integrations/sitemap.ts +11 -7
- package/package.json +4 -2
- package/style/markdown.css +115 -0
- package/utils/createTranslationSystem.ts +1 -1
- package/utils/navigation.ts +1 -1
- package/utils/route-data.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1069](https://github.com/withastro/starlight/pull/1069) [`b86f360`](https://github.com/withastro/starlight/commit/b86f3608f03be9455ec1d5ba11820c9bf601ad1e) Thanks [@Genteure](https://github.com/Genteure)! - Fix sidebar highlighting and navigation buttons for pages with path containing non-ASCII characters
|
|
8
|
+
|
|
9
|
+
- [#1025](https://github.com/withastro/starlight/pull/1025) [`0d1e75e`](https://github.com/withastro/starlight/commit/0d1e75e17269ddac3eb15b7dfb4480da1bb01c6c) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Internal: fix import issue in translation string loading mechanism
|
|
10
|
+
|
|
11
|
+
- [#1044](https://github.com/withastro/starlight/pull/1044) [`a5a9754`](https://github.com/withastro/starlight/commit/a5a9754f111b97abfd277d99759e9857aa0fb22b) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fix last updated dates for pages displaying fallback content
|
|
12
|
+
|
|
13
|
+
- [#1049](https://github.com/withastro/starlight/pull/1049) [`c27495d`](https://github.com/withastro/starlight/commit/c27495da61f9376236519ed3f08a169f245a189c) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Expose Markdown content styles in `@astrojs/starlight/style/markdown.css`
|
|
14
|
+
|
|
3
15
|
## 0.12.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -1,127 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { Props } from '../props';
|
|
3
|
+
import '../style/markdown.css';
|
|
3
4
|
---
|
|
4
5
|
|
|
5
|
-
<div class="content"><slot /></div>
|
|
6
|
-
|
|
7
|
-
<style>
|
|
8
|
-
.content
|
|
9
|
-
:global(
|
|
10
|
-
:not(a, strong, em, del, span, input, code)
|
|
11
|
-
+ :not(a, strong, em, del, span, input, code, :where(.not-content *))
|
|
12
|
-
) {
|
|
13
|
-
margin-top: 1.5rem;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* Headings after non-headings have more spacing. */
|
|
17
|
-
.content
|
|
18
|
-
:global(
|
|
19
|
-
:not(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *))
|
|
20
|
-
) {
|
|
21
|
-
margin-top: 2.5rem;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.content :global(li + li:not(:where(.not-content *))),
|
|
25
|
-
.content :global(dt + dt:not(:where(.not-content *))),
|
|
26
|
-
.content :global(dt + dd:not(:where(.not-content *))),
|
|
27
|
-
.content :global(dd + dd:not(:where(.not-content *))) {
|
|
28
|
-
margin-top: 0.25rem;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.content
|
|
32
|
-
:global(
|
|
33
|
-
li > :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *))
|
|
34
|
-
) {
|
|
35
|
-
margin-bottom: 1.25rem;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.content :global(dt:not(:where(.not-content *))) {
|
|
39
|
-
font-weight: 700;
|
|
40
|
-
}
|
|
41
|
-
.content :global(dd:not(:where(.not-content *))) {
|
|
42
|
-
padding-inline-start: 1rem;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.content :global(:is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *))) {
|
|
46
|
-
color: var(--sl-color-white);
|
|
47
|
-
line-height: var(--sl-line-height-headings);
|
|
48
|
-
font-weight: 600;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.content :global(:is(img, picture, video, canvas, svg, iframe):not(:where(.not-content *))) {
|
|
52
|
-
display: block;
|
|
53
|
-
max-width: 100%;
|
|
54
|
-
height: auto;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.content :global(h1:not(:where(.not-content *))) {
|
|
58
|
-
font-size: var(--sl-text-h1);
|
|
59
|
-
}
|
|
60
|
-
.content :global(h2:not(:where(.not-content *))) {
|
|
61
|
-
font-size: var(--sl-text-h2);
|
|
62
|
-
}
|
|
63
|
-
.content :global(h3:not(:where(.not-content *))) {
|
|
64
|
-
font-size: var(--sl-text-h3);
|
|
65
|
-
}
|
|
66
|
-
.content :global(h4:not(:where(.not-content *))) {
|
|
67
|
-
font-size: var(--sl-text-h4);
|
|
68
|
-
}
|
|
69
|
-
.content :global(h5:not(:where(.not-content *))) {
|
|
70
|
-
font-size: var(--sl-text-h5);
|
|
71
|
-
}
|
|
72
|
-
.content :global(h6:not(:where(.not-content *))) {
|
|
73
|
-
font-size: var(--sl-text-h6);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.content :global(a:not(:where(.not-content *))) {
|
|
77
|
-
color: var(--sl-color-text-accent);
|
|
78
|
-
}
|
|
79
|
-
.content :global(a:hover:not(:where(.not-content *))) {
|
|
80
|
-
color: var(--sl-color-white);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.content :global(code:not(:where(.not-content *))) {
|
|
84
|
-
background-color: var(--sl-color-bg-inline-code);
|
|
85
|
-
margin-block: -0.125rem;
|
|
86
|
-
padding: 0.125rem 0.375rem;
|
|
87
|
-
font-size: var(--sl-text-code-sm);
|
|
88
|
-
}
|
|
89
|
-
.content :global(:is(h1, h2, h3, h4, h5, h6) code) {
|
|
90
|
-
font-size: inherit;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.content :global(pre:not(:where(.not-content *))) {
|
|
94
|
-
border: 1px solid var(--sl-color-gray-5);
|
|
95
|
-
padding: 0.75rem 1rem;
|
|
96
|
-
font-size: var(--sl-text-code);
|
|
97
|
-
tab-size: 2;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.content :global(pre code:not(:where(.not-content *))) {
|
|
101
|
-
all: unset;
|
|
102
|
-
font-family: var(--__sl-font-mono);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.content :global(blockquote:not(:where(.not-content *))) {
|
|
106
|
-
border-inline-start: 1px solid var(--sl-color-gray-5);
|
|
107
|
-
padding-inline-start: 1rem;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.content :global(table:not(:where(.not-content *))) {
|
|
111
|
-
display: block;
|
|
112
|
-
overflow: auto;
|
|
113
|
-
border-collapse: collapse;
|
|
114
|
-
}
|
|
115
|
-
.content :global(tr:nth-child(2n):not(:where(.not-content *))) {
|
|
116
|
-
background-color: var(--sl-color-gray-7, var(--sl-color-gray-6));
|
|
117
|
-
}
|
|
118
|
-
.content :global(:is(th, td):not(:where(.not-content *))) {
|
|
119
|
-
border: 1px solid var(--sl-color-hairline-light);
|
|
120
|
-
padding: 0.375rem 0.8125rem;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.content :global(hr:not(:where(.not-content *))) {
|
|
124
|
-
border: 0;
|
|
125
|
-
border-bottom: 1px solid var(--sl-color-hairline);
|
|
126
|
-
}
|
|
127
|
-
</style>
|
|
6
|
+
<div class="sl-markdown-content"><slot /></div>
|
package/integrations/sitemap.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import sitemap, { type SitemapOptions } from '@astrojs/sitemap';
|
|
2
2
|
import type { StarlightConfig } from '../types';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* A wrapped version of the `@astrojs/sitemap` integration configured based
|
|
6
|
-
* on Starlight i18n config.
|
|
7
|
-
*/
|
|
8
|
-
export function starlightSitemap(opts: StarlightConfig) {
|
|
4
|
+
export function getSitemapConfig(opts: StarlightConfig): SitemapOptions {
|
|
9
5
|
const sitemapConfig: SitemapOptions = {};
|
|
10
6
|
if (opts.isMultilingual) {
|
|
11
7
|
sitemapConfig.i18n = {
|
|
12
|
-
defaultLocale: opts.defaultLocale.locale
|
|
8
|
+
defaultLocale: opts.defaultLocale.locale || 'root',
|
|
13
9
|
locales: Object.fromEntries(
|
|
14
10
|
Object.entries(opts.locales).map(([locale, config]) => [locale, config?.lang!])
|
|
15
11
|
),
|
|
16
12
|
};
|
|
17
13
|
}
|
|
18
|
-
return
|
|
14
|
+
return sitemapConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A wrapped version of the `@astrojs/sitemap` integration configured based
|
|
19
|
+
* on Starlight i18n config.
|
|
20
|
+
*/
|
|
21
|
+
export function starlightSitemap(opts: StarlightConfig) {
|
|
22
|
+
return sitemap(getSitemapConfig(opts));
|
|
19
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/starlight",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Build beautiful, high-performance documentation websites with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -154,12 +154,14 @@
|
|
|
154
154
|
"./schema": "./schema.ts",
|
|
155
155
|
"./types": "./types.ts",
|
|
156
156
|
"./index.astro": "./index.astro",
|
|
157
|
-
"./404.astro": "./404.astro"
|
|
157
|
+
"./404.astro": "./404.astro",
|
|
158
|
+
"./style/markdown.css": "./style/markdown.css"
|
|
158
159
|
},
|
|
159
160
|
"peerDependencies": {
|
|
160
161
|
"astro": "^3.2.0"
|
|
161
162
|
},
|
|
162
163
|
"devDependencies": {
|
|
164
|
+
"@astrojs/markdown-remark": "^3.2.1",
|
|
163
165
|
"@types/node": "^18.16.19",
|
|
164
166
|
"@vitest/coverage-v8": "^0.33.0",
|
|
165
167
|
"astro": "^3.2.3",
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
.sl-markdown-content
|
|
2
|
+
:not(a, strong, em, del, span, input, code)
|
|
3
|
+
+ :not(a, strong, em, del, span, input, code, :where(.not-content *)) {
|
|
4
|
+
margin-top: 1.5rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/* Headings after non-headings have more spacing. */
|
|
8
|
+
.sl-markdown-content
|
|
9
|
+
:not(h1, h2, h3, h4, h5, h6)
|
|
10
|
+
+ :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *)) {
|
|
11
|
+
margin-top: 2.5rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sl-markdown-content li + li:not(:where(.not-content *)),
|
|
15
|
+
.sl-markdown-content dt + dt:not(:where(.not-content *)),
|
|
16
|
+
.sl-markdown-content dt + dd:not(:where(.not-content *)),
|
|
17
|
+
.sl-markdown-content dd + dd:not(:where(.not-content *)) {
|
|
18
|
+
margin-top: 0.25rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sl-markdown-content
|
|
22
|
+
li
|
|
23
|
+
> :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *)) {
|
|
24
|
+
margin-bottom: 1.25rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sl-markdown-content dt:not(:where(.not-content *)) {
|
|
28
|
+
font-weight: 700;
|
|
29
|
+
}
|
|
30
|
+
.sl-markdown-content dd:not(:where(.not-content *)) {
|
|
31
|
+
padding-inline-start: 1rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.sl-markdown-content :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *)) {
|
|
35
|
+
color: var(--sl-color-white);
|
|
36
|
+
line-height: var(--sl-line-height-headings);
|
|
37
|
+
font-weight: 600;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.sl-markdown-content :is(img, picture, video, canvas, svg, iframe):not(:where(.not-content *)) {
|
|
41
|
+
display: block;
|
|
42
|
+
max-width: 100%;
|
|
43
|
+
height: auto;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sl-markdown-content h1:not(:where(.not-content *)) {
|
|
47
|
+
font-size: var(--sl-text-h1);
|
|
48
|
+
}
|
|
49
|
+
.sl-markdown-content h2:not(:where(.not-content *)) {
|
|
50
|
+
font-size: var(--sl-text-h2);
|
|
51
|
+
}
|
|
52
|
+
.sl-markdown-content h3:not(:where(.not-content *)) {
|
|
53
|
+
font-size: var(--sl-text-h3);
|
|
54
|
+
}
|
|
55
|
+
.sl-markdown-content h4:not(:where(.not-content *)) {
|
|
56
|
+
font-size: var(--sl-text-h4);
|
|
57
|
+
}
|
|
58
|
+
.sl-markdown-content h5:not(:where(.not-content *)) {
|
|
59
|
+
font-size: var(--sl-text-h5);
|
|
60
|
+
}
|
|
61
|
+
.sl-markdown-content h6:not(:where(.not-content *)) {
|
|
62
|
+
font-size: var(--sl-text-h6);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.sl-markdown-content a:not(:where(.not-content *)) {
|
|
66
|
+
color: var(--sl-color-text-accent);
|
|
67
|
+
}
|
|
68
|
+
.sl-markdown-content a:hover:not(:where(.not-content *)) {
|
|
69
|
+
color: var(--sl-color-white);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.sl-markdown-content code:not(:where(.not-content *)) {
|
|
73
|
+
background-color: var(--sl-color-bg-inline-code);
|
|
74
|
+
margin-block: -0.125rem;
|
|
75
|
+
padding: 0.125rem 0.375rem;
|
|
76
|
+
font-size: var(--sl-text-code-sm);
|
|
77
|
+
}
|
|
78
|
+
.sl-markdown-content :is(h1, h2, h3, h4, h5, h6) code {
|
|
79
|
+
font-size: inherit;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.sl-markdown-content pre:not(:where(.not-content *)) {
|
|
83
|
+
border: 1px solid var(--sl-color-gray-5);
|
|
84
|
+
padding: 0.75rem 1rem;
|
|
85
|
+
font-size: var(--sl-text-code);
|
|
86
|
+
tab-size: 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.sl-markdown-content pre code:not(:where(.not-content *)) {
|
|
90
|
+
all: unset;
|
|
91
|
+
font-family: var(--__sl-font-mono);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.sl-markdown-content blockquote:not(:where(.not-content *)) {
|
|
95
|
+
border-inline-start: 1px solid var(--sl-color-gray-5);
|
|
96
|
+
padding-inline-start: 1rem;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sl-markdown-content table:not(:where(.not-content *)) {
|
|
100
|
+
display: block;
|
|
101
|
+
overflow: auto;
|
|
102
|
+
border-collapse: collapse;
|
|
103
|
+
}
|
|
104
|
+
.sl-markdown-content tr:nth-child(2n):not(:where(.not-content *)) {
|
|
105
|
+
background-color: var(--sl-color-gray-7, var(--sl-color-gray-6));
|
|
106
|
+
}
|
|
107
|
+
.sl-markdown-content :is(th, td):not(:where(.not-content *)) {
|
|
108
|
+
border: 1px solid var(--sl-color-hairline-light);
|
|
109
|
+
padding: 0.375rem 0.8125rem;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.sl-markdown-content hr:not(:where(.not-content *)) {
|
|
113
|
+
border: 0;
|
|
114
|
+
border-bottom: 1px solid var(--sl-color-hairline);
|
|
115
|
+
}
|
package/utils/navigation.ts
CHANGED
|
@@ -135,7 +135,7 @@ function makeLink(
|
|
|
135
135
|
attrs?: LinkHTMLAttributes
|
|
136
136
|
): Link {
|
|
137
137
|
if (!isAbsolute(href)) href = pathWithBase(href);
|
|
138
|
-
const isCurrent = href === ensureTrailingSlash(currentPathname);
|
|
138
|
+
const isCurrent = encodeURI(href) === ensureTrailingSlash(currentPathname);
|
|
139
139
|
return { type: 'link', label, href, isCurrent, badge, attrs: attrs ?? {} };
|
|
140
140
|
}
|
|
141
141
|
|
package/utils/route-data.ts
CHANGED
|
@@ -66,9 +66,9 @@ function getToC({ entry, locale, headings }: PageProps) {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
function getLastUpdated({ entry
|
|
69
|
+
function getLastUpdated({ entry }: PageProps): Date | undefined {
|
|
70
70
|
if (entry.data.lastUpdated ?? config.lastUpdated) {
|
|
71
|
-
const currentFilePath = fileURLToPath(new URL('src/content/docs/' + id, project.root));
|
|
71
|
+
const currentFilePath = fileURLToPath(new URL('src/content/docs/' + entry.id, project.root));
|
|
72
72
|
let date = typeof entry.data.lastUpdated !== 'boolean' ? entry.data.lastUpdated : undefined;
|
|
73
73
|
if (!date) {
|
|
74
74
|
try {
|