@jaamd/astro 0.0.0-stage → 1.0.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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -2
  3. package/dist/default.css +1 -0
  4. package/dist/shiki-dual.css +1 -0
  5. package/dist/styles.css +1 -0
  6. package/dist/themes/catppuccin/index.css +1 -0
  7. package/dist/themes/dracula/dark.css +1 -0
  8. package/dist/themes/dracula/index.css +1 -0
  9. package/dist/themes/gruvbox/index.css +1 -0
  10. package/dist/themes/nord/dark.css +1 -0
  11. package/dist/themes/nord/index.css +1 -0
  12. package/dist/themes/one-dark/dark.css +1 -0
  13. package/dist/themes/one-dark/index.css +1 -0
  14. package/dist/themes/rose-pine/index.css +1 -0
  15. package/dist/themes/rose-pine-moon/index.css +1 -0
  16. package/dist/themes/tokyo-night/dark.css +1 -0
  17. package/dist/themes/tokyo-night/index.css +1 -0
  18. package/docs/00-overview.md +33 -0
  19. package/docs/01-getting-started/01-installation.md +109 -0
  20. package/docs/01-getting-started/02-options.md +81 -0
  21. package/docs/02-markdown.md +156 -0
  22. package/docs/03-usage/01-markdown-content.md +45 -0
  23. package/docs/03-usage/02-client.md +70 -0
  24. package/docs/04-styling/01-variables.md +87 -0
  25. package/docs/04-styling/02-themes.md +90 -0
  26. package/docs/04-styling/03-markup.md +29 -0
  27. package/docs/05-advanced/01-manual-setup.md +72 -0
  28. package/docs/05-advanced/02-frontmatter.md +20 -0
  29. package/docs/05-advanced/03-other-frameworks.md +111 -0
  30. package/docs/06-upgrading.md +156 -0
  31. package/index.ts +6 -0
  32. package/package.json +73 -3
  33. package/src/astro-satteri.ts +10 -0
  34. package/src/client.ts +1 -0
  35. package/src/components/MarkdownContent.astro +21 -0
  36. package/src/components/MarkdownContent.astro.d.ts +12 -0
  37. package/src/frontmatter.ts +27 -0
  38. package/src/integration.ts +96 -0
  39. package/src/processors.ts +135 -0
  40. package/src/rehype-heading-ids.js +5 -0
  41. package/src/shiki.ts +29 -0
  42. package/src/themes.ts +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Luca Pattocchio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,64 @@
