Skip to content

Commit

Permalink
core: adds support for custom extension (defaults to html)
Browse files Browse the repository at this point in the history
  • Loading branch information
dresende committed Feb 6, 2024
1 parent 64baa74 commit af398a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions core/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export class Renderer {
#debug = false;

constructor(options = {}) {
this.#resolver = options.resolver ?? Resolver;
this.#debug = (options.debug === true);
this.#resolver = options.resolver ?? Resolver(options.extension ?? "html");
this.#debug = (options.debug === true);
}

async compilePath(path, ...args) {
Expand Down
18 changes: 10 additions & 8 deletions core/Resolver.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { resolve } from "path";

export function Resolver(path, base = null) {
if (!path.endsWith(".html")) {
path += ".html";
}
export function Resolver(extension) {
return (path, base = null) => {
if (!path.endsWith(`.${extension}`)) {
path += `.${extension}`;
}

if (base) {
return resolve(base, path);
}
if (base) {
return resolve(base, path);
}

return resolve(path);
return resolve(path);
};
}

0 comments on commit af398a5

Please sign in to comment.