@minidocs/astro 0.0.0-stage → 0.2.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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -2
  3. package/dist/behaviors.d.mts +114 -0
  4. package/dist/behaviors.mjs +635 -0
  5. package/dist/index.d.mts +23 -0
  6. package/dist/index.mjs +275 -0
  7. package/dist/links-Dp7d5R-O.mjs +242 -0
  8. package/dist/loaders.d.mts +25 -0
  9. package/dist/loaders.mjs +88 -0
  10. package/dist/routing-D28b92w8.mjs +60 -0
  11. package/dist/runtime.d.mts +202 -0
  12. package/dist/runtime.mjs +327 -0
  13. package/package.json +80 -3
  14. package/src/components/Prose.astro +9 -0
  15. package/src/components/callout/Root.astro +14 -0
  16. package/src/components/callout/Title.astro +9 -0
  17. package/src/components/callout/index.ts +2 -0
  18. package/src/components/index.ts +7 -0
  19. package/src/components/layout/Aside.astro +29 -0
  20. package/src/components/layout/Header.astro +18 -0
  21. package/src/components/layout/Main.astro +9 -0
  22. package/src/components/layout/Root.astro +15 -0
  23. package/src/components/layout/Sidebar.astro +9 -0
  24. package/src/components/layout/Title.astro +10 -0
  25. package/src/components/layout/index.ts +6 -0
  26. package/src/components/pager/Label.astro +9 -0
  27. package/src/components/pager/Link.astro +12 -0
  28. package/src/components/pager/Root.astro +12 -0
  29. package/src/components/pager/Title.astro +9 -0
  30. package/src/components/pager/index.ts +4 -0
  31. package/src/components/search/Count.astro +10 -0
  32. package/src/components/search/Dialog.astro +14 -0
  33. package/src/components/search/Empty.astro +10 -0
  34. package/src/components/search/Error.astro +10 -0
  35. package/src/components/search/Found.astro +10 -0
  36. package/src/components/search/Idle.astro +10 -0
  37. package/src/components/search/Input.astro +26 -0
  38. package/src/components/search/Loading.astro +10 -0
  39. package/src/components/search/Query.astro +10 -0
  40. package/src/components/search/Results.astro +20 -0
  41. package/src/components/search/Root.astro +15 -0
  42. package/src/components/search/Shortcut.astro +14 -0
  43. package/src/components/search/Trigger.astro +28 -0
  44. package/src/components/search/index.ts +13 -0
  45. package/src/components/sidebar/Group.astro +45 -0
  46. package/src/components/sidebar/Item.astro +9 -0
  47. package/src/components/sidebar/Label.astro +9 -0
  48. package/src/components/sidebar/Link.astro +23 -0
  49. package/src/components/sidebar/List.astro +11 -0
  50. package/src/components/sidebar/Root.astro +24 -0
  51. package/src/components/sidebar/Trigger.astro +29 -0
  52. package/src/components/sidebar/index.ts +7 -0
  53. package/src/components/toc/Item.astro +9 -0
  54. package/src/components/toc/Link.astro +12 -0
  55. package/src/components/toc/List.astro +11 -0
  56. package/src/components/toc/Root.astro +20 -0
  57. package/src/components/toc/index.ts +4 -0
  58. package/src/styles/base.css +42 -0
  59. package/src/styles/callout.css +58 -0
  60. package/src/styles/layout.css +406 -0
  61. package/src/styles/pager.css +56 -0
  62. package/src/styles/prose.css +218 -0
  63. package/src/styles/search.css +207 -0
  64. package/src/styles/sidebar.css +162 -0
  65. package/src/styles/toc.css +79 -0
  66. package/src/styles.css +9 -0
