mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-12 06:46:24 +10:00
33 lines
640 B
JavaScript
33 lines
640 B
JavaScript
'use strict'
|
|
|
|
/**
|
|
* Module dependencies.
|
|
*/
|
|
|
|
const { normalizeHeadTag } = require('../util/index')
|
|
|
|
/**
|
|
* Expose HeadPlugin class.
|
|
*/
|
|
|
|
module.exports = class HeadPlugin {
|
|
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)
|
|
})
|
|
})
|
|
}
|
|
}
|