@tenphi/renderer 0.19.0
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/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/client/appearance.d.ts +12 -0
- package/dist/client/appearance.d.ts.map +1 -0
- package/dist/client/appearance.js +66 -0
- package/dist/client/appearance.js.map +1 -0
- package/dist/client/code-copy.d.ts +1 -0
- package/dist/client/code-copy.js +63 -0
- package/dist/client/code-copy.js.map +1 -0
- package/dist/client/heading-links.d.ts +6 -0
- package/dist/client/heading-links.d.ts.map +1 -0
- package/dist/client/heading-links.js +87 -0
- package/dist/client/heading-links.js.map +1 -0
- package/dist/client/mobile-toc.d.ts +1 -0
- package/dist/client/mobile-toc.js +28 -0
- package/dist/client/mobile-toc.js.map +1 -0
- package/dist/client/navigation.d.ts +1 -0
- package/dist/client/navigation.js +112 -0
- package/dist/client/navigation.js.map +1 -0
- package/dist/client/page-copy.d.ts +1 -0
- package/dist/client/page-copy.js +34 -0
- package/dist/client/page-copy.js.map +1 -0
- package/dist/client/search.d.ts +13 -0
- package/dist/client/search.d.ts.map +1 -0
- package/dist/client/search.js +87 -0
- package/dist/client/search.js.map +1 -0
- package/dist/client/sidebar.d.ts +1 -0
- package/dist/client/sidebar.js +93 -0
- package/dist/client/sidebar.js.map +1 -0
- package/dist/client/tabs.d.ts +6 -0
- package/dist/client/tabs.d.ts.map +1 -0
- package/dist/client/tabs.js +64 -0
- package/dist/client/tabs.js.map +1 -0
- package/dist/components/Callout.astro +15 -0
- package/dist/components/Card.astro +13 -0
- package/dist/components/CodeGroup.astro +47 -0
- package/dist/components/ContrastIcon.astro +29 -0
- package/dist/components/EditLink.astro +11 -0
- package/dist/components/GlobalStyles.js +1675 -0
- package/dist/components/HeaderLinks.astro +84 -0
- package/dist/components/Icon.astro +39 -0
- package/dist/components/LastUpdated.astro +17 -0
- package/dist/components/LayoutComponents.js +866 -0
- package/dist/components/Logo.astro +37 -0
- package/dist/components/MobileNavigationTabs.astro +79 -0
- package/dist/components/MobileTocList.astro +22 -0
- package/dist/components/PackageVersion.astro +25 -0
- package/dist/components/PageActions.astro +29 -0
- package/dist/components/Pagination.astro +29 -0
- package/dist/components/Preview.astro +34 -0
- package/dist/components/SidebarList.astro +122 -0
- package/dist/components/SiteLogo.astro +40 -0
- package/dist/components/SiteTitle.astro +7 -0
- package/dist/components/Steps.astro +6 -0
- package/dist/components/Tab.astro +10 -0
- package/dist/components/TableOfContents.astro +23 -0
- package/dist/components/Tabs.astro +16 -0
- package/dist/components/TastyComponents.js +255 -0
- package/dist/components/VersionSwitcher.astro +44 -0
- package/dist/components/appearance-preferences.test.ts +91 -0
- package/dist/components/appearance-preferences.ts +57 -0
- package/dist/components/component-styles.test.ts +129 -0
- package/dist/components/component-styles.ts +65 -0
- package/dist/components/customize-component.js +8 -0
- package/dist/components/props.d.ts +38 -0
- package/dist/components/props.d.ts.map +1 -0
- package/dist/components/props.js +1 -0
- package/dist/components/props.ts +30 -0
- package/dist/components/svg-icon.test.ts +11 -0
- package/dist/components/svg-icon.ts +11 -0
- package/dist/components/tasty-states.d.ts +2 -0
- package/dist/components/tasty-states.js +42 -0
- package/dist/components-public.d.ts +21 -0
- package/dist/components.d.ts +10 -0
- package/dist/components.js +9 -0
- package/dist/content.d.ts +11 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +16 -0
- package/dist/content.js.map +1 -0
- package/dist/eslint-plugin.d.ts +32 -0
- package/dist/eslint-plugin.d.ts.map +1 -0
- package/dist/eslint-plugin.js +155 -0
- package/dist/eslint-plugin.js.map +1 -0
- package/dist/icons/arrow-left.svg +1 -0
- package/dist/icons/arrow-right.svg +1 -0
- package/dist/icons/check.svg +1 -0
- package/dist/icons/chevron-down.svg +1 -0
- package/dist/icons/chevron-right.svg +1 -0
- package/dist/icons/close.svg +1 -0
- package/dist/icons/copy.svg +1 -0
- package/dist/icons/device-desktop.svg +1 -0
- package/dist/icons/favicon.svg +11 -0
- package/dist/icons/menu.svg +1 -0
- package/dist/icons/moon.svg +1 -0
- package/dist/icons/palette.svg +1 -0
- package/dist/icons/search.svg +1 -0
- package/dist/icons/sun.svg +1 -0
- package/dist/index-BuX_Sb5c.d.ts +10 -0
- package/dist/index-BuX_Sb5c.d.ts.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1648 -0
- package/dist/index.js.map +1 -0
- package/dist/localization.d.ts +69 -0
- package/dist/localization.d.ts.map +1 -0
- package/dist/localization.js +195 -0
- package/dist/localization.js.map +1 -0
- package/dist/markdown/rendered-content.d.ts +6 -0
- package/dist/markdown/rendered-content.d.ts.map +1 -0
- package/dist/markdown/rendered-content.js +34 -0
- package/dist/markdown/rendered-content.js.map +1 -0
- package/dist/messages-B_3xUzUb.js +14 -0
- package/dist/messages-B_3xUzUb.js.map +1 -0
- package/dist/navigation.d.ts +31 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +165 -0
- package/dist/navigation.js.map +1 -0
- package/dist/overrides/DraftContentNotice.astro +8 -0
- package/dist/overrides/EmptyFooter.astro +3 -0
- package/dist/overrides/Footer.astro +23 -0
- package/dist/overrides/Head.astro +59 -0
- package/dist/overrides/Header.astro +139 -0
- package/dist/overrides/Hero.astro +73 -0
- package/dist/overrides/LanguageSelect.astro +63 -0
- package/dist/overrides/MarkdownContent.astro +14 -0
- package/dist/overrides/MobileMenuFooter.astro +15 -0
- package/dist/overrides/MobileMenuToggle.astro +36 -0
- package/dist/overrides/MobileTableOfContents.astro +37 -0
- package/dist/overrides/PageFrame.astro +35 -0
- package/dist/overrides/Search.astro +64 -0
- package/dist/overrides/Sidebar.astro +89 -0
- package/dist/overrides/SocialIcons.astro +27 -0
- package/dist/overrides/ThemeSelect.astro +148 -0
- package/dist/page-metadata.d.ts +13 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +109 -0
- package/dist/page-metadata.js.map +1 -0
- package/dist/route-context.d.ts +85 -0
- package/dist/route-context.d.ts.map +1 -0
- package/dist/route-context.js +116 -0
- package/dist/route-context.js.map +1 -0
- package/dist/routes/DocsPage.astro +91 -0
- package/dist/routes/NotFound.astro +12 -0
- package/dist/routes/Page.astro +120 -0
- package/dist/styling.d.ts +17 -0
- package/dist/styling.d.ts.map +1 -0
- package/dist/styling.js +17 -0
- package/dist/styling.js.map +1 -0
- package/dist/tasty-states-BDKIbfw2.js +65 -0
- package/dist/tasty-states-BDKIbfw2.js.map +1 -0
- package/dist/theme/defaults.d.ts +21 -0
- package/dist/theme/defaults.d.ts.map +1 -0
- package/dist/theme/defaults.js +93 -0
- package/dist/theme/defaults.js.map +1 -0
- package/dist/theme/fonts.ts +64 -0
- package/dist/theme/shiki-theme.d.ts +13 -0
- package/dist/theme/shiki-theme.d.ts.map +1 -0
- package/dist/theme/shiki-theme.js +328 -0
- package/dist/theme/shiki-theme.js.map +1 -0
- package/dist/theme/tasty-config.d.ts +13 -0
- package/dist/theme/tasty-config.d.ts.map +1 -0
- package/dist/theme/tasty-config.js +16 -0
- package/dist/theme/tasty-config.js.map +1 -0
- package/dist/ui.d.ts +6 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +53 -0
- package/dist/ui.js.map +1 -0
- package/dist/versioning.d.ts +11 -0
- package/dist/versioning.d.ts.map +1 -0
- package/dist/versioning.js +38 -0
- package/dist/versioning.js.map +1 -0
- package/package.json +92 -0
- package/tasty.config.mjs +1 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
import DraftContentNotice from "virtual:cookbook/components/DraftContentNotice";
|
|
3
|
+
|
|
4
|
+
const { data } = Astro.locals.cookbookRoute.entry;
|
|
5
|
+
const { title = data.title, tagline, image, actions = [] } = data.hero ?? {};
|
|
6
|
+
const imageAttributes = {
|
|
7
|
+
loading: "eager" as const,
|
|
8
|
+
decoding: "async" as const,
|
|
9
|
+
fetchpriority: "high" as const,
|
|
10
|
+
alt: image?.alt ?? "",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let darkImage: { src: string; width: number; height: number } | undefined;
|
|
14
|
+
let lightImage: { src: string; width: number; height: number } | undefined;
|
|
15
|
+
let rawHtml: string | undefined;
|
|
16
|
+
if (image) {
|
|
17
|
+
if ("file" in image) {
|
|
18
|
+
darkImage = image.file;
|
|
19
|
+
} else if ("dark" in image) {
|
|
20
|
+
darkImage = image.dark;
|
|
21
|
+
lightImage = image.light;
|
|
22
|
+
} else {
|
|
23
|
+
rawHtml = image.html;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<div class="hero">
|
|
29
|
+
{
|
|
30
|
+
darkImage && (
|
|
31
|
+
<img
|
|
32
|
+
src={darkImage.src}
|
|
33
|
+
width={darkImage.width}
|
|
34
|
+
height={darkImage.height}
|
|
35
|
+
{...imageAttributes}
|
|
36
|
+
data-hero-image={lightImage ? "dark" : undefined}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
{
|
|
41
|
+
lightImage && (
|
|
42
|
+
<img
|
|
43
|
+
src={lightImage.src}
|
|
44
|
+
width={lightImage.width}
|
|
45
|
+
height={lightImage.height}
|
|
46
|
+
{...imageAttributes}
|
|
47
|
+
data-hero-image="light"
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
{rawHtml && <div class="hero-html" set:html={rawHtml} />}
|
|
52
|
+
<div class="stack">
|
|
53
|
+
<div class="copy">
|
|
54
|
+
<h1 id="_top" data-page-title set:html={title} />
|
|
55
|
+
{data.draft && <DraftContentNotice />}
|
|
56
|
+
{tagline && <div class="tagline" set:html={tagline} />}
|
|
57
|
+
</div>
|
|
58
|
+
{
|
|
59
|
+
actions.length > 0 && (
|
|
60
|
+
<div class="actions">
|
|
61
|
+
{actions.map(({ link: href, text, variant }) => (
|
|
62
|
+
<a
|
|
63
|
+
{href}
|
|
64
|
+
class:list={["cookbook-link-button", variant ?? "secondary"]}
|
|
65
|
+
>
|
|
66
|
+
{text}
|
|
67
|
+
</a>
|
|
68
|
+
))}
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { content } from "virtual:cookbook/config";
|
|
3
|
+
import { localeTarget, routeLocale, messages } from "../localization.js";
|
|
4
|
+
import { navigationPath } from "../navigation.js";
|
|
5
|
+
import Icon from "../components/Icon.astro";
|
|
6
|
+
const current = navigationPath(Astro.url.pathname, content.base);
|
|
7
|
+
const selected = routeLocale(current, content);
|
|
8
|
+
const ui = messages(Astro.locals.cookbookRoute.lang, content);
|
|
9
|
+
const options = Object.entries(content.locales ?? {}).flatMap(
|
|
10
|
+
([locale, config]) => {
|
|
11
|
+
const target = localeTarget(current, locale, content.routes, content);
|
|
12
|
+
const fallback = target && routeLocale(target, content) !== locale;
|
|
13
|
+
return target
|
|
14
|
+
? [
|
|
15
|
+
{
|
|
16
|
+
locale,
|
|
17
|
+
label: `${config.label}${fallback ? ` (${ui.fallback})` : ""}`,
|
|
18
|
+
href: `${content.base.replace(/\/$/, "")}${target === "/" ? "/" : `${target}/`}`,
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
: [];
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
{
|
|
27
|
+
options.length > 1 && (
|
|
28
|
+
<cookbook-language-select>
|
|
29
|
+
<label>
|
|
30
|
+
<Icon name="translate" class="label-icon" />
|
|
31
|
+
<span class="sr-only">
|
|
32
|
+
{Astro.locals.t("languageSelect.accessibleLabel")}
|
|
33
|
+
</span>
|
|
34
|
+
<select>
|
|
35
|
+
{options.map((option) => (
|
|
36
|
+
<option value={option.href} selected={option.locale === selected}>
|
|
37
|
+
{option.label}
|
|
38
|
+
</option>
|
|
39
|
+
))}
|
|
40
|
+
</select>
|
|
41
|
+
<Icon name="down-caret" class="caret" />
|
|
42
|
+
</label>
|
|
43
|
+
</cookbook-language-select>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
class CookbookLanguageSelect extends HTMLElement {
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
const select = this.querySelector("select");
|
|
51
|
+
select?.addEventListener("change", () => {
|
|
52
|
+
window.location.href = select.value;
|
|
53
|
+
});
|
|
54
|
+
window.addEventListener("pageshow", () => {
|
|
55
|
+
if (select)
|
|
56
|
+
select.selectedIndex =
|
|
57
|
+
select.querySelector("option[selected]")?.index ?? 0;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!customElements.get("cookbook-language-select"))
|
|
62
|
+
customElements.define("cookbook-language-select", CookbookLanguageSelect);
|
|
63
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { addHeadingPermalinks } from "../markdown/rendered-content.js";
|
|
3
|
+
|
|
4
|
+
const content = addHeadingPermalinks(await Astro.slots.render("default"));
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<div class="cookbook-markdown-content" set:html={content} />
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import { initializeHeadingLinks } from "../client/heading-links.js";
|
|
11
|
+
|
|
12
|
+
initializeHeadingLinks();
|
|
13
|
+
document.addEventListener("astro:page-load", initializeHeadingLinks);
|
|
14
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import LanguageSelect from "virtual:cookbook/components/LanguageSelect";
|
|
3
|
+
import SocialIcons from "virtual:cookbook/components/SocialIcons";
|
|
4
|
+
import { MobileMenuFooterRoot } from "../components/LayoutComponents.js";
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<MobileMenuFooterRoot
|
|
8
|
+
className="td-mobile-preferences"
|
|
9
|
+
data-tasty-anatomy="MobileMenuFooter"
|
|
10
|
+
>
|
|
11
|
+
<div class="td-mobile-preferences__social">
|
|
12
|
+
<SocialIcons />
|
|
13
|
+
</div>
|
|
14
|
+
<LanguageSelect />
|
|
15
|
+
</MobileMenuFooterRoot>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { localizedNavigation, localePath } from "../localization.js";
|
|
3
|
+
import { content } from "virtual:cookbook/config";
|
|
4
|
+
import Icon from "../components/Icon.astro";
|
|
5
|
+
import { layout as configuredLayout } from "virtual:cookbook/layout";
|
|
6
|
+
import { activeNavigationTab, navigationPath } from "../navigation.js";
|
|
7
|
+
const route = Astro.locals.cookbookRoute;
|
|
8
|
+
const { layout } = localizedNavigation(
|
|
9
|
+
configuredLayout,
|
|
10
|
+
content.routes,
|
|
11
|
+
navigationPath(Astro.url.pathname, import.meta.env.BASE_URL),
|
|
12
|
+
content,
|
|
13
|
+
);
|
|
14
|
+
const active = activeNavigationTab(
|
|
15
|
+
layout.tabs,
|
|
16
|
+
localePath(
|
|
17
|
+
navigationPath(Astro.url.pathname, import.meta.env.BASE_URL),
|
|
18
|
+
content,
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
const section = layout.tabs[active]?.label;
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
<button
|
|
25
|
+
type="button"
|
|
26
|
+
popovertarget="cookbook__sidebar"
|
|
27
|
+
aria-controls="cookbook__sidebar"
|
|
28
|
+
aria-expanded="false"
|
|
29
|
+
class="td-menu-button cookbook-menu-button cookbook-print-hidden"
|
|
30
|
+
>
|
|
31
|
+
<Icon name="bars" class="open-menu" />
|
|
32
|
+
<span class="sr-only">{Astro.locals.t("menuButton.accessibleLabel")}</span>
|
|
33
|
+
{section && <span class="td-menu-button__section">{section}</span>}
|
|
34
|
+
{section && <Icon name="right-caret" />}
|
|
35
|
+
<span class="td-menu-button__page">{route.entry.data.title}</span>
|
|
36
|
+
</button>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { content } from "virtual:cookbook/config";
|
|
3
|
+
import { navigationPath } from "../navigation.js";
|
|
4
|
+
import { MobileTableOfContentsRoot } from "../components/LayoutComponents.js";
|
|
5
|
+
import MobileTocList from "../components/MobileTocList.astro";
|
|
6
|
+
const { toc } = Astro.locals.cookbookRoute;
|
|
7
|
+
const entry = content.entries.find(
|
|
8
|
+
(entry) => entry.route === navigationPath(Astro.url.pathname, content.base),
|
|
9
|
+
);
|
|
10
|
+
const page = entry?.frontmatter.tableOfContents;
|
|
11
|
+
const site = content.tableOfContents;
|
|
12
|
+
const enabled =
|
|
13
|
+
page !== false && (page?.mobile ?? (site && site.mobile) ?? false);
|
|
14
|
+
const label = Astro.locals.t("tableOfContents.onThisPage");
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
enabled &&
|
|
19
|
+
toc &&
|
|
20
|
+
toc.items.some(
|
|
21
|
+
(item) => item.slug !== "_top" || item.children.length > 0,
|
|
22
|
+
) && (
|
|
23
|
+
<MobileTableOfContentsRoot data-tasty-anatomy="MobileTableOfContents">
|
|
24
|
+
<details>
|
|
25
|
+
<>
|
|
26
|
+
<summary>{label}</summary>
|
|
27
|
+
<nav aria-label={label}>
|
|
28
|
+
<MobileTocList items={toc.items} />
|
|
29
|
+
</nav>
|
|
30
|
+
</>
|
|
31
|
+
</details>
|
|
32
|
+
</MobileTableOfContentsRoot>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
<script>
|
|
36
|
+
import "../client/mobile-toc.js";
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { PageFrameRoot } from "../components/LayoutComponents.js";
|
|
3
|
+
const { hasSidebar } = Astro.locals.cookbookRoute;
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<PageFrameRoot
|
|
7
|
+
className="page"
|
|
8
|
+
data-tasty-anatomy="PageFrame"
|
|
9
|
+
data-has-sidebar={hasSidebar ? "" : undefined}
|
|
10
|
+
>
|
|
11
|
+
<header class="header"><slot name="header" /></header>
|
|
12
|
+
{
|
|
13
|
+
hasSidebar && (
|
|
14
|
+
<cookbook-sidebar-pane
|
|
15
|
+
id="cookbook__sidebar"
|
|
16
|
+
class="sidebar-pane cookbook-print-hidden"
|
|
17
|
+
popover="auto"
|
|
18
|
+
aria-label={Astro.locals.t("sidebarNav.accessibleLabel")}
|
|
19
|
+
tabindex="-1"
|
|
20
|
+
>
|
|
21
|
+
<nav
|
|
22
|
+
class="sidebar-content"
|
|
23
|
+
aria-label={Astro.locals.t("sidebarNav.accessibleLabel")}
|
|
24
|
+
>
|
|
25
|
+
<slot name="sidebar" />
|
|
26
|
+
</nav>
|
|
27
|
+
</cookbook-sidebar-pane>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
<div class="main-frame"><slot /></div>
|
|
31
|
+
</PageFrameRoot>
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
import "../client/navigation.js";
|
|
35
|
+
</script>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { messages } from "../localization.js";
|
|
3
|
+
import { content } from "virtual:cookbook/config";
|
|
4
|
+
const label = Astro.locals.t("search.label");
|
|
5
|
+
const translations = {
|
|
6
|
+
placeholder: label,
|
|
7
|
+
error: messages(Astro.locals.cookbookRoute?.lang ?? "en", content)
|
|
8
|
+
.searchError,
|
|
9
|
+
search: Astro.locals.t("pagefind.search"),
|
|
10
|
+
zero_results: Astro.locals.t("pagefind.zero_results"),
|
|
11
|
+
many_results: Astro.locals.t("pagefind.many_results"),
|
|
12
|
+
one_result: Astro.locals.t("pagefind.one_result"),
|
|
13
|
+
};
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<site-search
|
|
17
|
+
class={Astro.props.class}
|
|
18
|
+
data-translations={JSON.stringify(translations)}
|
|
19
|
+
data-strip-trailing-slash={import.meta.env.TRAILING_SLASH === "never" ||
|
|
20
|
+
undefined}
|
|
21
|
+
>
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
data-open-modal
|
|
25
|
+
disabled
|
|
26
|
+
aria-label={label}
|
|
27
|
+
aria-keyshortcuts="Control+K"
|
|
28
|
+
>
|
|
29
|
+
<span aria-hidden="true">{label}</span>
|
|
30
|
+
<kbd data-pending aria-hidden="true"
|
|
31
|
+
><kbd>{Astro.locals.t("search.ctrlKey")}</kbd><kbd>K</kbd></kbd
|
|
32
|
+
>
|
|
33
|
+
</button>
|
|
34
|
+
<dialog aria-label={label}>
|
|
35
|
+
<div class="dialog-frame">
|
|
36
|
+
<button type="button" data-close-modal
|
|
37
|
+
>{Astro.locals.t("search.cancelLabel")}</button
|
|
38
|
+
>
|
|
39
|
+
{
|
|
40
|
+
import.meta.env.DEV ? (
|
|
41
|
+
<p data-search-status dir="ltr">
|
|
42
|
+
{Astro.locals.t("search.devWarning")}
|
|
43
|
+
</p>
|
|
44
|
+
) : (
|
|
45
|
+
<div class="search-container">
|
|
46
|
+
<p data-search-status role="status" hidden />
|
|
47
|
+
<div id="cookbook__search" />
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
</div>
|
|
52
|
+
</dialog>
|
|
53
|
+
</site-search>
|
|
54
|
+
<script>
|
|
55
|
+
import { initializeSearch } from "../client/search.js";
|
|
56
|
+
document.querySelectorAll<HTMLElement>("site-search").forEach((element) => {
|
|
57
|
+
initializeSearch(
|
|
58
|
+
element,
|
|
59
|
+
{},
|
|
60
|
+
import.meta.env.DEV,
|
|
61
|
+
import.meta.env.BASE_URL,
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
</script>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
localizedNavigation,
|
|
4
|
+
localePath,
|
|
5
|
+
localeHref,
|
|
6
|
+
} from "../localization.js";
|
|
7
|
+
import { messages } from "../localization.js";
|
|
8
|
+
import { content } from "virtual:cookbook/config";
|
|
9
|
+
import Icon from "../components/Icon.astro";
|
|
10
|
+
import Logo from "../components/SiteLogo.astro";
|
|
11
|
+
import MobileMenuFooter from "virtual:cookbook/components/MobileMenuFooter";
|
|
12
|
+
import { layout as configuredLayout } from "virtual:cookbook/layout";
|
|
13
|
+
import SidebarList from "../components/SidebarList.astro";
|
|
14
|
+
import MobileNavigationTabs from "../components/MobileNavigationTabs.astro";
|
|
15
|
+
import { activeNavigationTab, navigationPath } from "../navigation.js";
|
|
16
|
+
|
|
17
|
+
const fullSidebar = Astro.locals.cookbookRoute.sidebar;
|
|
18
|
+
const currentPath = navigationPath(
|
|
19
|
+
Astro.url.pathname,
|
|
20
|
+
import.meta.env.BASE_URL,
|
|
21
|
+
);
|
|
22
|
+
const { layout } = localizedNavigation(
|
|
23
|
+
configuredLayout,
|
|
24
|
+
content.routes,
|
|
25
|
+
currentPath,
|
|
26
|
+
content,
|
|
27
|
+
);
|
|
28
|
+
const activeTab = activeNavigationTab(
|
|
29
|
+
layout.tabs,
|
|
30
|
+
localePath(currentPath, content),
|
|
31
|
+
);
|
|
32
|
+
const groupIndex =
|
|
33
|
+
(activeTab >= 0 ? layout.tabs[activeTab]?.sidebarGroup : undefined) ??
|
|
34
|
+
layout.fallbackSidebarGroup;
|
|
35
|
+
const selectedGroup = layout.sectioned
|
|
36
|
+
? groupIndex === undefined
|
|
37
|
+
? undefined
|
|
38
|
+
: fullSidebar[groupIndex]
|
|
39
|
+
: undefined;
|
|
40
|
+
const sidebar =
|
|
41
|
+
selectedGroup?.type === "group"
|
|
42
|
+
? selectedGroup.entries
|
|
43
|
+
: layout.sectioned
|
|
44
|
+
? []
|
|
45
|
+
: fullSidebar;
|
|
46
|
+
const ui = messages(Astro.locals.cookbookRoute?.lang ?? "en", content);
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<div class="td-sidebar-heading">
|
|
50
|
+
<a
|
|
51
|
+
class="td-sidebar-heading__home"
|
|
52
|
+
href={localeHref(
|
|
53
|
+
(content.logo && content.logo.href) || "/",
|
|
54
|
+
currentPath,
|
|
55
|
+
content.routes,
|
|
56
|
+
content,
|
|
57
|
+
content.base,
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
60
|
+
<Logo />
|
|
61
|
+
<span data-site-title>{Astro.locals.cookbookRoute.siteTitle}</span>
|
|
62
|
+
</a>
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
popovertarget="cookbook__sidebar"
|
|
66
|
+
popovertargetaction="hide"
|
|
67
|
+
aria-label={ui.closeNavigation}
|
|
68
|
+
autofocus><Icon name="close" /></button
|
|
69
|
+
>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<MobileNavigationTabs
|
|
73
|
+
base={import.meta.env.BASE_URL}
|
|
74
|
+
currentPath={Astro.url.pathname}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<cookbook-sidebar
|
|
78
|
+
data-storage-key={`cookbook-sidebar:${import.meta.env.BASE_URL}:${groupIndex ?? "all"}`}
|
|
79
|
+
>
|
|
80
|
+
<SidebarList entries={sidebar} />
|
|
81
|
+
</cookbook-sidebar>
|
|
82
|
+
|
|
83
|
+
<div class="md:cookbook-hidden">
|
|
84
|
+
<MobileMenuFooter />
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<script>
|
|
88
|
+
import "../client/sidebar.js";
|
|
89
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { content } from "virtual:cookbook/config";
|
|
3
|
+
import Icon from "../components/Icon.astro";
|
|
4
|
+
import { SocialIconsRoot } from "../components/LayoutComponents.js";
|
|
5
|
+
|
|
6
|
+
const repository = content.site.repository;
|
|
7
|
+
const icon = repository?.includes("github.com")
|
|
8
|
+
? "github"
|
|
9
|
+
: repository?.includes("gitlab.com")
|
|
10
|
+
? "gitlab"
|
|
11
|
+
: "link";
|
|
12
|
+
const links = repository
|
|
13
|
+
? [{ href: repository, label: "Source repository", icon }]
|
|
14
|
+
: [];
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
links.length > 0 && (
|
|
19
|
+
<SocialIconsRoot data-tasty-anatomy="SocialIcons">
|
|
20
|
+
{links.map(({ label, href, icon }) => (
|
|
21
|
+
<a href={href} rel="me" aria-label={label} title={label}>
|
|
22
|
+
<Icon name={icon} />
|
|
23
|
+
</a>
|
|
24
|
+
))}
|
|
25
|
+
</SocialIconsRoot>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { messages } from "../localization.js";
|
|
3
|
+
import { content } from "virtual:cookbook/config";
|
|
4
|
+
import Icon from "../components/Icon.astro";
|
|
5
|
+
import paletteIcon from "../icons/palette.svg?raw";
|
|
6
|
+
import ContrastIcon from "../components/ContrastIcon.astro";
|
|
7
|
+
import { ThemeSelectRoot } from "../components/LayoutComponents.js";
|
|
8
|
+
|
|
9
|
+
const ui = messages(Astro.locals.cookbookRoute?.lang ?? "en", content);
|
|
10
|
+
const id = `appearance-${crypto.randomUUID()}`;
|
|
11
|
+
const schemes = [
|
|
12
|
+
{ value: "light", label: Astro.locals.t("themeSelect.light"), icon: "sun" },
|
|
13
|
+
{ value: "dark", label: Astro.locals.t("themeSelect.dark"), icon: "moon" },
|
|
14
|
+
{ value: "auto", label: Astro.locals.t("themeSelect.auto"), icon: "laptop" },
|
|
15
|
+
] as const;
|
|
16
|
+
const contrasts = [
|
|
17
|
+
{ value: "normal", label: ui.normalContrast, icon: "normal" },
|
|
18
|
+
{ value: "more", label: ui.highContrast, icon: "more" },
|
|
19
|
+
{ value: "system", label: ui.auto, icon: "auto" },
|
|
20
|
+
] as const;
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<ThemeSelectRoot data-tasty-anatomy="ThemeSelect">
|
|
24
|
+
<button
|
|
25
|
+
type="button"
|
|
26
|
+
popovertarget={id}
|
|
27
|
+
aria-label={ui.appearance}
|
|
28
|
+
title={ui.appearance}
|
|
29
|
+
>
|
|
30
|
+
<span aria-hidden="true" set:html={paletteIcon} />
|
|
31
|
+
</button>
|
|
32
|
+
<div id={id} popover="auto" role="group" aria-label={ui.appearance}>
|
|
33
|
+
<fieldset>
|
|
34
|
+
<legend>{ui.colorScheme}</legend>
|
|
35
|
+
{
|
|
36
|
+
schemes.map(({ value, label, icon }) => (
|
|
37
|
+
<label>
|
|
38
|
+
<input
|
|
39
|
+
type="radio"
|
|
40
|
+
name={`${id}-scheme`}
|
|
41
|
+
value={value}
|
|
42
|
+
data-appearance-scheme
|
|
43
|
+
checked={value === "auto"}
|
|
44
|
+
/>
|
|
45
|
+
<Icon name={icon} />
|
|
46
|
+
<span>{label}</span>
|
|
47
|
+
<Icon name="approve-check" class="checkmark" />
|
|
48
|
+
</label>
|
|
49
|
+
))
|
|
50
|
+
}
|
|
51
|
+
</fieldset>
|
|
52
|
+
<fieldset>
|
|
53
|
+
<legend>{ui.contrast}</legend>
|
|
54
|
+
{
|
|
55
|
+
contrasts.map(({ value, label, icon }) => (
|
|
56
|
+
<label>
|
|
57
|
+
<input
|
|
58
|
+
type="radio"
|
|
59
|
+
name={`${id}-contrast`}
|
|
60
|
+
value={value}
|
|
61
|
+
data-appearance-contrast
|
|
62
|
+
checked={value === "system"}
|
|
63
|
+
/>
|
|
64
|
+
{icon === "auto" ? (
|
|
65
|
+
<Icon name="laptop" />
|
|
66
|
+
) : (
|
|
67
|
+
<ContrastIcon level={icon} />
|
|
68
|
+
)}
|
|
69
|
+
<span>{label}</span>
|
|
70
|
+
<Icon name="approve-check" class="checkmark" />
|
|
71
|
+
</label>
|
|
72
|
+
))
|
|
73
|
+
}
|
|
74
|
+
</fieldset>
|
|
75
|
+
</div>
|
|
76
|
+
</ThemeSelectRoot>
|
|
77
|
+
|
|
78
|
+
<script>
|
|
79
|
+
import {
|
|
80
|
+
loadPreferences,
|
|
81
|
+
storePreferences,
|
|
82
|
+
parseScheme,
|
|
83
|
+
parseContrast,
|
|
84
|
+
} from "../components/appearance-preferences.js";
|
|
85
|
+
|
|
86
|
+
let current = loadPreferences();
|
|
87
|
+
const systemScheme = matchMedia("(prefers-color-scheme: light)");
|
|
88
|
+
|
|
89
|
+
function applyPreferences(): void {
|
|
90
|
+
document.documentElement.dataset.theme =
|
|
91
|
+
current.scheme === "auto"
|
|
92
|
+
? systemScheme.matches
|
|
93
|
+
? "light"
|
|
94
|
+
: "dark"
|
|
95
|
+
: current.scheme;
|
|
96
|
+
if (current.contrast === "system") {
|
|
97
|
+
delete document.documentElement.dataset.contrast;
|
|
98
|
+
} else {
|
|
99
|
+
document.documentElement.dataset.contrast = current.contrast;
|
|
100
|
+
}
|
|
101
|
+
document
|
|
102
|
+
.querySelectorAll<HTMLInputElement>("[data-appearance-scheme]")
|
|
103
|
+
.forEach((input) => {
|
|
104
|
+
input.checked = input.value === current.scheme;
|
|
105
|
+
});
|
|
106
|
+
document
|
|
107
|
+
.querySelectorAll<HTMLInputElement>("[data-appearance-contrast]")
|
|
108
|
+
.forEach((input) => {
|
|
109
|
+
input.checked = input.value === current.contrast;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
systemScheme.addEventListener("change", () => {
|
|
114
|
+
if (current.scheme === "auto") applyPreferences();
|
|
115
|
+
});
|
|
116
|
+
window.addEventListener("storage", (event) => {
|
|
117
|
+
if (
|
|
118
|
+
!event.key ||
|
|
119
|
+
["cookbook-theme", "cookbook-appearance"].includes(event.key)
|
|
120
|
+
) {
|
|
121
|
+
current = loadPreferences();
|
|
122
|
+
applyPreferences();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
class CookbookAppearanceMenu extends HTMLElement {
|
|
127
|
+
connectedCallback(): void {
|
|
128
|
+
if (this.dataset.ready) return;
|
|
129
|
+
this.dataset.ready = "true";
|
|
130
|
+
this.addEventListener("change", (event) => {
|
|
131
|
+
const input = event.target;
|
|
132
|
+
if (!(input instanceof HTMLInputElement)) return;
|
|
133
|
+
if (input.hasAttribute("data-appearance-scheme")) {
|
|
134
|
+
current.scheme = parseScheme(input.value);
|
|
135
|
+
} else if (input.hasAttribute("data-appearance-contrast")) {
|
|
136
|
+
current.contrast = parseContrast(input.value);
|
|
137
|
+
} else return;
|
|
138
|
+
storePreferences(current);
|
|
139
|
+
applyPreferences();
|
|
140
|
+
});
|
|
141
|
+
applyPreferences();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!customElements.get("cookbook-appearance-menu")) {
|
|
146
|
+
customElements.define("cookbook-appearance-menu", CookbookAppearanceMenu);
|
|
147
|
+
}
|
|
148
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DocsConfig, DocsEntry, DocsRoute, HeadConfig, SiteConfig } from "@tenphi/docs";
|
|
2
|
+
//#region src/page-metadata.d.ts
|
|
3
|
+
declare function pageMetadata(entry: DocsEntry, content: {
|
|
4
|
+
site: SiteConfig;
|
|
5
|
+
base: string;
|
|
6
|
+
routes: DocsRoute[];
|
|
7
|
+
locales?: DocsConfig["locales"];
|
|
8
|
+
}, existing: HeadConfig[]): HeadConfig[];
|
|
9
|
+
/** Stable short asset names also support deeply nested and non-ASCII routes. */
|
|
10
|
+
declare function agentPagePath(route: string, base?: string): string;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { agentPagePath, pageMetadata };
|
|
13
|
+
//# sourceMappingURL=page-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-metadata.d.ts","names":[],"sources":["../src/page-metadata.ts"],"mappings":";;iBAYgB,aACd,OAAO,WACP;EACE,MAAM;EACN;EACA,QAAQ;EACR,UAAU;GAEZ,UAAU,eACT;;iBA4Ha,cAAc,eAAe"}
|