blob: 2ccb46e07d05eba9dc76f03577541d4e0edea9b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
const { normalizeHeadTag } = require('../util')
module.exports = class SiteDataPlugin {
constructor ({ tags }) {
this.tags = tags
}
apply (compiler) {
compiler.hooks.compilation.tap('vuepress-site-data', compilation => {
compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync('vuepress-site-data', (data, cb) => {
try {
this.tags.forEach(tag => {
data.head.push(normalizeHeadTag(tag))
})
} catch (e) {
return cb(e)
}
cb(null, data)
})
})
}
}
|