Skip to content

Commit f18a722

Browse files
committed
docs - anchors - fix accessibility
1 parent 00b3c51 commit f18a722

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vuepress/.vuepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Readable } from 'stream'
99
import { pwaPlugin } from '@vuepress/plugin-pwa'
1010
import { pwaPopupPlugin } from '@vuepress/plugin-pwa-popup'
1111
import { docsearchPlugin } from '@vuepress/plugin-docsearch'
12+
import anchor from 'markdown-it-anchor'
1213

1314
const domain = 'datagridvue.com'
1415
const hostname = `https://${domain}`
@@ -188,6 +189,9 @@ export default defineUserConfig({
188189
importCode: {
189190
handleImportPath: str => str.replace(/^@temp/, tempDir),
190191
},
192+
anchor: {
193+
permalink: anchor.permalink.headerLink({}),
194+
},
191195
},
192196
plugins: [
193197
shikiPlugin({

vuepress/.vuepress/styles/index.scss

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ html.dark {
6767
/*
6868
TYPOGRAPHY
6969
*/
70+
71+
/*
72+
Changes to the default theme to support using headerLink of markdown-it-anchor for proper accessibility.
73+
*/
74+
a.header-anchor {
75+
opacity: 1;
76+
float: none;
77+
margin-left: 0;
78+
}
79+
7080
h2 {
7181
border-bottom-color: var(--color-secondary-opaque);
7282
}
@@ -82,14 +92,19 @@ h2 {
8292
padding-top: 0;
8393
}
8494

85-
h1 {
95+
h1, h1 a {
8696
color: var(--c-text);
8797
}
8898

89-
h2, h3, h4, h5, h6 {
99+
h2, h3, h4, h5, h6, h2 a, h3 a, h4 a, h5 a, h6 a {
90100
color: var(--color-secondary);
91101
}
92102

103+
h1, h2, h3, h4, h5, h6 {
104+
/* add scroll margin to account for fixed navbar */
105+
scroll-margin-top: calc(var(--navbar-height) + 1rem);
106+
}
107+
93108
p a code {
94109
color: var(--color-accent3);
95110
}

vuepress/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@vuepress/theme-default": "2.0.0-rc.0",
3333
"@vuepress/utils": "2.0.0-rc.0",
3434
"data-grid-vue": "workspace:^",
35+
"markdown-it-anchor": "^8.6.7",
3536
"markdown-it-include": "^2.0.0",
3637
"postcss": "^8.4.31",
3738
"sitemap": "^7.1.1",

0 commit comments

Comments
 (0)