Skip to content

Commit 5720ca7

Browse files
committed
feat(Axe): using defaultConfig to axe and add docs
1 parent 0316f46 commit 5720ca7

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

Diff for: config/defaultThemeConfig.js

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ export const colorMode = {
55
modes: ['light', 'dark', 'system', 'sepia']
66
}
77
}
8+
9+
export const axe = {
10+
enabled: true
11+
}

Diff for: docs/guide/config.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ module.exports = {
6363
}
6464
```
6565
66-
## Skip to
67-
68-
Pretty soon
69-
7066
## Announcer
7167
7268
The [@vue-a11y/announcer](https://github.com/vue-a11y/vue-announcer) provides an easy way for people using screen readers to know what’s going on in your app.
@@ -104,3 +100,31 @@ module.exports = {
104100
}
105101
}
106102
```
103+
104+
## Axe
105+
106+
We use the `axe` property in `$themeConfig` to customize the vue-axe package.
107+
108+
```javascript
109+
// e.g. docs/.vuepress/config.js
110+
module.exports = {
111+
theme: 'vuepress-theme-default-vue-a11y',
112+
// ...
113+
themeConfig: {
114+
axe: {
115+
enabled: true,
116+
options: {
117+
clearConsoleOnUpdate: true
118+
}
119+
}
120+
}
121+
```
122+
123+
::: tip
124+
See more config options available in VueAxe:
125+
[https://github.com/vue-a11y/vue-axe#configuration](https://github.com/vue-a11y/vue-axe#configuration)
126+
:::
127+
128+
## Skip to
129+
130+
Pretty soon

Diff for: enhanceApp.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import VueAnnouncer from '@vue-a11y/announcer'
22
import VueDarkMode from '@vue-a11y/dark-mode'
33
import 'a11y-css-reset/combo.css'
4+
import merge from 'deepmerge'
45
import VueSkipTo from 'vue-skip-to'
6+
import { axe as axeDefaultConfig } from './config/defaultThemeConfig'
7+
import { isObject } from './utils'
58

6-
export default ({ Vue, router, isServer }) => {
9+
export default ({ Vue, router, isServer, siteData }) => {
710
if (process.env.NODE_ENV === 'development') {
8-
const VueAxe = require('vue-axe').default
9-
Vue.use(VueAxe)
11+
const axeConfig = siteData.themeConfig.axe && isObject(siteData.themeConfig.axe) ? merge(axeDefaultConfig, siteData.themeConfig.axe) : axeDefaultConfig
12+
if (axeConfig.enabled) {
13+
const VueAxe = require('vue-axe').default
14+
Vue.use(VueAxe, axeConfig.options)
15+
}
1016
}
1117
if (!isServer) {
1218
Vue.use(VueSkipTo)

Diff for: utils/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function isObject (item) {
2+
return (item && typeof item === 'object' && !Array.isArray(item))
3+
}

0 commit comments

Comments
 (0)