Skip to content

Commit c71c8e1

Browse files
committed
Add aria-label to asides
1 parent d5ed679 commit c71c8e1

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/scripts/asides.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,21 @@ export default function astroStarlightRemarkAsides() {
3030
// logic to support :::tip{title="title"} syntax and default to Tip for :::tip
3131
let title = node.attributes.title || callout.title;
3232

33-
node.attributes = {
34-
...attributes,
35-
class: "class" in attributes
36-
? `callout callout-${node.name} ${attributes.class}`
37-
: `callout callout-${node.name}`,
38-
};
39-
4033
// logic to support :::tip[title] syntax
4134
// remark-directive converts a container’s “label” to a paragraph at children[0] with the `directiveLabel` property set to true
4235
if (node.children[0].data?.directiveLabel) {
4336
title = node.children[0].children[0].value;
4437
node.children.shift();
4538
}
4639

40+
node.attributes = {
41+
...attributes,
42+
"aria-label": title,
43+
class: "class" in attributes
44+
? `callout callout-${node.name} ${attributes.class}`
45+
: `callout callout-${node.name}`,
46+
};
47+
4748
node.children = generate(title, node.children, callout.icon);
4849

4950
// TO DO: maybe get rid of h just make it set the classes in hProperties without needing hast

0 commit comments

Comments
 (0)