@dogsbay/docs-layout 0.2.0-beta.171 → 0.2.0-beta.173
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/package.json +8 -7
- package/src/DocsLayout.astro +1 -0
- package/src/section-switcher.css +20 -0
- package/src/section-switcher.ts +4 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dogsbay/docs-layout",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.173",
|
|
4
4
|
"description": "Standard documentation layout components for Dogsbay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
"./HeaderLinks.astro": "./src/HeaderLinks.astro",
|
|
34
34
|
"./SocialLinks.astro": "./src/SocialLinks.astro",
|
|
35
35
|
"./site-chrome": "./src/site-chrome.ts",
|
|
36
|
-
"./section-switcher": "./src/section-switcher.ts"
|
|
36
|
+
"./section-switcher": "./src/section-switcher.ts",
|
|
37
|
+
"./section-switcher.css": "./src/section-switcher.css"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@dogsbay/elements": "0.2.0-beta.
|
|
40
|
-
"@dogsbay/primitives": "0.2.0-beta.
|
|
41
|
-
"@dogsbay/
|
|
42
|
-
"@dogsbay/
|
|
43
|
-
"@dogsbay/ui": "0.2.0-beta.
|
|
40
|
+
"@dogsbay/elements": "0.2.0-beta.173",
|
|
41
|
+
"@dogsbay/primitives": "0.2.0-beta.173",
|
|
42
|
+
"@dogsbay/site-files": "0.2.0-beta.173",
|
|
43
|
+
"@dogsbay/search": "0.2.0-beta.173",
|
|
44
|
+
"@dogsbay/ui": "0.2.0-beta.173"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"happy-dom": "^20.10.6",
|
package/src/DocsLayout.astro
CHANGED
|
@@ -35,6 +35,7 @@ import DocsNavClient from "./DocsNavClient.astro";
|
|
|
35
35
|
import Separator from "@dogsbay/ui/separator/Separator.astro";
|
|
36
36
|
import ThemeToggle from "@dogsbay/ui/theme-toggle/ThemeToggle.astro";
|
|
37
37
|
import DocsToc from "./DocsToc.astro";
|
|
38
|
+
import "./section-switcher.css";
|
|
38
39
|
import { resolveTocPlacement, hasDisplayableToc, type TocMode } from "./toc-placement.js";
|
|
39
40
|
import { linkIconAttrs } from "./link-icons.js";
|
|
40
41
|
import DocsFooter from "./DocsFooter.astro";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The section menu's entries (section-switcher.ts). One short class per
|
|
3
|
+
* entry instead of a Tailwind list repeated on each: Cloudflare's menu has
|
|
4
|
+
* 115 entries, and the repeated classes were 17.7 KB of every page.
|
|
5
|
+
* Plain CSS over the theme tokens, so dogsbay-ssg copies this file as it is.
|
|
6
|
+
*/
|
|
7
|
+
.db-section-link {
|
|
8
|
+
display: flex;
|
|
9
|
+
border-radius: calc(var(--radius) - 4px);
|
|
10
|
+
padding: 0.375rem 0.5rem;
|
|
11
|
+
color: var(--foreground);
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
}
|
|
14
|
+
.db-section-link:hover {
|
|
15
|
+
background-color: var(--accent);
|
|
16
|
+
}
|
|
17
|
+
.db-section-link[aria-current="true"] {
|
|
18
|
+
background-color: var(--accent);
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
}
|
package/src/section-switcher.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* dogsbay-ssg (which copies this file, as it copies site-chrome.ts) cannot
|
|
8
8
|
* drift. No imports, so a copy runs on its own.
|
|
9
9
|
*
|
|
10
|
-
* The data comes from `sectionMenu` in @dogsbay/site-files.
|
|
10
|
+
* The data comes from `sectionMenu` in @dogsbay/site-files. The entries are
|
|
11
|
+
* styled by section-switcher.css (a host includes it once), not per entry.
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
export interface SectionSwitcherEntry {
|
|
@@ -49,10 +50,8 @@ export function sectionSwitcherHtml(o: SectionSwitcherOptions): string {
|
|
|
49
50
|
const cur =
|
|
50
51
|
o.current !== undefined &&
|
|
51
52
|
(e.index !== undefined && o.current.index !== undefined ? e.index === o.current.index : e.href === o.current.href);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
: "flex rounded-sm px-2 py-1.5 no-underline text-foreground hover:bg-accent";
|
|
55
|
-
return `<li><a href="${esc(e.href)}"${cur ? ' aria-current="true"' : ""} class="${cls}">${esc(e.label)}</a></li>`;
|
|
53
|
+
// styled by section-switcher.css: one short class, not a class list per entry
|
|
54
|
+
return `<li><a href="${esc(e.href)}"${cur ? ' aria-current="true"' : ""} class="db-section-link">${esc(e.label)}</a></li>`;
|
|
56
55
|
})
|
|
57
56
|
.join("");
|
|
58
57
|
const name = o.current
|