@dogsbay/docs-layout 0.2.0-beta.150 → 0.2.0-beta.151
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 +5 -5
- package/src/AnnouncementBar.astro +2 -2
- package/src/DocsLayout.astro +14 -10
- package/src/HeaderLinks.astro +4 -2
- package/src/site-chrome.ts +2 -1
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.151",
|
|
4
4
|
"description": "Standard documentation layout components for Dogsbay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"./site-chrome": "./src/site-chrome.ts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@dogsbay/elements": "0.2.0-beta.
|
|
39
|
-
"@dogsbay/primitives": "0.2.0-beta.
|
|
40
|
-
"@dogsbay/
|
|
41
|
-
"@dogsbay/
|
|
38
|
+
"@dogsbay/elements": "0.2.0-beta.151",
|
|
39
|
+
"@dogsbay/primitives": "0.2.0-beta.151",
|
|
40
|
+
"@dogsbay/site-files": "0.2.0-beta.151",
|
|
41
|
+
"@dogsbay/ui": "0.2.0-beta.151"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"happy-dom": "^20.10.6",
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
import { ANNOUNCEMENT_TONE_CLASS } from "./site-chrome.js";
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
|
-
announcement: { id: string; html: string; tone: string; closeable: boolean };
|
|
11
|
+
announcement: { id: string; key?: string; html: string; tone: string; closeable: boolean };
|
|
12
12
|
}
|
|
13
13
|
const { announcement } = Astro.props;
|
|
14
14
|
const tone = ANNOUNCEMENT_TONE_CLASS[announcement.tone] ?? ANNOUNCEMENT_TONE_CLASS.note;
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
<db-announcement
|
|
18
|
-
announcement-id={announcement.id}
|
|
18
|
+
announcement-id={announcement.key ?? announcement.id}
|
|
19
19
|
class:list={["db-announcement block border-b text-sm text-foreground", tone]}
|
|
20
20
|
role="region"
|
|
21
21
|
aria-label="Announcement"
|
package/src/DocsLayout.astro
CHANGED
|
@@ -805,8 +805,9 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
805
805
|
---
|
|
806
806
|
|
|
807
807
|
<!doctype html>
|
|
808
|
-
<html lang="en">
|
|
808
|
+
<html lang="en" class:list={[siteChrome?.colorMode === "dark" && "dark"]}>
|
|
809
809
|
<head>
|
|
810
|
+
{/* colorMode: dark is in the built page (the html class), so it holds with no script (a sandboxed preview); the head script still honours a stored "light" */}
|
|
810
811
|
<meta charset="UTF-8" />
|
|
811
812
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
812
813
|
<title>{title} | {siteName}</title>
|
|
@@ -1054,7 +1055,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1054
1055
|
*/}
|
|
1055
1056
|
{siteChrome?.announcement?.closeable && (
|
|
1056
1057
|
<>
|
|
1057
|
-
<meta name="db-announcement" content={siteChrome.announcement.id} />
|
|
1058
|
+
<meta name="db-announcement" content={siteChrome.announcement.key ?? siteChrome.announcement.id} />
|
|
1058
1059
|
<script is:inline set:html={ANNOUNCEMENT_HEAD_SCRIPT} />
|
|
1059
1060
|
<style is:inline set:html={ANNOUNCEMENT_CSS} />
|
|
1060
1061
|
</>
|
|
@@ -1085,8 +1086,8 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1085
1086
|
{siteChrome?.logo ? (
|
|
1086
1087
|
<>
|
|
1087
1088
|
{/* 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" />}
|
|
1089
|
+
<img src={siteChrome.logo.light} alt={siteChrome.logo.replacesName ? siteChrome.logo.alt || siteName : ""} class:list={["site-logo h-8 w-auto max-w-[10rem] object-contain object-left", siteChrome.logo.dark && "dark:hidden"]} />
|
|
1090
|
+
{siteChrome.logo.dark && <img src={siteChrome.logo.dark} alt={siteChrome.logo.replacesName ? siteChrome.logo.alt || siteName : ""} class="site-logo hidden h-8 w-auto max-w-[10rem] object-contain object-left dark:block" />}
|
|
1090
1091
|
</>
|
|
1091
1092
|
) : (
|
|
1092
1093
|
<div class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
|
|
@@ -1190,12 +1191,15 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1190
1191
|
can never leave another sticky bar overlapping or floating.
|
|
1191
1192
|
*/}
|
|
1192
1193
|
{siteChrome?.announcement && <AnnouncementBar announcement={siteChrome.announcement} />}
|
|
1193
|
-
<header class="sticky top-0 z-40 flex
|
|
1194
|
+
<header class:list={["sticky top-0 z-40 flex shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur-sm supports-[backdrop-filter]:bg-background/60", chrome !== "docs" && siteChrome?.header?.links.length ? "min-h-[var(--db-header-height)] flex-wrap py-1" : "h-[var(--db-header-height)]"]}>
|
|
1194
1195
|
{chrome === "docs" && <SidebarTrigger class="-ml-1" />}
|
|
1195
1196
|
<Separator orientation="vertical" class="mr-2 h-4" />
|
|
1196
|
-
{/* With header links, the page title shows only below lg, where the links are in the sidebar
|
|
1197
|
-
|
|
1198
|
-
{siteChrome?.header?.links.length
|
|
1197
|
+
{/* With header links, the page title shows only below lg, where the links are in the sidebar;
|
|
1198
|
+
a layout with no sidebar keeps the links in the header (wrapping) and no title */}
|
|
1199
|
+
{!(chrome !== "docs" && siteChrome?.header?.links.length) && (
|
|
1200
|
+
<span class:list={["text-sm text-muted-foreground", siteChrome?.header?.links.length && "lg:hidden"]} data-page-title>{title}</span>
|
|
1201
|
+
)}
|
|
1202
|
+
{siteChrome?.header?.links.length ? <HeaderLinks links={siteChrome.header.links} currentPath={currentPath} wrap={chrome !== "docs"} /> : null}
|
|
1199
1203
|
<div class="ml-auto flex items-center gap-2">
|
|
1200
1204
|
<slot name="header" />
|
|
1201
1205
|
{tocPlacement.popoverToc && (
|
|
@@ -1244,8 +1248,8 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
1244
1248
|
/>
|
|
1245
1249
|
)}
|
|
1246
1250
|
{siteChrome?.header ? (
|
|
1247
|
-
<SocialLinks links={siteChrome.header.social} class={siteChrome.header.links.length ? "max-md:hidden" : undefined} />
|
|
1248
|
-
) : repoUrl && (
|
|
1251
|
+
<SocialLinks links={siteChrome.header.social} class={chrome === "docs" && siteChrome.header.links.length ? "max-md:hidden" : undefined} />
|
|
1252
|
+
) : repoUrl && /^https?:\/\//i.test(repoUrl) && (
|
|
1249
1253
|
<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">
|
|
1250
1254
|
<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>
|
|
1251
1255
|
</a>
|
package/src/HeaderLinks.astro
CHANGED
|
@@ -10,8 +10,10 @@ interface Props {
|
|
|
10
10
|
links: Array<SiteChromeLink | SiteChromeMenu>;
|
|
11
11
|
layout?: "bar" | "list";
|
|
12
12
|
currentPath?: string;
|
|
13
|
+
/** A layout with no sidebar to move them into: shown at every width, wrapping. */
|
|
14
|
+
wrap?: boolean;
|
|
13
15
|
}
|
|
14
|
-
const { links, layout = "bar", currentPath } = Astro.props;
|
|
16
|
+
const { links, layout = "bar", currentPath, wrap = false } = Astro.props;
|
|
15
17
|
// The page, or a page under the link's section; a link to the site's root only on the root itself
|
|
16
18
|
const current = (href: string) => {
|
|
17
19
|
if (!currentPath || isExternal(href)) return undefined;
|
|
@@ -23,7 +25,7 @@ const current = (href: string) => {
|
|
|
23
25
|
---
|
|
24
26
|
|
|
25
27
|
{layout === "bar" ? (
|
|
26
|
-
<nav aria-label="Site" class="site-header-links
|
|
28
|
+
<nav aria-label="Site" class:list={["site-header-links items-center gap-1", wrap ? "flex min-w-0 flex-wrap" : "hidden lg:flex"]}>
|
|
27
29
|
{links.map((l) =>
|
|
28
30
|
isMenu(l) ? (
|
|
29
31
|
<details class="site-header-menu relative">
|
package/src/site-chrome.ts
CHANGED
|
@@ -20,7 +20,8 @@ export interface SiteChromeSocial {
|
|
|
20
20
|
export interface SiteChromeData {
|
|
21
21
|
colorMode?: "light" | "dark" | "system";
|
|
22
22
|
logo?: { light: string; dark?: string; alt: string; replacesName: boolean };
|
|
23
|
-
|
|
23
|
+
/** `key` (format-astro): the stored id, with the site's prefix; older site.json files have only `id`. */
|
|
24
|
+
announcement?: { id: string; key?: string; html: string; tone: string; closeable: boolean };
|
|
24
25
|
header?: { links: Array<SiteChromeLink | SiteChromeMenu>; social: SiteChromeSocial[] };
|
|
25
26
|
footer?: { columns: Array<{ title: string; links: SiteChromeLink[] }>; social: SiteChromeSocial[] };
|
|
26
27
|
}
|