@beatzball/create-litro 0.3.0 → 0.4.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 +19 -0
- package/LICENSE +78 -62
- package/dist/recipes/starlight/template/package.json +1 -0
- package/dist/recipes/starlight/template/pages/docs/[slug].ts +75 -2
- package/dist/recipes/starlight/template/public/styles/highlight.css +108 -0
- package/dist/recipes/starlight/template/src/components/starlight-header.ts +125 -29
- package/dist/recipes/starlight/template/src/components/starlight-page.ts +48 -4
- package/dist/recipes/starlight/template/src/highlight.ts +40 -0
- package/dist/recipes/starlight/template/src/route-meta.ts +1 -0
- package/package.json +16 -2
- package/recipes/starlight/template/package.json +1 -0
- package/recipes/starlight/template/pages/docs/[slug].ts +75 -2
- package/recipes/starlight/template/public/styles/highlight.css +108 -0
- package/recipes/starlight/template/src/components/starlight-header.ts +125 -29
- package/recipes/starlight/template/src/components/starlight-page.ts +48 -4
- package/recipes/starlight/template/src/highlight.ts +40 -0
- package/recipes/starlight/template/src/route-meta.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# create-litro
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 619ec3c: feat(seo): inject seoHead and seoTitle from pageData into HTML shell
|
|
8
|
+
|
|
9
|
+
Pages can now return `seoHead` (a string of meta/JSON-LD tags) and `seoTitle` from `definePageData()`. The framework extracts these at request time and injects them into the actual `<head>` element of the HTML response — not buried in the `__litro_data__` JSON blob.
|
|
10
|
+
|
|
11
|
+
Also bumps the `h3` dependency to `>=1.15.6` to patch CVE GHSA-22cc-p3c6-wpvm.
|
|
12
|
+
|
|
13
|
+
Also improves npm discoverability: updated descriptions and keywords for all three packages, and rewrote the framework README with a Hello World example, comparison table, and SEO section.
|
|
14
|
+
|
|
15
|
+
## 0.4.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 1cd1e7f: Add syntax highlighting to the starlight recipe. Code blocks in Markdown docs are now automatically highlighted at SSG build time using `highlight.js` with the fire palette theme (dark background, orange keywords, sky-blue strings, amber numbers). The `DocPage` component includes `static override styles` with all `.hljs-*` token rules so highlighting works correctly inside the Lit shadow DOM.
|
|
20
|
+
- 1a84fad: Add responsive hamburger menu to the starlight recipe. A hamburger button appears to the left of the site logo on screens ≤72rem where the sidebar is hidden. Clicking it opens/closes the sidebar as a fixed drawer overlay with a backdrop. The nav auto-closes on route change.
|
|
21
|
+
|
|
3
22
|
## 0.3.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/LICENSE
CHANGED
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
not limited to compiled object code, generated documentation,
|
|
33
33
|
and conversions to other media types.
|
|
34
34
|
|
|
35
|
-
"Work" shall mean the work of authorship
|
|
36
|
-
the License, as indicated by a
|
|
37
|
-
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
38
39
|
|
|
39
40
|
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
41
|
form, that is based on (or derived from) the Work and for which the
|
|
@@ -44,21 +45,23 @@
|
|
|
44
45
|
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
46
|
the Work and Derivative Works thereof.
|
|
46
47
|
|
|
47
|
-
"Contribution" shall mean
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
or
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
62
65
|
|
|
63
66
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
67
|
this License, each Contributor hereby grants to You a perpetual,
|
|
@@ -76,20 +79,20 @@
|
|
|
76
79
|
by such Contributor that are necessarily infringed by their
|
|
77
80
|
Contribution(s) alone or by combination of their Contribution(s)
|
|
78
81
|
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
-
institute patent litigation against any entity (including a
|
|
80
|
-
or counterclaim in a lawsuit) alleging that the Work
|
|
81
|
-
Contribution incorporated within the Work constitutes direct
|
|
82
|
-
contributory patent infringement, then any patent licenses
|
|
83
|
-
You under this License for that Work shall terminate
|
|
84
|
-
such litigation is filed.
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
85
88
|
|
|
86
89
|
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
90
|
Work or Derivative Works thereof in any medium, with or without
|
|
88
91
|
modifications, and in Source or Object form, provided that You
|
|
89
92
|
meet the following conditions:
|
|
90
93
|
|
|
91
|
-
(a) You must give any other recipients of the Work or
|
|
92
|
-
Works a copy of this License; and
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
93
96
|
|
|
94
97
|
(b) You must cause any modified files to carry prominent notices
|
|
95
98
|
stating that You changed the files; and
|
|
@@ -101,26 +104,28 @@
|
|
|
101
104
|
the Derivative Works; and
|
|
102
105
|
|
|
103
106
|
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
-
distribution,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
the
|
|
109
|
-
Derivative Works;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
use, reproduction,
|
|
123
|
-
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
124
129
|
|
|
125
130
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
126
131
|
any Contribution intentionally submitted for inclusion in the Work
|
|
@@ -142,7 +147,7 @@
|
|
|
142
147
|
implied, including, without limitation, any warranties or conditions
|
|
143
148
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
144
149
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
145
|
-
appropriateness of using or
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
146
151
|
risks associated with Your exercise of permissions under this License.
|
|
147
152
|
|
|
148
153
|
8. Limitation of Liability. In no event and under no legal theory,
|
|
@@ -150,26 +155,37 @@
|
|
|
150
155
|
unless required by applicable law (such as deliberate and grossly
|
|
151
156
|
negligent acts) or agreed to in writing, shall any Contributor be
|
|
152
157
|
liable to You for damages, including any direct, indirect, special,
|
|
153
|
-
incidental, or
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
154
159
|
result of this License or out of the use or inability to use the
|
|
155
160
|
Work (including but not limited to damages for loss of goodwill,
|
|
156
|
-
work stoppage, computer failure or malfunction, or all
|
|
157
|
-
commercial damages or losses), even if such Contributor
|
|
158
|
-
advised of the possibility of such damages.
|
|
159
|
-
|
|
160
|
-
9. Accepting Warranty or Liability. While redistributing
|
|
161
|
-
Derivative Works thereof, You may choose to offer,
|
|
162
|
-
for, acceptance of support, warranty, indemnity,
|
|
163
|
-
obligations and/or rights consistent with this
|
|
164
|
-
accepting such obligations, You may
|
|
165
|
-
Your own behalf and on Your sole responsibility, not on behalf
|
|
166
|
-
any other Contributor, and only if You agree to indemnify,
|
|
167
|
-
and hold each Contributor harmless for any liability
|
|
168
|
-
claims asserted against, such Contributor by reason
|
|
169
|
-
any such warranty or additional liability.
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
170
175
|
|
|
171
176
|
END OF TERMS AND CONDITIONS
|
|
172
177
|
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
173
189
|
Copyright 2026 beatzball
|
|
174
190
|
|
|
175
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
1
|
+
import { html, css } from 'lit';
|
|
2
2
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import { LitroPage } from '@beatzball/litro/runtime';
|
|
@@ -8,6 +8,7 @@ import type { Post } from 'litro:content';
|
|
|
8
8
|
import { getPosts } from 'litro:content';
|
|
9
9
|
import { siteConfig } from '../../server/starlight.config.js';
|
|
10
10
|
import { extractHeadings, addHeadingIds } from '../../src/extract-headings.js';
|
|
11
|
+
import { applyHighlighting } from '../../src/highlight.js';
|
|
11
12
|
import { starlightHead } from '../../src/route-meta.js';
|
|
12
13
|
|
|
13
14
|
// Register components used in render()
|
|
@@ -55,7 +56,7 @@ export const pageData = definePageData(async (event) => {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
const toc = extractHeadings(doc.rawBody);
|
|
58
|
-
const body = addHeadingIds(doc.body);
|
|
59
|
+
const body = applyHighlighting(addHeadingIds(doc.body));
|
|
59
60
|
const { prevDoc, nextDoc } = computePrevNext(siteConfig.sidebar, slug);
|
|
60
61
|
const editUrl = siteConfig.editUrlBase
|
|
61
62
|
? `${siteConfig.editUrlBase}/content/docs/${slug}.md`
|
|
@@ -89,6 +90,78 @@ export const routeMeta = {
|
|
|
89
90
|
|
|
90
91
|
@customElement('page-docs-slug')
|
|
91
92
|
export class DocPage extends LitroPage {
|
|
93
|
+
/**
|
|
94
|
+
* Styles injected into page-docs-slug's shadow root so they reach the
|
|
95
|
+
* <div slot="content"> subtree. Global stylesheets (starlight.css,
|
|
96
|
+
* highlight.css) cannot pierce shadow DOM boundaries.
|
|
97
|
+
*/
|
|
98
|
+
static override styles = css`
|
|
99
|
+
/* ── Typography for slotted doc content ─────────────────────────── */
|
|
100
|
+
h1, h2, h3, h4, h5, h6 {
|
|
101
|
+
margin-top: 1.5em; margin-bottom: 0.5em;
|
|
102
|
+
font-weight: 600; line-height: 1.25;
|
|
103
|
+
color: var(--sl-color-text);
|
|
104
|
+
}
|
|
105
|
+
h1 { font-size: var(--sl-text-4xl, 2.25rem); }
|
|
106
|
+
h2 { font-size: var(--sl-text-2xl, 1.5rem); border-bottom: 1px solid var(--sl-color-border, #e8e8e8); padding-bottom: 0.25em; }
|
|
107
|
+
h3 { font-size: var(--sl-text-xl, 1.25rem); }
|
|
108
|
+
h4 { font-size: var(--sl-text-lg, 1.125rem); }
|
|
109
|
+
p { margin-top: 0; margin-bottom: 1rem; line-height: 1.7; }
|
|
110
|
+
a { color: var(--sl-color-text-accent, var(--sl-color-accent)); text-decoration: none; }
|
|
111
|
+
a:hover { text-decoration: underline; }
|
|
112
|
+
code {
|
|
113
|
+
font-family: var(--sl-font-mono, ui-monospace, monospace);
|
|
114
|
+
font-size: 0.875em;
|
|
115
|
+
background-color: var(--sl-color-bg-inline-code, #e8e8e8);
|
|
116
|
+
border: 1px solid var(--sl-color-border, #e8e8e8);
|
|
117
|
+
border-radius: 0.25rem;
|
|
118
|
+
padding: 0.15em 0.4em;
|
|
119
|
+
}
|
|
120
|
+
pre {
|
|
121
|
+
background-color: #0d0e11;
|
|
122
|
+
color: #e2e4e9;
|
|
123
|
+
border-radius: 0.375rem;
|
|
124
|
+
padding: 1rem 1.25rem;
|
|
125
|
+
overflow-x: auto;
|
|
126
|
+
margin: 1.5rem 0;
|
|
127
|
+
font-size: var(--sl-text-sm, 0.875rem);
|
|
128
|
+
line-height: 1.6;
|
|
129
|
+
}
|
|
130
|
+
pre code { background: none; border: none; padding: 0; font-size: inherit; }
|
|
131
|
+
ul, ol { padding-left: 1.5rem; margin: 0 0 1rem; }
|
|
132
|
+
li { margin-bottom: 0.25rem; line-height: 1.7; }
|
|
133
|
+
blockquote {
|
|
134
|
+
margin: 1.5rem 0; padding: 0.75rem 1rem;
|
|
135
|
+
border-left: 4px solid var(--sl-color-accent, #ea580c);
|
|
136
|
+
background-color: var(--sl-color-accent-low, #fff7ed);
|
|
137
|
+
border-radius: 0 0.375rem 0.375rem 0;
|
|
138
|
+
}
|
|
139
|
+
hr { border: none; border-top: 1px solid var(--sl-color-border, #e8e8e8); margin: 2rem 0; }
|
|
140
|
+
img { max-width: 100%; height: auto; }
|
|
141
|
+
table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: var(--sl-text-sm, 0.875rem); }
|
|
142
|
+
th, td { border: 1px solid var(--sl-color-border, #e8e8e8); padding: 0.5rem 0.75rem; text-align: left; }
|
|
143
|
+
th { background-color: var(--sl-color-gray-1, #f6f6f6); font-weight: 600; }
|
|
144
|
+
|
|
145
|
+
/* ── highlight.js fire theme ─────────────────────────────────────── */
|
|
146
|
+
pre:has(.hljs) { background-color: #0d0d10; color: #cbd5e1; }
|
|
147
|
+
.hljs { color: #cbd5e1; background: transparent; }
|
|
148
|
+
.hljs-keyword, .hljs-selector-tag, .hljs-tag { color: #f97316; }
|
|
149
|
+
.hljs-string, .hljs-attr, .hljs-attribute { color: #38bdf8; }
|
|
150
|
+
.hljs-number, .hljs-literal { color: #fbbf24; }
|
|
151
|
+
.hljs-title, .hljs-title.class_, .hljs-title.function_, .hljs-built_in { color: #fb923c; }
|
|
152
|
+
.hljs-comment { color: #6b7280; font-style: italic; }
|
|
153
|
+
.hljs-variable, .hljs-params { color: #cbd5e1; }
|
|
154
|
+
.hljs-operator, .hljs-punctuation { color: #94a3b8; }
|
|
155
|
+
.hljs-meta, .hljs-meta .hljs-keyword { color: #38bdf8; }
|
|
156
|
+
.hljs-type { color: #fb923c; }
|
|
157
|
+
.hljs-deletion { color: #f87171; background: rgba(248,113,113,.1); }
|
|
158
|
+
.hljs-addition { color: #4ade80; background: rgba(74,222,128,.1); }
|
|
159
|
+
.hljs-section, .hljs-selector-class, .hljs-selector-id { color: #fb923c; }
|
|
160
|
+
.hljs-symbol, .hljs-bullet, .hljs-link { color: #38bdf8; }
|
|
161
|
+
.hljs-emphasis { font-style: italic; }
|
|
162
|
+
.hljs-strong { font-weight: bold; }
|
|
163
|
+
`;
|
|
164
|
+
|
|
92
165
|
override render() {
|
|
93
166
|
const data = this.serverData as DocPageData | null;
|
|
94
167
|
if (!data?.doc) return html`<p>Loading…</p>`;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* highlight.js — fire theme (always dark background) */
|
|
2
|
+
|
|
3
|
+
pre:has(.hljs) {
|
|
4
|
+
background-color: #0d0d10;
|
|
5
|
+
color: #cbd5e1;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
[data-theme="dark"] pre:has(.hljs) {
|
|
9
|
+
background-color: #0d0d10;
|
|
10
|
+
color: #cbd5e1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.hljs {
|
|
14
|
+
color: #cbd5e1;
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Keywords: const, let, if, class, return … */
|
|
19
|
+
.hljs-keyword,
|
|
20
|
+
.hljs-selector-tag,
|
|
21
|
+
.hljs-tag {
|
|
22
|
+
color: #f97316;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Strings and attribute values */
|
|
26
|
+
.hljs-string,
|
|
27
|
+
.hljs-attr,
|
|
28
|
+
.hljs-attribute {
|
|
29
|
+
color: #38bdf8;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Numbers and boolean literals */
|
|
33
|
+
.hljs-number,
|
|
34
|
+
.hljs-literal {
|
|
35
|
+
color: #fbbf24;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Function/class names, built-ins */
|
|
39
|
+
.hljs-title,
|
|
40
|
+
.hljs-title.class_,
|
|
41
|
+
.hljs-title.function_,
|
|
42
|
+
.hljs-built_in {
|
|
43
|
+
color: #fb923c;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Comments */
|
|
47
|
+
.hljs-comment {
|
|
48
|
+
color: #6b7280;
|
|
49
|
+
font-style: italic;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Variables and parameters */
|
|
53
|
+
.hljs-variable,
|
|
54
|
+
.hljs-params {
|
|
55
|
+
color: #cbd5e1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Operators and punctuation */
|
|
59
|
+
.hljs-operator,
|
|
60
|
+
.hljs-punctuation {
|
|
61
|
+
color: #94a3b8;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Meta / imports / decorators */
|
|
65
|
+
.hljs-meta,
|
|
66
|
+
.hljs-meta .hljs-keyword {
|
|
67
|
+
color: #38bdf8;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Type annotations */
|
|
71
|
+
.hljs-type {
|
|
72
|
+
color: #fb923c;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Diff deletions */
|
|
76
|
+
.hljs-deletion {
|
|
77
|
+
color: #f87171;
|
|
78
|
+
background: rgba(248, 113, 113, 0.1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Diff additions */
|
|
82
|
+
.hljs-addition {
|
|
83
|
+
color: #4ade80;
|
|
84
|
+
background: rgba(74, 222, 128, 0.1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Section / selector */
|
|
88
|
+
.hljs-section,
|
|
89
|
+
.hljs-selector-class,
|
|
90
|
+
.hljs-selector-id {
|
|
91
|
+
color: #fb923c;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Symbol / bullet */
|
|
95
|
+
.hljs-symbol,
|
|
96
|
+
.hljs-bullet,
|
|
97
|
+
.hljs-link {
|
|
98
|
+
color: #38bdf8;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Emphasis */
|
|
102
|
+
.hljs-emphasis {
|
|
103
|
+
font-style: italic;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.hljs-strong {
|
|
107
|
+
font-weight: bold;
|
|
108
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LitElement, html, css } from
|
|
2
|
-
import { customElement } from
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { customElement } from "lit/decorators.js";
|
|
3
3
|
|
|
4
4
|
export interface NavItem {
|
|
5
5
|
label: string;
|
|
@@ -10,12 +10,14 @@ export interface NavItem {
|
|
|
10
10
|
* <starlight-header siteTitle="My Docs" .nav=${nav} currentPath="/docs/getting-started">
|
|
11
11
|
* Top navigation bar with site title, nav links, and dark/light theme toggle.
|
|
12
12
|
*/
|
|
13
|
-
@customElement(
|
|
13
|
+
@customElement("starlight-header")
|
|
14
14
|
export class StarlightHeader extends LitElement {
|
|
15
15
|
static override properties = {
|
|
16
16
|
siteTitle: { type: String },
|
|
17
17
|
nav: { type: Array },
|
|
18
18
|
currentPath: { type: String },
|
|
19
|
+
navOpen: { type: Boolean },
|
|
20
|
+
hasSidebar: { type: Boolean },
|
|
19
21
|
_theme: { type: String, state: true },
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -34,7 +36,39 @@ export class StarlightHeader extends LitElement {
|
|
|
34
36
|
display: flex;
|
|
35
37
|
align-items: center;
|
|
36
38
|
padding: 0 var(--sl-content-pad-x, 1.5rem);
|
|
37
|
-
gap:
|
|
39
|
+
gap: 1rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.menu-btn {
|
|
43
|
+
display: none;
|
|
44
|
+
appearance: none;
|
|
45
|
+
background: none;
|
|
46
|
+
border: 1px solid var(--sl-color-border, #e8e8e8);
|
|
47
|
+
border-radius: var(--sl-border-radius, 0.375rem);
|
|
48
|
+
width: 2.25rem;
|
|
49
|
+
height: 2.25rem;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
color: var(--sl-color-text, #23262f);
|
|
54
|
+
transition: background-color 0.15s;
|
|
55
|
+
flex-shrink: 0;
|
|
56
|
+
padding: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.menu-btn:hover {
|
|
60
|
+
background-color: var(--sl-color-gray-2, #e8e8e8);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.menu-btn svg {
|
|
64
|
+
width: 1.1rem;
|
|
65
|
+
height: 1.1rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@media (max-width: 72rem) {
|
|
69
|
+
.menu-btn {
|
|
70
|
+
display: flex;
|
|
71
|
+
}
|
|
38
72
|
}
|
|
39
73
|
|
|
40
74
|
.site-title {
|
|
@@ -45,7 +79,9 @@ export class StarlightHeader extends LitElement {
|
|
|
45
79
|
white-space: nowrap;
|
|
46
80
|
}
|
|
47
81
|
|
|
48
|
-
.site-title:hover {
|
|
82
|
+
.site-title:hover {
|
|
83
|
+
opacity: 0.85;
|
|
84
|
+
}
|
|
49
85
|
|
|
50
86
|
nav {
|
|
51
87
|
display: flex;
|
|
@@ -61,7 +97,9 @@ export class StarlightHeader extends LitElement {
|
|
|
61
97
|
color: var(--sl-color-gray-5, #4b4b4b);
|
|
62
98
|
text-decoration: none;
|
|
63
99
|
border-radius: var(--sl-border-radius, 0.375rem);
|
|
64
|
-
transition:
|
|
100
|
+
transition:
|
|
101
|
+
color 0.15s,
|
|
102
|
+
background-color 0.15s;
|
|
65
103
|
}
|
|
66
104
|
|
|
67
105
|
nav a:hover {
|
|
@@ -69,7 +107,7 @@ export class StarlightHeader extends LitElement {
|
|
|
69
107
|
background-color: var(--sl-color-gray-2, #e8e8e8);
|
|
70
108
|
}
|
|
71
109
|
|
|
72
|
-
nav a[aria-current=
|
|
110
|
+
nav a[aria-current="page"] {
|
|
73
111
|
color: var(--sl-color-accent, #7c3aed);
|
|
74
112
|
background-color: var(--sl-color-accent-low, #ede9fe);
|
|
75
113
|
}
|
|
@@ -97,53 +135,111 @@ export class StarlightHeader extends LitElement {
|
|
|
97
135
|
}
|
|
98
136
|
`;
|
|
99
137
|
|
|
100
|
-
siteTitle =
|
|
138
|
+
siteTitle = "";
|
|
101
139
|
nav: NavItem[] = [];
|
|
102
|
-
currentPath =
|
|
140
|
+
currentPath = "";
|
|
141
|
+
navOpen = false;
|
|
142
|
+
hasSidebar = false;
|
|
103
143
|
|
|
104
|
-
_theme =
|
|
144
|
+
_theme = "light";
|
|
105
145
|
|
|
106
146
|
override firstUpdated() {
|
|
107
|
-
const stored =
|
|
108
|
-
|
|
109
|
-
|
|
147
|
+
const stored =
|
|
148
|
+
(typeof localStorage !== "undefined"
|
|
149
|
+
? localStorage.getItem("sl-theme")
|
|
150
|
+
: null) ?? "light";
|
|
110
151
|
this._theme = stored;
|
|
111
|
-
if (typeof document !==
|
|
112
|
-
document.documentElement.setAttribute(
|
|
152
|
+
if (typeof document !== "undefined") {
|
|
153
|
+
document.documentElement.setAttribute("data-theme", stored);
|
|
113
154
|
}
|
|
114
155
|
}
|
|
115
156
|
|
|
116
157
|
private _toggleTheme() {
|
|
117
|
-
const next = this._theme ===
|
|
158
|
+
const next = this._theme === "light" ? "dark" : "light";
|
|
118
159
|
this._theme = next;
|
|
119
|
-
if (typeof localStorage !==
|
|
120
|
-
localStorage.setItem(
|
|
160
|
+
if (typeof localStorage !== "undefined") {
|
|
161
|
+
localStorage.setItem("sl-theme", next);
|
|
121
162
|
}
|
|
122
|
-
if (typeof document !==
|
|
123
|
-
document.documentElement.setAttribute(
|
|
163
|
+
if (typeof document !== "undefined") {
|
|
164
|
+
document.documentElement.setAttribute("data-theme", next);
|
|
124
165
|
}
|
|
125
166
|
}
|
|
126
167
|
|
|
168
|
+
private _toggleNav() {
|
|
169
|
+
this.dispatchEvent(
|
|
170
|
+
new CustomEvent("sl-nav-toggle", { bubbles: true, composed: true }),
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
127
174
|
override render() {
|
|
128
|
-
const icon = this._theme ===
|
|
129
|
-
const label =
|
|
175
|
+
const icon = this._theme === "dark" ? "☀️" : "🌙";
|
|
176
|
+
const label =
|
|
177
|
+
this._theme === "dark" ? "Switch to light mode" : "Switch to dark mode";
|
|
130
178
|
|
|
131
179
|
return html`
|
|
132
180
|
<header>
|
|
181
|
+
${this.hasSidebar
|
|
182
|
+
? html`
|
|
183
|
+
<button
|
|
184
|
+
class="menu-btn"
|
|
185
|
+
aria-label="${this.navOpen
|
|
186
|
+
? "Close navigation"
|
|
187
|
+
: "Open navigation"}"
|
|
188
|
+
aria-expanded="${this.navOpen}"
|
|
189
|
+
@click="${this._toggleNav}"
|
|
190
|
+
>
|
|
191
|
+
${this.navOpen
|
|
192
|
+
? html`
|
|
193
|
+
<svg
|
|
194
|
+
viewBox="0 0 24 24"
|
|
195
|
+
fill="none"
|
|
196
|
+
stroke="currentColor"
|
|
197
|
+
stroke-width="2"
|
|
198
|
+
stroke-linecap="round"
|
|
199
|
+
aria-hidden="true"
|
|
200
|
+
>
|
|
201
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
202
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
203
|
+
</svg>
|
|
204
|
+
`
|
|
205
|
+
: html`
|
|
206
|
+
<svg
|
|
207
|
+
viewBox="0 0 24 24"
|
|
208
|
+
fill="none"
|
|
209
|
+
stroke="currentColor"
|
|
210
|
+
stroke-width="2"
|
|
211
|
+
stroke-linecap="round"
|
|
212
|
+
aria-hidden="true"
|
|
213
|
+
>
|
|
214
|
+
<line x1="3" y1="6" x2="21" y2="6" />
|
|
215
|
+
<line x1="3" y1="12" x2="21" y2="12" />
|
|
216
|
+
<line x1="3" y1="18" x2="21" y2="18" />
|
|
217
|
+
</svg>
|
|
218
|
+
`}
|
|
219
|
+
</button>
|
|
220
|
+
`
|
|
221
|
+
: ""}
|
|
133
222
|
<a class="site-title" href="/">${this.siteTitle}</a>
|
|
134
223
|
<nav aria-label="Main navigation">
|
|
135
|
-
${this.nav.map(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
224
|
+
${this.nav.map(
|
|
225
|
+
(item) => html`
|
|
226
|
+
<a
|
|
227
|
+
href="${item.href}"
|
|
228
|
+
aria-current="${this.currentPath.startsWith(item.href)
|
|
229
|
+
? "page"
|
|
230
|
+
: "false"}"
|
|
231
|
+
>${item.label}</a
|
|
232
|
+
>
|
|
233
|
+
`,
|
|
234
|
+
)}
|
|
141
235
|
</nav>
|
|
142
236
|
<button
|
|
143
237
|
class="theme-toggle"
|
|
144
238
|
aria-label="${label}"
|
|
145
239
|
@click="${this._toggleTheme}"
|
|
146
|
-
|
|
240
|
+
>
|
|
241
|
+
${icon}
|
|
242
|
+
</button>
|
|
147
243
|
</header>
|
|
148
244
|
`;
|
|
149
245
|
}
|