@rr0/cms
Version:
RR0 Content Management System (CMS)
22 lines (21 loc) • 611 B
JavaScript
import { DomReplaceCommand } from "ssg-api";
import path from "path";
/**
* Enforce a constant host value for the <base> tag
*/
export class BaseReplaceCommand extends DomReplaceCommand {
constructor(baseUrl) {
super("base", undefined);
this.baseUrl = baseUrl;
}
async createReplacer(context) {
const self = this;
return new class {
async replace(original) {
const dir = path.dirname(context.file.name);
original.href = path.join(self.baseUrl, dir, "/");
return original;
}
};
}
}