File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import mdx from '@astrojs/mdx'
55import sitemap from '@astrojs/sitemap'
66import type { AstroIntegration } from 'astro'
77import autoImport from 'astro-auto-import'
8- import type { Element } from 'hast'
8+ import type { Element , Text } from 'hast'
99import rehypeAutolinkHeadings from 'rehype-autolink-headings'
1010import { getConfig } from './config'
1111import { rehypeBsTable } from './rehype'
@@ -58,7 +58,30 @@ export function bootstrap(): AstroIntegration[] {
5858 rehypeAutolinkHeadings ,
5959 {
6060 behavior : 'append' ,
61- content : [ { type : 'text' , value : ' ' } ] ,
61+ content : ( element : Element ) => [
62+ {
63+ type : 'element' ,
64+ tagName : 'span' ,
65+ children : [
66+ {
67+ type : 'text' ,
68+ value : `Link to this section: ${ ( element . children [ 0 ] as Text ) . value } `
69+ }
70+ ] ,
71+ properties : { class : 'visually-hidden' }
72+ } ,
73+ {
74+ type : 'element' ,
75+ tagName : 'span' ,
76+ children : [
77+ {
78+ type : 'text' ,
79+ value : ' #'
80+ }
81+ ] ,
82+ properties : { ariaHidden : true }
83+ }
84+ ] ,
6285 properties : { class : 'anchor-link' } ,
6386 test : ( element : Element ) => element . tagName . match ( headingsRangeRegex )
6487 }
Original file line number Diff line number Diff line change 66 opacity : 0 ;
77 @include transition (color .15s ease-in-out , opacity .15s ease-in-out );
88
9- & ::after {
10- content : " #" ;
11- }
12-
139 & :focus ,
1410 & :hover ,
1511 :hover > & ,
You can’t perform that action at this time.
0 commit comments