mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-11 06:16:08 +10:00
23 lines
554 B
JavaScript
23 lines
554 B
JavaScript
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)
|
|
})
|
|
})
|
|
}
|
|
}
|