@@ -0,0 +1,14 @@
1
+ ---
2
+ import type { CalloutType } from '@minidocs/astro';
3
+ import type { HTMLAttributes } from 'astro/types';
4
+
5
+ interface Props extends HTMLAttributes<'div'> {
6
+ /** Decides the color in the default styles. */
7
+ type?: CalloutType;
8
+ }
9
+
10
+ // Same markup as the :::type and > [!TYPE] syntax renders, so both share the default styles
11
+ const { type = 'note', class: className, ...attrs } = Astro.props;
12
+ ---
13
+
14
+ <div class:list={['md-callout', className]} data-type={type} role="note" {...attrs}><slot /></div>
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'p'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <p class:list={['md-callout-title', className]} {...attrs}><slot /></p>
@@ -0,0 +1,2 @@
1
+ export { default as Root } from './Root.astro';
2
+ export { default as Title } from './Title.astro';
@@ -0,0 +1,7 @@
1
+ export * as Callout from './callout';
2
+ export * as Layout from './layout';
3
+ export { default as Prose } from './Prose.astro';
4
+ export * as Pager from './pager';
5
+ export * as Search from './search';
6
+ export * as Sidebar from './sidebar';
7
+ export * as Toc from './toc';
@@ -0,0 +1,29 @@
1
+ ---
2
+ import { restoreAside } from '@minidocs/astro/behaviors';
3
+ import type { HTMLAttributes } from 'astro/types';
4
+
5
+ interface Props extends HTMLAttributes<'details'> {
6
+ /** Heading of the column, and the toggle when the aside collapses above the content. */
7
+ title: string;
8
+ }
9
+
10
+ const { title, class: className, ...attrs } = Astro.props;
11
+ // The empty span is filled by attachAside with the heading being read, from md:toc-change events
12
+ // Runs before the first paint, so a collapsible aside starts closed without a flash of its contents
13
+ const restore = `(${restoreAside})(document.currentScript.parentElement)`;
14
+ ---
15
+
16
+ <details class:list={['md-layout-aside', className]} open {...attrs}>
17
+ <summary class="md-layout-aside-title">
18
+ <span class="md-layout-aside-label">{title}</span>
19
+ <span class="md-layout-aside-current" data-md-aside-current></span>
20
+ </summary>
21
+ <slot />
22
+ <script is:inline set:html={restore} />
23
+ </details>
24
+
25
+ <script>
26
+ import { attachAside } from '@minidocs/astro/behaviors';
27
+
28
+ for (const aside of document.querySelectorAll<HTMLDetailsElement>('.md-layout-aside')) attachAside(aside);
29
+ </script>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'header'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <header class:list={['md-layout-header', className]} {...attrs}>
10
+ <div class="md-layout-header-inner">
11
+ <slot />
12
+ {Astro.slots.has('end') && (
13
+ <div class="md-layout-header-end">
14
+ <slot name="end" />
15
+ </div>
16
+ )}
17
+ </div>
18
+ </header>
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'main'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <main class:list={['md-layout-main', className]} {...attrs}><slot /></main>
@@ -0,0 +1,15 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'div'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <div class:list={['md-layout', className]} data-md-layout {...attrs}><slot /></div>
10
+
11
+ <script>
12
+ import { attachLayout } from '@minidocs/astro/behaviors';
13
+
14
+ for (const root of document.querySelectorAll<HTMLElement>('[data-md-layout]')) attachLayout(root);
15
+ </script>
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'aside'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <aside class:list={['md-layout-sidebar', className]} {...attrs}><slot /></aside>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'a'>;
5
+
6
+ // Site name or logo in Layout.Header, linking home
7
+ const { href, class: className, ...attrs } = Astro.props;
8
+ ---
9
+
10
+ <a class:list={['md-layout-title', className]} href={href} {...attrs}><slot /></a>
@@ -0,0 +1,6 @@
1
+ export { default as Aside } from './Aside.astro';
2
+ export { default as Header } from './Header.astro';
3
+ export { default as Main } from './Main.astro';
4
+ export { default as Root } from './Root.astro';
5
+ export { default as Sidebar } from './Sidebar.astro';
6
+ export { default as Title } from './Title.astro';
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'span'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <span class:list={['md-pager-label', className]} {...attrs}><slot /></span>
@@ -0,0 +1,12 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'a'> {
5
+ /** Direction of the linked page, which also decides which side the link sits on. */
6
+ rel: 'prev' | 'next';
7
+ }
8
+
9
+ const { href, rel, class: className, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <a class:list={['md-pager-link', className]} href={href} rel={rel} {...attrs}><slot /></a>
@@ -0,0 +1,12 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'nav'> {
5
+ /** Accessible name of the navigation, e.g. "Pagination". */
6
+ label?: string;
7
+ }
8
+
9
+ const { label, class: className, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <nav class:list={['md-pager', className]} aria-label={label} {...attrs}><slot /></nav>
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'span'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <span class:list={['md-pager-title', className]} {...attrs}><slot /></span>
@@ -0,0 +1,4 @@
1
+ export { default as Label } from './Label.astro';
2
+ export { default as Link } from './Link.astro';
3
+ export { default as Root } from './Root.astro';
4
+ export { default as Title } from './Title.astro';
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'span'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ // How many results the latest query found
8
+ ---
9
+
10
+ <span class:list={['md-search-count', className]} data-md-search-count {...attrs}></span>
@@ -0,0 +1,14 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'dialog'> {
5
+ /** Accessible name of the dialog, e.g. "Search docs". */
6
+ label?: string;
7
+ }
8
+
9
+ const { label, class: className, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <dialog class:list={['md-search-dialog', className]} aria-label={label} data-md-search-dialog {...attrs}>
13
+ <slot />
14
+ </dialog>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'div'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ // Shown when the latest query found nothing
8
+ ---
9
+
10
+ <div class:list={['md-search-empty', className]} data-md-search-state="empty" hidden {...attrs}><slot /></div>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'div'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ // Shown when the source failed, e.g. in the dev server where Pagefind has no index
8
+ ---
9
+
10
+ <div class:list={['md-search-error', className]} data-md-search-state="error" hidden {...attrs}><slot /></div>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'div'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ // Shown when the latest query found results, e.g. to say how many with Search.Count
8
+ ---
9
+
10
+ <div class:list={['md-search-found', className]} data-md-search-state="found" hidden {...attrs}><slot /></div>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'div'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ // Shown while nothing is typed
8
+ ---
9
+
10
+ <div class:list={['md-search-idle', className]} data-md-search-state="idle" {...attrs}><slot /></div>
@@ -0,0 +1,26 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'input'> {
5
+ /** Accessible name of the input, e.g. "Search". */
6
+ label?: string;
7
+ }
8
+
9
+ const { label, class: className, ...attrs } = Astro.props;
10
+ // Not type="search": in Chrome, Escape would clear it first instead of closing the dialog
11
+ ---
12
+
13
+ <input
14
+ type="text"
15
+ class:list={['md-search-input', className]}
16
+ role="combobox"
17
+ aria-label={label}
18
+ aria-autocomplete="list"
19
+ aria-expanded="false"
20
+ autocomplete="off"
21
+ autocapitalize="off"
22
+ spellcheck="false"
23
+ enterkeyhint="search"
24
+ data-md-search-input
25
+ {...attrs}
26
+ >
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'div'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ // Shown while a query is on its way, over whatever the last one left
8
+ ---
9
+
10
+ <div class:list={['md-search-loading', className]} data-md-search-state="loading" hidden {...attrs}><slot /></div>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'span'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ // The query whose outcome is shown
8
+ ---
9
+
10
+ <span class:list={['md-search-query', className]} data-md-search-query {...attrs}></span>
@@ -0,0 +1,20 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'div'> {
5
+ /** Accessible name of the list, e.g. "Results". */
6
+ label?: string;
7
+ }
8
+
9
+ const { label, class: className, ...attrs } = Astro.props;
10
+ // Filled by the render function given to attachSearch
11
+ ---
12
+
13
+ <div
14
+ class:list={['md-search-results', className]}
15
+ role="listbox"
16
+ aria-label={label}
17
+ data-md-search-results
18
+ hidden
19
+ {...attrs}
20
+ ></div>
@@ -0,0 +1,15 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'search'> {
5
+ /** Lets Search.Trigger point to it, and the script that attaches the search find it. */
6
+ id: string;
7
+ }
8
+
9
+ const { class: className, ...attrs } = Astro.props;
10
+ // attachSearch takes the user's source and renderer, so it is not attached here
11
+ ---
12
+
13
+ <search class:list={['md-search', className]} data-md-search data-status="idle" {...attrs}>
14
+ <slot />
15
+ </search>
@@ -0,0 +1,14 @@
1
+ ---
2
+ import { restoreShortcut } from '@minidocs/astro/behaviors';
3
+ import type { HTMLAttributes } from 'astro/types';
4
+
5
+ type Props = HTMLAttributes<'kbd'>;
6
+
7
+ const { class: className, ...attrs } = Astro.props;
8
+ // Hidden from screen readers, since the trigger announces the shortcut through aria-keyshortcuts
9
+ // Filled while the page is parsed from the shortcut of the trigger around it, so nothing flashes
10
+ const restore = `(${restoreShortcut})(document.currentScript.previousElementSibling)`;
11
+ ---
12
+
13
+ <kbd class:list={['md-search-shortcut', className]} aria-hidden="true" {...attrs}></kbd>
14
+ <script is:inline set:html={restore} />
@@ -0,0 +1,28 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'button'> {
5
+ /** Id of the Search.Root to open, so the trigger can sit anywhere on the page. */
6
+ target: string;
7
+ /**
8
+ * Keys that press the trigger, written as in aria-keyshortcuts, e.g. "Mod+K" or "/".
9
+ * Mod is ⌘ on Apple platforms and Ctrl elsewhere, spaces separate alternatives, and false turns it off.
10
+ */
11
+ shortcut?: string | false;
12
+ }
13
+
14
+ const { target, shortcut = 'Mod+K', class: className, ...attrs } = Astro.props;
15
+ // attachSearch resolves Mod for the platform and writes aria-keyshortcuts
16
+ ---
17
+
18
+ <button
19
+ type="button"
20
+ class:list={['md-search-trigger', className]}
21
+ aria-controls={target}
22
+ aria-haspopup="dialog"
23
+ data-md-search-trigger
24
+ data-md-search-keys={shortcut || undefined}
25
+ {...attrs}
26
+ >
27
+ <slot />
28
+ </button>
@@ -0,0 +1,13 @@
1
+ export { default as Count } from './Count.astro';
2
+ export { default as Dialog } from './Dialog.astro';
3
+ export { default as Empty } from './Empty.astro';
4
+ export { default as Error } from './Error.astro';
5
+ export { default as Found } from './Found.astro';
6
+ export { default as Idle } from './Idle.astro';
7
+ export { default as Input } from './Input.astro';
8
+ export { default as Loading } from './Loading.astro';
9
+ export { default as Query } from './Query.astro';
10
+ export { default as Results } from './Results.astro';
11
+ export { default as Root } from './Root.astro';
12
+ export { default as Shortcut } from './Shortcut.astro';
13
+ export { default as Trigger } from './Trigger.astro';
@@ -0,0 +1,45 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'div'> {
5
+ /** Whether the group starts expanded. */
6
+ open?: boolean;
7
+ /** Groups sharing a name form an accordion: opening one closes the others. Only for groups without `href`. */
8
+ name?: string;
9
+ /** Page of the group itself. Its title becomes a link, or a toggle while on that page. */
10
+ href?: string | undefined;
11
+ /** Whether the group's own page is the current page. */
12
+ current?: boolean;
13
+ }
14
+
15
+ const { open = false, name, href, current = false, class: className, ...attrs } = Astro.props;
16
+ const classes = ['md-sidebar-group', className];
17
+ // On its own page the title would link to itself, so it toggles instead
18
+ const collapsible = href === undefined || current;
19
+ const expanded = open || current;
20
+ ---
21
+
22
+ {collapsible ? (
23
+ <details
24
+ class:list={classes}
25
+ name={href === undefined ? name : undefined}
26
+ open={expanded}
27
+ data-state={expanded ? 'open' : 'closed'}
28
+ data-md-sidebar-group
29
+ {...attrs}
30
+ >
31
+ <summary class="md-sidebar-group-title" aria-current={current ? 'page' : undefined}>
32
+ <slot name="label" />
33
+ </summary>
34
+ <slot />
35
+ </details>
36
+ ) : (
37
+ <div class:list={classes} data-state={expanded ? 'open' : 'closed'} data-md-sidebar-group {...attrs}>
38
+ <a class="md-sidebar-group-title" href={href}>
39
+ <slot name="label" />
40
+ </a>
41
+ <div class="md-sidebar-group-content" hidden={!expanded} data-md-sidebar-group-content>
42
+ <slot />
43
+ </div>
44
+ </div>
45
+ )}
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'li'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <li class:list={['md-sidebar-item', className]} {...attrs}><slot /></li>
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'span'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <span class:list={['md-sidebar-label', className]} {...attrs}><slot /></span>
@@ -0,0 +1,23 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'a'> {
5
+ /** Marks the link as the current page. */
6
+ current?: boolean;
7
+ /** Ignored. Accepted so that `nav.of(node)` can be spread onto any navigation part. */
8
+ open?: boolean;
9
+ }
10
+
11
+ const { href, current = false, open: _, class: className, ...attrs } = Astro.props;
12
+ // Absolute URLs, including protocol-relative ones, leave the site
13
+ const external = /^([a-z][a-z\d+.-]*:|\/\/)/i.test(String(href ?? ''));
14
+ ---
15
+
16
+ <a
17
+ class:list={['md-sidebar-link', className]}
18
+ href={href}
19
+ aria-current={current ? 'page' : undefined}
20
+ data-external={external ? '' : undefined}
21
+ {...attrs}
22
+ ><slot /></a
23
+ >
@@ -0,0 +1,11 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'ul'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <ul class:list={['md-sidebar-list', className]} {...attrs}>
10
+ <slot />
11
+ </ul>
@@ -0,0 +1,24 @@
1
+ ---
2
+ import { restoreSidebar } from '@minidocs/astro/behaviors';
3
+ import type { HTMLAttributes } from 'astro/types';
4
+
5
+ interface Props extends HTMLAttributes<'nav'> {
6
+ /** Accessible name of the navigation, e.g. "Docs". */
7
+ label?: string;
8
+ }
9
+
10
+ const { label, class: className, ...attrs } = Astro.props;
11
+ // Runs while the page is parsed, before the first paint, so navigating does not visibly change the sidebar
12
+ const restore = `(${restoreSidebar})(document.currentScript.closest('[data-md-sidebar]'))`;
13
+ ---
14
+
15
+ <nav class:list={['md-sidebar', className]} aria-label={label} data-md-sidebar data-state="closed" {...attrs}>
16
+ <slot />
17
+ <script is:inline set:html={restore} />
18
+ </nav>
19
+
20
+ <script>
21
+ import { attachSidebar } from '@minidocs/astro/behaviors';
22
+
23
+ for (const root of document.querySelectorAll<HTMLElement>('[data-md-sidebar]')) attachSidebar(root);
24
+ </script>
@@ -0,0 +1,29 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'button'> {
5
+ /** Id of the sidebar to open and close. */
6
+ target: string;
7
+ }
8
+
9
+ const { target, class: className, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <button
13
+ type="button"
14
+ class:list={['md-sidebar-trigger', className]}
15
+ aria-controls={target}
16
+ aria-expanded="false"
17
+ data-md-sidebar-trigger
18
+ {...attrs}
19
+ >
20
+ <slot />
21
+ </button>
22
+
23
+ <script>
24
+ import { attachTrigger } from '@minidocs/astro/behaviors';
25
+
26
+ for (const button of document.querySelectorAll<HTMLButtonElement>('[data-md-sidebar-trigger]')) {
27
+ attachTrigger(button);
28
+ }
29
+ </script>
@@ -0,0 +1,7 @@
1
+ export { default as Group } from './Group.astro';
2
+ export { default as Item } from './Item.astro';
3
+ export { default as Label } from './Label.astro';
4
+ export { default as Link } from './Link.astro';
5
+ export { default as List } from './List.astro';
6
+ export { default as Root } from './Root.astro';
7
+ export { default as Trigger } from './Trigger.astro';
@@ -0,0 +1,9 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'li'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <li class:list={['md-toc-item', className]} {...attrs}><slot /></li>
@@ -0,0 +1,12 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends Omit<HTMLAttributes<'a'>, 'href'> {
5
+ /** Id of the heading to link to. */
6
+ slug: string;
7
+ }
8
+
9
+ const { slug, class: className, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <a class:list={['md-toc-link', className]} href={`#${slug}`} {...attrs}><slot /></a>
@@ -0,0 +1,11 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ type Props = HTMLAttributes<'ul'>;
5
+
6
+ const { class: className, ...attrs } = Astro.props;
7
+ ---
8
+
9
+ <ul class:list={['md-toc-list', className]} {...attrs}>
10
+ <slot />
11
+ </ul>
@@ -0,0 +1,20 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'nav'> {
5
+ /** Accessible name of the navigation, e.g. "On this page". */
6
+ label?: string;
7
+ }
8
+
9
+ const { label, class: className, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <nav class:list={['md-toc', className]} aria-label={label} data-md-toc {...attrs}>
13
+ <slot />
14
+ </nav>
15
+
16
+ <script>
17
+ import { attachToc } from '@minidocs/astro/behaviors';
18
+
19
+ for (const root of document.querySelectorAll<HTMLElement>('[data-md-toc]')) attachToc(root);
20
+ </script>