mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-14 01:24:19 +02:00
Docs: add aria label on section headings anchor links (#41487)
Co-authored-by: Julien Déramond <juderamond@gmail.com> Co-authored-by: Patrick H. Lauke <redux@splintered.co.uk>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
],
|
||||
|
Reference in New Issue
Block a user