@dogsbay/docs-layout 0.2.0-beta.149 → 0.2.0-beta.150
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 +10 -5
- package/src/AnnouncementBar.astro +38 -0
- package/src/DocsFooter.astro +33 -3
- package/src/DocsLayout.astro +64 -15
- package/src/HeaderLinks.astro +76 -0
- package/src/SocialLinks.astro +34 -0
- package/src/site-chrome.ts +39 -0
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.150",
|
|
4
4
|
"description": "Standard documentation layout components for Dogsbay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -28,12 +28,17 @@
|
|
|
28
28
|
"./pagefind-base-url": "./src/pagefind-base-url.ts",
|
|
29
29
|
"./tag-list-data": "./src/tag-list-data.ts",
|
|
30
30
|
"./llm-actions": "./src/llm-actions.ts",
|
|
31
|
-
"./json-ld": "./src/json-ld.ts"
|
|
31
|
+
"./json-ld": "./src/json-ld.ts",
|
|
32
|
+
"./AnnouncementBar.astro": "./src/AnnouncementBar.astro",
|
|
33
|
+
"./HeaderLinks.astro": "./src/HeaderLinks.astro",
|
|
34
|
+
"./SocialLinks.astro": "./src/SocialLinks.astro",
|
|
35
|
+
"./site-chrome": "./src/site-chrome.ts"
|
|
32
36
|
},
|
|
33
37
|
"dependencies": {
|
|
34
|
-
"@dogsbay/
|
|
35
|
-
"@dogsbay/
|
|
36
|
-
"@dogsbay/ui": "0.2.0-beta.
|
|
38
|
+
"@dogsbay/elements": "0.2.0-beta.150",
|
|
39
|
+
"@dogsbay/primitives": "0.2.0-beta.150",
|
|
40
|
+
"@dogsbay/ui": "0.2.0-beta.150",
|
|
41
|
+
"@dogsbay/site-files": "0.2.0-beta.150"
|
|
37
42
|
},
|
|
38
43
|
"devDependencies": {
|
|
39
44
|
"happy-dom": "^20.10.6",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* The site's announcement bar (`site.announcement`): a full-width band above the header in the
|
|
4
|
+
* callout colours of its tone. A closeable one is a `<db-announcement>` (@dogsbay/elements): the
|
|
5
|
+
* reader's close is remembered under its id, and DocsLayout's head script hides it before first
|
|
6
|
+
* paint on later pages. `html` is site-files' inline Markdown, rendered at build.
|
|
7
|
+
*/
|
|
8
|
+
import { ANNOUNCEMENT_TONE_CLASS } from "./site-chrome.js";
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
announcement: { id: string; html: string; tone: string; closeable: boolean };
|
|
12
|
+
}
|
|
13
|
+
const { announcement } = Astro.props;
|
|
14
|
+
const tone = ANNOUNCEMENT_TONE_CLASS[announcement.tone] ?? ANNOUNCEMENT_TONE_CLASS.note;
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<db-announcement
|
|
18
|
+
announcement-id={announcement.id}
|
|
19
|
+
class:list={["db-announcement block border-b text-sm text-foreground", tone]}
|
|
20
|
+
role="region"
|
|
21
|
+
aria-label="Announcement"
|
|
22
|
+
data-pagefind-ignore
|
|
23
|
+
>
|
|
24
|
+
<div class="mx-auto flex min-h-10 items-center gap-2 px-4 py-2">
|
|
25
|
+
<p class="m-0 flex-1 text-center [&_a]:font-medium [&_a]:underline [&_a]:underline-offset-2"><Fragment set:html={announcement.html} /></p>
|
|
26
|
+
{announcement.closeable && (
|
|
27
|
+
<button type="button" data-part="close" aria-label="Close announcement" class="shrink-0 rounded-md p-1 text-foreground/80 hover:bg-foreground/10 hover:text-foreground">
|
|
28
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
29
|
+
</button>
|
|
30
|
+
)}
|
|
31
|
+
</div>
|
|
32
|
+
</db-announcement>
|
|
33
|
+
|
|
34
|
+
{announcement.closeable && (
|
|
35
|
+
<script>
|
|
36
|
+
import "@dogsbay/elements/db-announcement";
|
|
37
|
+
</script>
|
|
38
|
+
)}
|
package/src/DocsFooter.astro
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
/**
|
|
3
3
|
* Documentation page footer.
|
|
4
|
-
* Edit link, last updated, prev/next pagination
|
|
4
|
+
* Edit link, last updated, prev/next pagination; the site's footer columns and social icons
|
|
5
|
+
* (`footer:` in dogsbay.config.yml) above the bottom row.
|
|
5
6
|
*/
|
|
7
|
+
import SocialLinks from "./SocialLinks.astro";
|
|
8
|
+
import { isExternal, type SiteChromeLink, type SiteChromeSocial } from "./site-chrome.js";
|
|
6
9
|
|
|
7
10
|
interface PaginationLink {
|
|
8
11
|
label: string;
|
|
@@ -40,6 +43,10 @@ interface Props {
|
|
|
40
43
|
* tool. See docs/powered-by.md.
|
|
41
44
|
*/
|
|
42
45
|
poweredBy?: boolean;
|
|
46
|
+
/** `footer.columns`: titled link lists, above the bottom row. */
|
|
47
|
+
columns?: Array<{ title: string; links: SiteChromeLink[] }>;
|
|
48
|
+
/** `footer.social`: brand icons in the bottom row. */
|
|
49
|
+
social?: SiteChromeSocial[];
|
|
43
50
|
class?: string;
|
|
44
51
|
}
|
|
45
52
|
|
|
@@ -54,6 +61,8 @@ const {
|
|
|
54
61
|
llmsLink = false,
|
|
55
62
|
llmsLinkHref = "/llms.txt",
|
|
56
63
|
poweredBy = false,
|
|
64
|
+
columns = [],
|
|
65
|
+
social = [],
|
|
57
66
|
class: className,
|
|
58
67
|
} = Astro.props;
|
|
59
68
|
|
|
@@ -110,11 +119,32 @@ function formatDate(value: string): string {
|
|
|
110
119
|
</nav>
|
|
111
120
|
)}
|
|
112
121
|
|
|
113
|
-
{/*
|
|
114
|
-
{
|
|
122
|
+
{/* The site's footer columns: wrap on narrow screens */}
|
|
123
|
+
{columns.length > 0 && (
|
|
124
|
+
<nav aria-label="Footer" data-pagefind-ignore class="site-footer-columns mt-8 grid grid-cols-2 gap-6 text-sm first:mt-0 sm:grid-cols-3 lg:grid-cols-4">
|
|
125
|
+
{columns.map((c) => (
|
|
126
|
+
<div class="min-w-0">
|
|
127
|
+
<h2 class="mb-2 text-sm font-semibold text-foreground">{c.title}</h2>
|
|
128
|
+
<ul class="flex flex-col gap-1.5">
|
|
129
|
+
{c.links.map((l) => (
|
|
130
|
+
<li><a href={l.href} class="text-muted-foreground no-underline hover:text-foreground" data-external={isExternal(l.href) ? "" : undefined}>{l.label}</a></li>
|
|
131
|
+
))}
|
|
132
|
+
</ul>
|
|
133
|
+
</div>
|
|
134
|
+
))}
|
|
135
|
+
</nav>
|
|
136
|
+
)}
|
|
137
|
+
|
|
138
|
+
{/* Footer meta — copyright + social icons + agent-friendly llms.txt link + attribution */}
|
|
139
|
+
{(copyright || llmsLink || poweredBy || social.length > 0) && (
|
|
115
140
|
<div class="mt-6 flex flex-wrap items-center justify-between gap-2 border-t pt-4 text-xs text-muted-foreground">
|
|
116
141
|
{copyright ? <span><Fragment set:html={copyright} /></span> : <span />}
|
|
117
142
|
<div class="flex flex-wrap items-center gap-4">
|
|
143
|
+
{social.length > 0 && (
|
|
144
|
+
<div class="flex items-center gap-1">
|
|
145
|
+
<SocialLinks links={social} size="footer" />
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
118
148
|
{llmsLink && (
|
|
119
149
|
<a
|
|
120
150
|
href={llmsLinkHref}
|
package/src/DocsLayout.astro
CHANGED
|
@@ -45,6 +45,12 @@ import TypeBadge from "./TypeBadge.astro";
|
|
|
45
45
|
import PageActions from "./PageActions.astro";
|
|
46
46
|
import VersionSwitcher from "./VersionSwitcher.astro";
|
|
47
47
|
import ProductSwitcher from "./ProductSwitcher.astro";
|
|
48
|
+
import AnnouncementBar from "./AnnouncementBar.astro";
|
|
49
|
+
import HeaderLinks from "./HeaderLinks.astro";
|
|
50
|
+
import SocialLinks from "./SocialLinks.astro";
|
|
51
|
+
import type { SiteChromeData } from "./site-chrome.js";
|
|
52
|
+
import { COLOR_MODE_HEAD_SCRIPTS } from "@dogsbay/elements/color-mode-head";
|
|
53
|
+
import { ANNOUNCEMENT_CSS, ANNOUNCEMENT_HEAD_SCRIPT } from "@dogsbay/elements/announcement-head";
|
|
48
54
|
import LocaleSwitcher from "./LocaleSwitcher.astro";
|
|
49
55
|
import { filterNavByAxis, rootVersionFilter } from "./nav-filter.js";
|
|
50
56
|
import { versionBadge } from "./switcher.js";
|
|
@@ -491,11 +497,19 @@ interface Props {
|
|
|
491
497
|
* `poweredBy: false` in dogsbay.config.yml. See docs/powered-by.md.
|
|
492
498
|
*/
|
|
493
499
|
poweredBy?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* The site's chrome (`chrome` in site.json, format-astro's `chromeData`): logo, colour mode,
|
|
502
|
+
* announcement bar, header links, social icons, footer columns. With it, the header's
|
|
503
|
+
* repository icon is `siteChrome.header.social` (site.repoUrl is its default there), not
|
|
504
|
+
* `repoUrl`. See plans/site-chrome.md.
|
|
505
|
+
*/
|
|
506
|
+
siteChrome?: SiteChromeData;
|
|
494
507
|
class?: string;
|
|
495
508
|
}
|
|
496
509
|
|
|
497
510
|
const {
|
|
498
511
|
poweredBy = false,
|
|
512
|
+
siteChrome,
|
|
499
513
|
siteName,
|
|
500
514
|
siteTagline,
|
|
501
515
|
title,
|
|
@@ -1029,19 +1043,22 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1029
1043
|
would skip the class entirely, so it is guarded and degrades to
|
|
1030
1044
|
the OS preference.
|
|
1031
1045
|
*/}
|
|
1032
|
-
|
|
1033
|
-
(
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1046
|
+
{/*
|
|
1047
|
+
site.colorMode is the first-visit mode (system: the OS preference). @dogsbay/elements' fixed
|
|
1048
|
+
scripts, one per mode: dogsbay-ssg writes the same bytes, so the CSP hashes are shared.
|
|
1049
|
+
*/}
|
|
1050
|
+
<script is:inline set:html={COLOR_MODE_HEAD_SCRIPTS[siteChrome?.colorMode ?? "system"] ?? COLOR_MODE_HEAD_SCRIPTS.system} />
|
|
1051
|
+
{/*
|
|
1052
|
+
A closed announcement bar never shows, not even for a frame: @dogsbay/elements' fixed head
|
|
1053
|
+
script (the same bytes dogsbay-ssg uses) reads the bar's id from the meta before it is drawn.
|
|
1054
|
+
*/}
|
|
1055
|
+
{siteChrome?.announcement?.closeable && (
|
|
1056
|
+
<>
|
|
1057
|
+
<meta name="db-announcement" content={siteChrome.announcement.id} />
|
|
1058
|
+
<script is:inline set:html={ANNOUNCEMENT_HEAD_SCRIPT} />
|
|
1059
|
+
<style is:inline set:html={ANNOUNCEMENT_CSS} />
|
|
1060
|
+
</>
|
|
1061
|
+
)}
|
|
1045
1062
|
<slot name="head" />
|
|
1046
1063
|
</head>
|
|
1047
1064
|
<body
|
|
@@ -1065,13 +1082,24 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1065
1082
|
<SidebarMenu>
|
|
1066
1083
|
<SidebarMenuItem>
|
|
1067
1084
|
<SidebarMenuButton size="lg" href={basePath || "/"} isActive={currentPath === basePath || currentPath === "/"}>
|
|
1085
|
+
{siteChrome?.logo ? (
|
|
1086
|
+
<>
|
|
1087
|
+
{/* Two images, one hidden by the theme class: no script, no flash */}
|
|
1088
|
+
<img src={siteChrome.logo.light} alt={siteChrome.logo.replacesName ? siteName : ""} class:list={["site-logo h-8 w-auto max-w-[10rem] object-contain object-left", siteChrome.logo.dark && "dark:hidden"]} />
|
|
1089
|
+
{siteChrome.logo.dark && <img src={siteChrome.logo.dark} alt={siteChrome.logo.replacesName ? siteName : ""} class="site-logo hidden h-8 w-auto max-w-[10rem] object-contain object-left dark:block" />}
|
|
1090
|
+
</>
|
|
1091
|
+
) : (
|
|
1068
1092
|
<div class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
|
|
1069
1093
|
<Fragment set:html={siteIcon} />
|
|
1070
1094
|
</div>
|
|
1095
|
+
)}
|
|
1096
|
+
{/* A wordmark logo is the name: its alt is the site name, the link's accessible name */}
|
|
1097
|
+
{!siteChrome?.logo?.replacesName && (
|
|
1071
1098
|
<div class="grid flex-1 text-left text-sm leading-tight">
|
|
1072
1099
|
<span class="truncate font-semibold">{siteName}</span>
|
|
1073
1100
|
<span class="truncate text-xs text-sidebar-foreground/70">{siteTagline || "Documentation"}</span>
|
|
1074
1101
|
</div>
|
|
1102
|
+
)}
|
|
1075
1103
|
</SidebarMenuButton>
|
|
1076
1104
|
</SidebarMenuItem>
|
|
1077
1105
|
</SidebarMenu>
|
|
@@ -1080,6 +1108,20 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1080
1108
|
<SidebarSeparator />
|
|
1081
1109
|
|
|
1082
1110
|
<SidebarContent>
|
|
1111
|
+
{/* The header's links move here below lg, as Docusaurus moves navbar items into its drawer */}
|
|
1112
|
+
{siteChrome?.header?.links.length ? (
|
|
1113
|
+
<SidebarGroup class="lg:hidden">
|
|
1114
|
+
<SidebarGroupContent>
|
|
1115
|
+
<HeaderLinks links={siteChrome.header.links} layout="list" currentPath={currentPath} />
|
|
1116
|
+
{/* The header's icons too, below md, where the header has no room for them beside the links */}
|
|
1117
|
+
{siteChrome.header.social.length > 0 && (
|
|
1118
|
+
<div class="mt-2 flex flex-wrap items-center gap-1 px-1 md:hidden">
|
|
1119
|
+
<SocialLinks links={siteChrome.header.social} />
|
|
1120
|
+
</div>
|
|
1121
|
+
)}
|
|
1122
|
+
</SidebarGroupContent>
|
|
1123
|
+
</SidebarGroup>
|
|
1124
|
+
) : null}
|
|
1083
1125
|
{navMode === "client" ? (
|
|
1084
1126
|
// Client-render mode: emit one DocsNavClient placeholder
|
|
1085
1127
|
// inside a single SidebarGroup, regardless of navGroups.
|
|
@@ -1147,10 +1189,13 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1147
1189
|
the release-comparison toolbar. One variable, so a change here
|
|
1148
1190
|
can never leave another sticky bar overlapping or floating.
|
|
1149
1191
|
*/}
|
|
1192
|
+
{siteChrome?.announcement && <AnnouncementBar announcement={siteChrome.announcement} />}
|
|
1150
1193
|
<header class="sticky top-0 z-40 flex h-[var(--db-header-height)] shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur-sm supports-[backdrop-filter]:bg-background/60">
|
|
1151
1194
|
{chrome === "docs" && <SidebarTrigger class="-ml-1" />}
|
|
1152
1195
|
<Separator orientation="vertical" class="mr-2 h-4" />
|
|
1153
|
-
|
|
1196
|
+
{/* With header links, the page title shows only below lg, where the links are in the sidebar */}
|
|
1197
|
+
<span class:list={["text-sm text-muted-foreground", siteChrome?.header?.links.length && "lg:hidden"]} data-page-title>{title}</span>
|
|
1198
|
+
{siteChrome?.header?.links.length ? <HeaderLinks links={siteChrome.header.links} currentPath={currentPath} /> : null}
|
|
1154
1199
|
<div class="ml-auto flex items-center gap-2">
|
|
1155
1200
|
<slot name="header" />
|
|
1156
1201
|
{tocPlacement.popoverToc && (
|
|
@@ -1198,7 +1243,9 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1198
1243
|
scopeVersion={multiSource?.version}
|
|
1199
1244
|
/>
|
|
1200
1245
|
)}
|
|
1201
|
-
{
|
|
1246
|
+
{siteChrome?.header ? (
|
|
1247
|
+
<SocialLinks links={siteChrome.header.social} class={siteChrome.header.links.length ? "max-md:hidden" : undefined} />
|
|
1248
|
+
) : repoUrl && (
|
|
1202
1249
|
<a href={repoUrl} target="_blank" rel="noopener" class="rounded-md p-2 text-muted-foreground hover:bg-accent hover:text-foreground" aria-label="Source repository">
|
|
1203
1250
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
|
|
1204
1251
|
</a>
|
|
@@ -1445,6 +1492,8 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1445
1492
|
llmsLink={llmFooterLink}
|
|
1446
1493
|
llmsLinkHref={llmsLinkHrefResolved}
|
|
1447
1494
|
poweredBy={poweredBy}
|
|
1495
|
+
columns={siteChrome?.footer?.columns}
|
|
1496
|
+
social={siteChrome?.footer?.social}
|
|
1448
1497
|
/>
|
|
1449
1498
|
</div>
|
|
1450
1499
|
</main>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* The header's links (`header.links`): links, and one-level dropdowns as `<details>` lists like
|
|
4
|
+
* the version and product menus, so every link is in the HTML (crawlers, readers without
|
|
5
|
+
* JavaScript). `layout="bar"` for the header (from `lg`), `layout="list"` for the sidebar below it.
|
|
6
|
+
*/
|
|
7
|
+
import { isExternal, isMenu, type SiteChromeLink, type SiteChromeMenu } from "./site-chrome.js";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
links: Array<SiteChromeLink | SiteChromeMenu>;
|
|
11
|
+
layout?: "bar" | "list";
|
|
12
|
+
currentPath?: string;
|
|
13
|
+
}
|
|
14
|
+
const { links, layout = "bar", currentPath } = Astro.props;
|
|
15
|
+
// The page, or a page under the link's section; a link to the site's root only on the root itself
|
|
16
|
+
const current = (href: string) => {
|
|
17
|
+
if (!currentPath || isExternal(href)) return undefined;
|
|
18
|
+
const norm = (p: string) => (p.endsWith("/") ? p : `${p}/`);
|
|
19
|
+
const page = norm(currentPath);
|
|
20
|
+
const link = norm(href.replace(/[?#].*$/, ""));
|
|
21
|
+
return page === link || (link.split("/").filter(Boolean).length > 1 && page.startsWith(link)) ? "page" : undefined;
|
|
22
|
+
};
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
{layout === "bar" ? (
|
|
26
|
+
<nav aria-label="Site" class="site-header-links hidden items-center gap-1 lg:flex">
|
|
27
|
+
{links.map((l) =>
|
|
28
|
+
isMenu(l) ? (
|
|
29
|
+
<details class="site-header-menu relative">
|
|
30
|
+
<summary class="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground">
|
|
31
|
+
{l.label}
|
|
32
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
|
|
33
|
+
</summary>
|
|
34
|
+
<ul class="absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-border bg-popover p-1 text-sm shadow-md">
|
|
35
|
+
{l.items.map((i) => (
|
|
36
|
+
<li><a href={i.href} aria-current={current(i.href)} class="block rounded-sm px-2 py-1.5 text-foreground no-underline hover:bg-accent">{i.label}</a></li>
|
|
37
|
+
))}
|
|
38
|
+
</ul>
|
|
39
|
+
</details>
|
|
40
|
+
) : (
|
|
41
|
+
<a href={l.href} aria-current={current(l.href)} class="rounded-md px-2 py-1.5 text-sm text-muted-foreground no-underline hover:bg-accent hover:text-foreground aria-[current=page]:text-foreground">{l.label}</a>
|
|
42
|
+
),
|
|
43
|
+
)}
|
|
44
|
+
</nav>
|
|
45
|
+
) : (
|
|
46
|
+
<nav aria-label="Site" class="site-header-links-list">
|
|
47
|
+
<ul class="flex flex-col gap-0.5 text-sm">
|
|
48
|
+
{links.map((l) =>
|
|
49
|
+
isMenu(l) ? (
|
|
50
|
+
<li>
|
|
51
|
+
<span class="block px-2 py-1.5 text-xs font-medium text-sidebar-foreground/70">{l.label}</span>
|
|
52
|
+
<ul class="flex flex-col gap-0.5 pl-2">
|
|
53
|
+
{l.items.map((i) => (
|
|
54
|
+
<li><a href={i.href} aria-current={current(i.href)} class="block rounded-md px-2 py-1.5 text-sidebar-foreground no-underline hover:bg-sidebar-accent">{i.label}</a></li>
|
|
55
|
+
))}
|
|
56
|
+
</ul>
|
|
57
|
+
</li>
|
|
58
|
+
) : (
|
|
59
|
+
<li><a href={l.href} aria-current={current(l.href)} class="block rounded-md px-2 py-1.5 text-sidebar-foreground no-underline hover:bg-sidebar-accent">{l.label}</a></li>
|
|
60
|
+
),
|
|
61
|
+
)}
|
|
62
|
+
</ul>
|
|
63
|
+
</nav>
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
.site-header-menu > summary {
|
|
68
|
+
list-style: none;
|
|
69
|
+
}
|
|
70
|
+
.site-header-menu > summary::-webkit-details-marker {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
.site-header-menu[open] > summary > svg {
|
|
74
|
+
transform: rotate(180deg);
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Brand icon links (`header.social`, `footer.social`; `site.repoUrl` is the header's default).
|
|
4
|
+
* The SVG is @dogsbay/icons' (aria-hidden); the link carries the name. Another site opens in a
|
|
5
|
+
* new tab, as the repository icon always did.
|
|
6
|
+
*/
|
|
7
|
+
import { isExternal, type SiteChromeSocial } from "./site-chrome.js";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
links: SiteChromeSocial[];
|
|
11
|
+
size?: "header" | "footer";
|
|
12
|
+
/** Classes for each link (the header hides them below md, where they are in the sidebar). */
|
|
13
|
+
class?: string;
|
|
14
|
+
}
|
|
15
|
+
const { links, size = "header", class: className } = Astro.props;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
{links.map((s) => (
|
|
19
|
+
<a
|
|
20
|
+
href={s.href}
|
|
21
|
+
target={isExternal(s.href) ? "_blank" : undefined}
|
|
22
|
+
rel={isExternal(s.href) ? "noopener" : undefined}
|
|
23
|
+
aria-label={s.label}
|
|
24
|
+
title={s.label}
|
|
25
|
+
class:list={[
|
|
26
|
+
"inline-flex items-center justify-center text-muted-foreground hover:text-foreground",
|
|
27
|
+
size === "header" ? "rounded-md p-2 hover:bg-accent" : "p-1",
|
|
28
|
+
className,
|
|
29
|
+
]}
|
|
30
|
+
data-social-link
|
|
31
|
+
>
|
|
32
|
+
<Fragment set:html={s.svg} />
|
|
33
|
+
</a>
|
|
34
|
+
))}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The site's chrome as DocsLayout draws it: the `chrome` object format-astro writes into
|
|
3
|
+
* site.json (its `chromeData`), links already carrying the site's prefix, texts already HTML
|
|
4
|
+
* (@dogsbay/site-files inline Markdown), icons already SVG. dogsbay-ssg draws the same keys with
|
|
5
|
+
* its own markup and these classes. See plans/site-chrome.md.
|
|
6
|
+
*/
|
|
7
|
+
export interface SiteChromeLink {
|
|
8
|
+
label: string;
|
|
9
|
+
href: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SiteChromeMenu {
|
|
12
|
+
label: string;
|
|
13
|
+
items: SiteChromeLink[];
|
|
14
|
+
}
|
|
15
|
+
export interface SiteChromeSocial {
|
|
16
|
+
label: string;
|
|
17
|
+
href: string;
|
|
18
|
+
svg: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SiteChromeData {
|
|
21
|
+
colorMode?: "light" | "dark" | "system";
|
|
22
|
+
logo?: { light: string; dark?: string; alt: string; replacesName: boolean };
|
|
23
|
+
announcement?: { id: string; html: string; tone: string; closeable: boolean };
|
|
24
|
+
header?: { links: Array<SiteChromeLink | SiteChromeMenu>; social: SiteChromeSocial[] };
|
|
25
|
+
footer?: { columns: Array<{ title: string; links: SiteChromeLink[] }>; social: SiteChromeSocial[] };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const isMenu = (l: SiteChromeLink | SiteChromeMenu): l is SiteChromeMenu => "items" in l;
|
|
29
|
+
|
|
30
|
+
/** An http(s) address on another site: opened as the version menu's are, in the same tab, marked external for link icons. */
|
|
31
|
+
export const isExternal = (href: string): boolean => /^https?:\/\//i.test(href);
|
|
32
|
+
|
|
33
|
+
/** The announcement's colours by tone: the callout tokens, so the theme and dark mode apply. */
|
|
34
|
+
export const ANNOUNCEMENT_TONE_CLASS: Record<string, string> = {
|
|
35
|
+
note: "border-note/40 bg-note/15",
|
|
36
|
+
tip: "border-tip/40 bg-tip/15",
|
|
37
|
+
warning: "border-warning/40 bg-warning/20",
|
|
38
|
+
caution: "border-danger/40 bg-danger/15",
|
|
39
|
+
};
|