nizel-plugin-heading-anchors 0.1.4 → 0.1.6

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # nizel-plugin-heading-anchors
2
2
 
3
- Visible heading anchor links for [Nizel](https://npmjs.com/package/nizel).
3
+ Subtle heading anchor links for [Nizel](https://npmjs.com/package/nizel).
4
4
 
5
- The plugin appends a linked marker to parsed headings that already have generated IDs. It is useful for documentation and long-form pages that need copyable section links.
5
+ The plugin appends a copyable section link to parsed headings that already have generated IDs. By default the link has no visible text, so apps can reveal it with CSS on hover or focus without adding a literal marker to the heading content.
6
6
 
7
7
  The browser build exposes `NizelHeadingAnchors` from `dist/heading-anchors.iife.js`.
8
8
 
@@ -28,12 +28,13 @@ const nizel = useNizel({
28
28
  | Option | Type | Default | Description |
29
29
  | --- | --- | --- | --- |
30
30
  | `className` | `string` | `'heading-anchor'` | CSS class for the generated anchor. |
31
- | `label` | `string` | `'#'` | Visible marker text appended to the heading. |
31
+ | `label` | `string` | `''` | Optional visible marker text appended to the heading. |
32
+ | `ariaLabel` | `string` | `'Link to section'` | Accessible label for the generated anchor. |
32
33
 
33
34
  ## Output
34
35
 
35
36
  ```html
36
- <h2 id="install">Install<a class="heading-anchor" href="#install" aria-hidden="true">#</a></h2>
37
+ <h2 id="install">Install<a class="heading-anchor" href="#install" aria-label="Link to section"></a></h2>
37
38
  ```
38
39
 
39
40
  ## License
@@ -43,7 +43,7 @@ var NizelHeadingAnchors = (() => {
43
43
  ...node.children,
44
44
  {
45
45
  type: "inlineHtml",
46
- value: `<a class="${escapeHtml(options.className ?? "heading-anchor")}" href="#${escapeHtml(node.id)}" aria-hidden="true">${escapeHtml(options.label ?? "#")}</a>`
46
+ value: `<a class="${escapeHtml(options.className ?? "heading-anchor")}" href="#${escapeHtml(node.id)}" aria-label="${escapeHtml(options.ariaLabel ?? "Link to section")}">${escapeHtml(options.label ?? "")}</a>`
47
47
  }
48
48
  ]
49
49
  };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { NizelPlugin, NizelRootNode } from 'nizel';
2
2
  export type HeadingAnchorsPluginOptions = {
3
3
  className?: string;
4
4
  label?: string;
5
+ ariaLabel?: string;
5
6
  };
6
7
  export declare const headingAnchorsPlugin: (options?: HeadingAnchorsPluginOptions) => NizelPlugin;
7
8
  export declare const addHeadingAnchors: (ast: NizelRootNode, options?: HeadingAnchorsPluginOptions) => NizelRootNode;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAS,2BAAgC,KAAG,WAO/E,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,aAAa,EAClB,UAAS,2BAAgC,KACxC,aAeD,CAAC;AAIH,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAS,2BAAgC,KAAG,WAO/E,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,aAAa,EAClB,UAAS,2BAAgC,KACxC,aAeD,CAAC;AAIH,eAAe,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ export const addHeadingAnchors = (ast, options = {}) => ({
17
17
  ...node.children,
18
18
  {
19
19
  type: 'inlineHtml',
20
- value: `<a class="${escapeHtml(options.className ?? 'heading-anchor')}" href="#${escapeHtml(node.id)}" aria-hidden="true">${escapeHtml(options.label ?? '#')}</a>`,
20
+ value: `<a class="${escapeHtml(options.className ?? 'heading-anchor')}" href="#${escapeHtml(node.id)}" aria-label="${escapeHtml(options.ariaLabel ?? 'Link to section')}">${escapeHtml(options.label ?? '')}</a>`,
21
21
  },
22
22
  ],
23
23
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAuC,EAAE,EAAe,EAAE,CAAC,CAAC;IAC/F,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE;QACL,UAAU,CAAC,GAAG;YACZ,OAAO,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAkB,EAClB,UAAuC,EAAE,EAC1B,EAAE,CAAC,CAAC;IACnB,GAAG,GAAG;IACN,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAClC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QACrD,OAAO;YACL,GAAG,IAAI;YACP,QAAQ,EAAE;gBACR,GAAG,IAAI,CAAC,QAAQ;gBAChB;oBACE,IAAI,EAAE,YAAY;oBAClB,KAAK,EAAE,aAAa,UAAU,CAAC,OAAO,CAAC,SAAS,IAAI,gBAAgB,CAAC,YAAY,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,wBAAwB,UAAU,CA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I,iBAAiB,CAAC,KAAK,UAAU,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM;iBAClN;aACF;SACF,CAAC;IACJ,CAAC,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAE/I,eAAe,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nizel-plugin-heading-anchors",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Heading anchor link plugin for Nizel.",
5
5
  "repository": {
6
6
  "type": "git",