Files
zhdiary/plugins/cogear-plugin-base-url/plugin.js
T
2019-08-12 01:34:35 +07:00

13 lines
421 B
JavaScript

const path = require("path");
const fs = require("fs");
module.exports = {
apply() {
cogear.on("build.page.writeAfter", ([page, html]) => {
let BASE_URL = cogear.config.baseUrl || "/";
html = html.replace(/(<link rel="stylesheet" href="|<script src=")\//g, `$1${BASE_URL}`);
page.writePath = path.join(cogear.options.output, page.path);
fs.writeFileSync(page.writePath, html);
})
}
}