From: Maxime Lardenois Date: Sun, 25 May 2025 12:56:22 +0000 (+0200) Subject: Docs: add aria label on section headings anchor links (#41487) X-Git-Tag: v5.3.7~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3663e3a061811798ca1ae8c0e2d2a73c85ecf1ad;p=thirdparty%2Fbootstrap.git Docs: add aria label on section headings anchor links (#41487) Co-authored-by: Julien Déramond Co-authored-by: Patrick H. Lauke --- diff --git a/site/src/libs/astro.ts b/site/src/libs/astro.ts index 3eb6947d34..01b4f6b106 100644 --- a/site/src/libs/astro.ts +++ b/site/src/libs/astro.ts @@ -5,7 +5,7 @@ import mdx from '@astrojs/mdx' import sitemap from '@astrojs/sitemap' import type { AstroIntegration } from 'astro' import autoImport from 'astro-auto-import' -import type { Element } from 'hast' +import type { Element, Text } from 'hast' import rehypeAutolinkHeadings from 'rehype-autolink-headings' import { getConfig } from './config' import { rehypeBsTable } from './rehype' @@ -59,7 +59,10 @@ export function bootstrap(): AstroIntegration[] { { behavior: 'append', content: [{ type: 'text', value: ' ' }], - properties: { class: 'anchor-link' }, + properties: (element: Element) => ({ + class: 'anchor-link', + ariaLabel: `Link to this section: ${(element.children[0] as Text).value}` + }), test: (element: Element) => element.tagName.match(headingsRangeRegex) } ],