1
- # Temporary Holding Version
1
+ <h1 align="center">JAAMD</h1>
2
+ <p align="center">
3
+ <b>Just Another Astro Markdown</b> — markdown plugins, client-side enhancements and styles as a single Astro integration.
4
+ </p>
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ ---
7
+
8
+ Alerts, code tabs, a table of contents and spoilers in your markdown; heading
9
+ anchors, scrollable tables, copy buttons and an image lightbox on the page; a
10
+ stylesheet driven by CSS variables, with eight theme presets.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npx astro add @jaamd/astro
16
+ ```
17
+
18
+ Or install it and register it yourself:
19
+
20
+ ```ts
21
+ // astro.config.mjs
22
+ import jaamd from '@jaamd/astro'
23
+ import { defineConfig } from 'astro/config'
24
+
25
+ export default defineConfig({
26
+ integrations: [jaamd()],
27
+ })
28
+ ```
29
+
30
+ Then wrap your markdown in the component, in your layout:
31
+
32
+ ```astro
33
+ ---
34
+ import MarkdownContent from '@jaamd/astro/components'
35
+ ---
36
+
37
+ <MarkdownContent>
38
+ <slot />
39
+ </MarkdownContent>
40
+ ```
41
+
42
+ Requires Astro `^7.3.0` and Node `>=22.12.0`.
43
+
44
+ ## Documentation
45
+
46
+ The documentation ships with the package, in
47
+ [`docs/`](https://github.com/jaamd/jaamd/tree/main/packages/astro/docs): once
48
+ installed, at `node_modules/@jaamd/astro/docs/`. Point an agent's `AGENTS.md`
49
+ there. It is also published at [docs.jaamd.org](https://docs.jaamd.org).
50
+
51
+ | Page | What |
52
+ | ------------------------------------------------------------- | ------------------------------------------------------------- |
53
+ | [Installation](./docs/01-getting-started/01-installation.md) | Requirements and setup |
54
+ | [Options](./docs/01-getting-started/02-options.md) | `theme`, `selector`, `defaultVariables`, `features`, `labels` |
55
+ | [Markdown syntax](./docs/02-markdown.md) | Alerts, code tabs, table of contents, spoilers |
56
+ | [MarkdownContent](./docs/03-usage/01-markdown-content.md) | The wrapper component |
57
+ | [Client script](./docs/03-usage/02-client.md) | Enhancements, keyboard, lightbox |
58
+ | [Variables](./docs/04-styling/01-variables.md) | CSS variables, font sizes, dark mode |
59
+ | [Themes](./docs/04-styling/02-themes.md) | Presets and dual-theme Shiki |
60
+ | [Markup and classes](./docs/04-styling/03-markup.md) | The emitted HTML |
61
+ | [Manual setup](./docs/05-advanced/01-manual-setup.md) | Registering the plugins yourself |
62
+ | [Frontmatter fields](./docs/05-advanced/02-frontmatter.md) | `frontmatterFields(z)` |
63
+ | [Other frameworks](./docs/05-advanced/03-other-frameworks.md) | `@jaamd/core` |
64
+ | [Upgrading](./docs/06-upgrading.md) | Changes between versions |
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/default.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/shiki-dual.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/styles.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/catppuccin.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/dracula/dark.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/dracula.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/gruvbox.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/nord/dark.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/nord.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/one-dark/dark.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/one-dark.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/rose-pine.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/rose-pine-moon.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/tokyo-night/dark.css';
@@ -0,0 +1 @@
1
+ @import '@jaamd/core/themes/tokyo-night.css';
@@ -0,0 +1,33 @@
1
+ ---
2
+ description: JAAMD refines the Markdown you already write, as one Astro integration.
3
+ ---
4
+
5
+ # Overview
6
+
7
+ **Just Another Astro Markdown**: Markdown plugins, client-side enhancements and
8
+ styles as a single Astro integration. Your pages, layouts and routes stay
9
+ yours; JAAMD only changes how Markdown looks and behaves.
10
+
11
+ - **In the Markdown you write:** [alerts](./02-markdown.md#alerts),
12
+ [code tabs](./02-markdown.md#code-tabs), a
13
+ [table of contents](./02-markdown.md#table-of-contents) and
14
+ [spoilers](./02-markdown.md#spoilers).
15
+ - **In the built HTML:** heading anchors and scrollable tables.
16
+ - **In the browser:** copy buttons, an image lightbox and keyboard support,
17
+ from a [client script](./03-usage/02-client.md).
18
+ - **In the stylesheet:** [CSS variables](./04-styling/01-variables.md) and
19
+ [eight theme presets](./04-styling/02-themes.md).
20
+
21
+ ## Packages
22
+
23
+ | Package | What it is |
24
+ | -------------- | -------------------------------------------------------------------------------- |
25
+ | `@jaamd/astro` | The Astro integration and the `<MarkdownContent>` component. Install this one. |
26
+ | `@jaamd/core` | The plugins, the client script and the styles, with no framework around them. |
27
+ | `@jaamd/jaad` | A [documentation site generator](../../jaad/docs/00-overview.md) built on JAAMD. |
28
+
29
+ `@jaamd/astro` brings `@jaamd/core` with it: an Astro project never installs
30
+ core itself. To use JAAMD with another framework, see
31
+ [Other frameworks](./05-advanced/03-other-frameworks.md).
32
+
33
+ Start with [Installation](./01-getting-started/01-installation.md).
@@ -0,0 +1,109 @@
1
+ ---
2
+ description: Install the @jaamd/astro integration and wrap your Markdown with it.
3
+ ---
4
+
5
+ # Installation
6
+
7
+ Let Astro add the integration and register it for you:
8
+
9
+ :::code-tabs
10
+
11
+ ```bash npm
12
+ npx astro add @jaamd/astro
13
+ ```
14
+
15
+ ```bash pnpm
16
+ pnpm astro add @jaamd/astro
17
+ ```
18
+
19
+ ```bash yarn
20
+ yarn astro add @jaamd/astro
21
+ ```
22
+
23
+ ```bash bun
24
+ bunx astro add @jaamd/astro
25
+ ```
26
+
27
+ :::
28
+
29
+ Or install it and register it yourself:
30
+
31
+ :::code-tabs
32
+
33
+ ```bash npm
34
+ npm install @jaamd/astro
35
+ ```
36
+
37
+ ```bash pnpm
38
+ pnpm add @jaamd/astro
39
+ ```
40
+
41
+ ```bash yarn
42
+ yarn add @jaamd/astro
43
+ ```
44
+
45
+ ```bash bun
46
+ bun add @jaamd/astro
47
+ ```
48
+
49
+ :::
50
+
51
+ ```ts
52
+ // astro.config.mjs
53
+ import jaamd from '@jaamd/astro'
54
+ import { defineConfig } from 'astro/config'
55
+
56
+ export default defineConfig({
57
+ integrations: [jaamd()],
58
+ })
59
+ ```
60
+
61
+ ## Requirements
62
+
63
+ | Requirement | Detail |
64
+ | -------------------------- | --------------------------------------------------------- |
65
+ | Astro | `^7.3.0` |
66
+ | Node | `>=22.12.0` |
67
+ | Markdown processor | Sätteri (Astro's default) or `unified()` |
68
+ | `@astrojs/markdown-remark` | Only with `unified()`: an optional peer, installed by you |
69
+ | Toolchain | Must compile TypeScript and `.astro` sources |
70
+
71
+ `@jaamd/astro` is published as TypeScript and `.astro` source, which any Astro
72
+ project compiles. It is not consumable from plain Node, a CommonJS build, or a
73
+ TypeScript project using `"moduleResolution": "node16"`: outside Astro, use
74
+ the compiled [`@jaamd/core`](../05-advanced/03-other-frameworks.md).
75
+
76
+ ## Wrapping your content
77
+
78
+ Wrap your markdown content with the
79
+ [`MarkdownContent`](../03-usage/01-markdown-content.md) component in your
80
+ layout:
81
+
82
+ ```astro
83
+ ---
84
+ // src/layouts/BlogPost.astro
85
+ import MarkdownContent from '@jaamd/astro/components'
86
+ ---
87
+
88
+ <MarkdownContent>
89
+ <slot />
90
+ </MarkdownContent>
91
+ ```
92
+
93
+ The integration registers its plugins on the configured markdown processor and
94
+ injects the stylesheet. No other configuration is required.
95
+
96
+ The processor is extended, never replaced: Sätteri gets mdast plugins and the
97
+ directive syntax, `unified()` gets the remark plugins. Any other processor is
98
+ left alone, with a warning.
99
+
100
+ > [!IMPORTANT]
101
+ > `<MarkdownContent>` loads the stylesheets for you. If you render markdown
102
+ > **without** it, import them yourself in your layout frontmatter:
103
+ >
104
+ > ```astro
105
+ > ---
106
+ > import '@jaamd/astro/default.css'
107
+ > import '@jaamd/astro/styles.css'
108
+ > ---
109
+ > ```
@@ -0,0 +1,81 @@
1
+ ---
2
+ description: 'Every option of the jaamd() integration: theme, selector, default variables, features and labels.'
3
+ ---
4
+
5
+ # Options
6
+
7
+ `jaamd()` works with no options. Each one below changes a single behaviour:
8
+
9
+ ```ts
10
+ jaamd({
11
+ selector: '.jaamd-content', // elements the client script enhances
12
+ theme: 'github-light', // Shiki theme name, or { light, dark }; see below
13
+ defaultVariables: true, // inject @jaamd/astro/default.css on every page
14
+ features: {}, // features to turn off, such as { lightbox: false }
15
+ labels: {}, // text JAAMD writes into the page
16
+ })
17
+ ```
18
+
19
+ ## `theme`
20
+
21
+ The Shiki theme for code blocks, or `{ light, dark }` for
22
+ [dual-theme mode](../04-styling/02-themes.md#dual-theme-shiki). Unset,
23
+ `markdown.shikiConfig` is left as configured; `"github-light"` replaces only
24
+ Astro's own default (`"github-dark"` with no `themes`).
25
+
26
+ ## `selector`
27
+
28
+ Controls which element the **client-side JS enhancements** target at runtime.
29
+ It does not affect the CSS file, which always uses `.jaamd-content`.
30
+
31
+ - With `<MarkdownContent>`, leave it at the default.
32
+ - With a custom wrapper (e.g. `<div data-md>`), set `selector` to match it and
33
+ provide your own CSS.
34
+
35
+ ## `defaultVariables`
36
+
37
+ Set to `false` when you supply a complete `--jaamd-*` variable set of your own.
38
+ It has no effect on `<MarkdownContent>`, which imports the defaults directly;
39
+ with a custom wrapper, control them by importing `@jaamd/astro/default.css` or
40
+ not.
41
+
42
+ ## `features`
43
+
44
+ Every feature is on. Set one to `false` to turn it off, in the build and in the
45
+ client script:
46
+
47
+ | Feature | What | Where |
48
+ | -------------- | -------------------------------------------- | ------------- |
49
+ | `alerts` | `> [!NOTE]` blockquotes | build |
50
+ | `codeTabs` | `:::code-tabs` blocks | build, client |
51
+ | `toc` | `:::toc` blocks | build, client |
52
+ | `spoilers` | `:spoiler[…]` and `:::spoiler` | build, client |
53
+ | `directives` | The `:::` syntax, for directives of your own | build |
54
+ | `tables` | Scroll container around tables | build, client |
55
+ | `headingLinks` | Anchor on every heading | build, client |
56
+ | `copyButtons` | Copy button on code blocks | client |
57
+ | `lightbox` | Images open in a dialog | client |
58
+
59
+ `directives` stays on while `codeTabs`, `toc` or `spoilers` is, since they are
60
+ written in it.
61
+
62
+ ## `labels`
63
+
64
+ The text JAAMD writes into the page, in English by default. Set the ones to
65
+ translate:
66
+
67
+ ```ts
68
+ jaamd({ labels: { copy: 'Copia il codice', headingLink: 'Link alla sezione' } })
69
+ ```
70
+
71
+ | Label | Default |
72
+ | --------------- | ------------------------------------------------- |
73
+ | `headingLink` | `Link to section`, followed by the heading |
74
+ | `toc` | `Table of contents`, for a `:::toc` without title |
75
+ | `copy` | `Copy code` |
76
+ | `copied` | `Code copied to clipboard` |
77
+ | `copySelected` | `Code selected: copy it with your keyboard` |
78
+ | `lightbox` | `Image preview` |
79
+ | `lightboxOpen` | `Enlarge image`, followed by the alt text |
80
+ | `lightboxClose` | `Close image preview` |
81
+ | `spoiler` | `Spoiler` |
@@ -0,0 +1,156 @@
1
+ ---
2
+ description: The blocks JAAMD adds to CommonMark and GitHub Flavored Markdown, each with its result.
3
+ keywords: [alerts, code tabs, toc, spoilers, directives]
4
+ ---
5
+
6
+ # Markdown syntax
7
+
8
+ JAAMD extends [CommonMark](https://commonmark.org/help/) and
9
+ [GitHub Flavored Markdown](https://github.github.com/gfm/) with the blocks
10
+ below. Each one is shown as you write it, then as it renders. Every one of them
11
+ can be turned off with the
12
+ [`features` option](./01-getting-started/02-options.md#features).
13
+
14
+ ## Alerts
15
+
16
+ GitHub-style blockquote alerts, in five types: `NOTE`, `TIP`, `IMPORTANT`,
17
+ `WARNING` and `CAUTION`.
18
+
19
+ ```markdown
20
+ > [!NOTE]
21
+ > Useful information the reader should know.
22
+
23
+ > [!WARNING]
24
+ > Urgent information needing immediate attention.
25
+ ```
26
+
27
+ > [!NOTE]
28
+ > Useful information the reader should know.
29
+
30
+ > [!WARNING]
31
+ > Urgent information needing immediate attention.
32
+
33
+ ## Code tabs
34
+
35
+ Group several code blocks into a tabbed panel. The text after the language is
36
+ the tab label; it falls back to the language, then to `Tab N`.
37
+
38
+ ````markdown
39
+ :::code-tabs
40
+
41
+ ```bash npm
42
+ npm install
43
+ ```
44
+
45
+ ```bash pnpm
46
+ pnpm install
47
+ ```
48
+
49
+ :::
50
+ ````
51
+
52
+ :::code-tabs
53
+
54
+ ```bash npm
55
+ npm install
56
+ ```
57
+
58
+ ```bash pnpm
59
+ pnpm install
60
+ ```
61
+
62
+ :::
63
+
64
+ ## Table of contents
65
+
66
+ A `:::toc` block wraps the list you write in a navigation landmark. Nothing is
67
+ generated: entries, order, wording and depth are whatever the Markdown says.
68
+ The text in brackets is an optional title.
69
+
70
+ ```markdown
71
+ :::toc[On this page]
72
+
73
+ - [Alerts](#alerts)
74
+ - [Code tabs](#code-tabs)
75
+
76
+ :::
77
+ ```
78
+
79
+ :::toc[On this page]
80
+
81
+ - [Alerts](#alerts)
82
+ - [Code tabs](#code-tabs)
83
+
84
+ :::
85
+
86
+ A `-` list loses its bullets, `1.` keeps the numbers. Entries are plain anchors
87
+ and navigate with JavaScript disabled; with it, the entry whose section is on
88
+ screen is marked `aria-current="location"`. The title is a `<p>`, so it stays
89
+ out of `getHeadings()` and has no anchor.
90
+
91
+ ### Writing the anchors
92
+
93
+ Heading ids come from Astro, slugged with
94
+ [`github-slugger`](https://github.com/Flet/github-slugger):
95
+
96
+ | Heading | Anchor |
97
+ | ------------------------ | ------------------------------------------------------------------------ |
98
+ | `## Getting started` | `#getting-started` |
99
+ | `## Details / accordion` | `#details--accordion` (one dash per space, the `/` dropped between them) |
100
+ | `## What's new?` | `#whats-new` (punctuation removed, not replaced) |
101
+ | `## snake_case` | `#snake_case` (underscores survive) |
102
+ | a second `## Setup` | `#setup-1` |
103
+
104
+ The client script follows the same rules, so ids match for Markdown that never
105
+ went through Astro's pipeline (`set:html`, HTML from a CMS).
106
+
107
+ With a sticky header, raise `--jaamd-scroll-margin-top` (default `80px`).
108
+
109
+ > [!NOTE]
110
+ > `:::toc` needs the directive syntax, on by default. With
111
+ > `features: { toc: false }` the block degrades to a plain `<div>`: list and
112
+ > links intact, unstyled.
113
+
114
+ ## Spoilers
115
+
116
+ Text hidden until the reader activates it, inline or as a block. Spoilers are
117
+ reachable from the keyboard and hide again on reload.
118
+
119
+ ```markdown
120
+ The answer is :spoiler[42].
121
+
122
+ :::spoiler
123
+ A whole paragraph, hidden.
124
+ :::
125
+ ```
126
+
127
+ The answer is :spoiler[42].
128
+
129
+ :::spoiler
130
+ A whole paragraph, hidden.
131
+ :::
132
+
133
+ In HTML you write yourself, the class is `jaamd-spoiler`.
134
+
135
+ ## Details
136
+
137
+ `<details>` is plain HTML. JAAMD styles it and animates it open and closed, in
138
+ CSS alone.
139
+
140
+ ```html
141
+ <details>
142
+ <summary>Why is the sky blue?</summary>
143
+ Shorter wavelengths scatter more.
144
+ </details>
145
+ ```
146
+
147
+ <details>
148
+ <summary>Why is the sky blue?</summary>
149
+ Shorter wavelengths scatter more.
150
+ </details>
151
+
152
+ ## Without writing anything
153
+
154
+ Some enhancements need no syntax. Every heading gets an anchor link, every code
155
+ block a copy button, every image a lightbox, and every table a scroll container
156
+ on narrow screens. See [Client script](./03-usage/02-client.md).
@@ -0,0 +1,45 @@
1
+ ---
2
+ description: The MarkdownContent component, which wraps rendered Markdown and loads the styles.
3
+ ---
4
+
5
+ # MarkdownContent
6
+
7
+ `MarkdownContent` is a polymorphic component. It renders as `<div>` by default
8
+ and accepts any valid HTML tag via the `as` prop. It loads the stylesheets; the
9
+ [client script](./02-client.md) the integration injects enhances its content.
10
+
11
+ ```ts
12
+ import MarkdownContent from '@jaamd/astro/components'
13
+ ```
14
+
15
+ ## Props
16
+
17
+ | Prop | Type | Default | Description |
18
+ | --------- | --------- | ------- | ----------------------------------------------------------------------------------------- |
19
+ | `as` | `HTMLTag` | `"div"` | The HTML element to render as. |
20
+ | `class` | `string` | - | Extra CSS classes appended to the wrapper. |
21
+ | _...rest_ | - | - | All standard HTML attributes for the chosen `as` element (e.g. `id`, `data-*`, `aria-*`). |
22
+
23
+ The `jaamd-content` class is always present on the wrapper element. It is the
24
+ selector used by the JS enhancements and must not be removed.
25
+
26
+ ```astro
27
+ ---
28
+ import MarkdownContent from '@jaamd/astro/components'
29
+ ---
30
+
31
+ <!-- Default: renders as <div class="jaamd-content"> -->
32
+ <MarkdownContent>
33
+ <slot />
34
+ </MarkdownContent>
35
+
36
+ <!-- Custom tag: renders as <article class="jaamd-content"> -->
37
+ <MarkdownContent as="article">
38
+ <slot />
39
+ </MarkdownContent>
40
+
41
+ <!-- Extra classes: renders as <article class="jaamd-content prose mx-auto"> -->
42
+ <MarkdownContent as="article" class="prose mx-auto">
43
+ <slot />
44
+ </MarkdownContent>
45
+ ```
@@ -0,0 +1,70 @@
1
+ ---
2
+ description: What the client script adds in the browser, and how it behaves from the keyboard.
3
+ ---
4
+
5
+ # Client script
6
+
7
+ A dependency-free ES module enhances the rendered markdown. The integration
8
+ injects it on every page; it runs on the elements matching
9
+ [`selector`](../01-getting-started/02-options.md#selector), with the
10
+ [`features`](../01-getting-started/02-options.md#features) and
11
+ [`labels`](../01-getting-started/02-options.md#labels) of the integration. Events are delegated
12
+ on `document`; per-element setup re-runs on every `astro:page-load`, so it
13
+ keeps working across View Transitions.
14
+
15
+ Table wrappers and heading anchors come from the build. The module adds them
16
+ only to markup that skipped the processor (`set:html`, HTML from a CMS).
17
+
18
+ | Enhancement | Behaviour |
19
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
20
+ | Heading links | Adds an anchor link to `h1`–`h6` where the build did not. Fills in a missing `id` with a `github-slugger`-compatible slug, de-duplicated across the page. |
21
+ | Table of contents | Marks the `:::toc` entry whose section is on screen with `aria-current="location"`. |
22
+ | Copy buttons | Adds a copy button to every `pre`. Without clipboard access it selects the code instead. The only clipboard write in the package. |
23
+ | Image lightbox | Wraps each image in a button that opens it in a modal `<dialog>`. Closes on <kbd>Esc</kbd>, the ✕ button or a click outside the image. |
24
+ | Responsive tables | Wraps a `table` in a horizontally scrollable container where the build did not. |
25
+ | Code tabs | Drives the `:::code-tabs` tablist. |
26
+ | Spoilers | Reveals a spoiler on click or <kbd>Enter</kbd>/<kbd>Space</kbd>. |
27
+
28
+ ## Keyboard
29
+
30
+ | Element | Keys |
31
+ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
32
+ | Code tabs | <kbd>←</kbd> <kbd>→</kbd> move between tabs, <kbd>Home</kbd> <kbd>End</kbd> jump to first/last. Panels are focusable so wide samples can be scrolled. |
33
+ | Spoilers | <kbd>Tab</kbd> to focus, <kbd>Enter</kbd> or <kbd>Space</kbd> to reveal. Hover does not reveal. |
34
+ | Lightbox | <kbd>Tab</kbd> to an image, <kbd>Enter</kbd> or <kbd>Space</kbd> to open, <kbd>Esc</kbd> to close. Focus returns to the image. |
35
+
36
+ `<details>` animates in CSS, no script: height where the browser supports
37
+ `interpolate-size`, a fade elsewhere.
38
+
39
+ Under `prefers-reduced-motion: reduce` JAAMD's CSS transitions are disabled.
40
+
41
+ With scripting disabled, tables still scroll, heading anchors work and every
42
+ code tab panel is shown.
43
+
44
+ ## Image lightbox
45
+
46
+ Opening and closing are the browser's own: the image button and the ✕ button
47
+ are [invoker commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API)
48
+ on the `<dialog>`, and `closedby="any"` closes it on a click outside the image.
49
+
50
+ | Browser | Lightbox | Click outside closes |
51
+ | ------------- | -------- | ---------------------------------- |
52
+ | Chrome / Edge | 135+ | 134+ |
53
+ | Firefox | 144+ | 141+ |
54
+ | Safari | 26.2+ | not yet: <kbd>Esc</kbd> and ✕ only |
55
+
56
+ Older browsers show the image as a plain image.
57
+
58
+ ### Excluding images from the lightbox
59
+
60
+ Linked images are skipped automatically, so badges keep navigating:
61
+
62
+ ```markdown
63
+ [![build](https://img.shields.io/badge/build-passing-green)](https://github.com/you/repo)
64
+ ```
65
+
66
+ Opt a standalone image out with `data-no-lightbox`:
67
+
68
+ ```html
69
+ <img src="/diagram.svg" alt="Architecture diagram" data-no-lightbox />
70
+ ```