UNPKG

@helldoc/core

Version:
35 lines (34 loc) 1.14 kB
"use strict"; function normalizeHeadTag(_a) { var tagName = _a[0], _b = _a[1], attributes = _b === void 0 ? {} : _b, _c = _a[2], innerHTML = _c === void 0 ? "" : _c; return { tagName: tagName, attributes: attributes, innerHTML: innerHTML, closeTag: !(tagName === "meta" || tagName === "link") }; } module.exports = /** @class */ (function () { function HeadPlugin(_a) { var tags = _a.tags; this.tags = []; this.tags = tags; } HeadPlugin.prototype.apply = function (compiler) { var _this = this; compiler.hooks.compilation.tap("helldoc-site-head", function (compilation) { compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync("helldoc-site-data", function (data, cb) { try { _this.tags.forEach(function (tag) { data.head.push(normalizeHeadTag(tag)); }); } catch (e) { return cb(e); } cb(null, data); }); }); }; return HeadPlugin; }());