Skip to content

Commit

Permalink
fix cache invalidation on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-rubio committed Oct 29, 2024
1 parent 44021ad commit 6c968c9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
- Allow to specify fallbacks for `metas` and `feed` plugins [#683].

### Fixed
- Vento plugin: Cache invalidation on Windows.
- Nav plugin: Breadcrumb with urls with CJK characters.
- Enable tests for `sri` and `reading_info` plugins [#677].
- Fix tests for `esbuild` plugin [#676].
Expand Down
2 changes: 1 addition & 1 deletion deps/vento.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export { default as engine } from "https://deno.land/x/[email protected]/mod.ts";
export { FileLoader } from "https://deno.land/x/[email protected]/src/loader.ts";

export type {
Environment,
Plugin,
} from "https://deno.land/x/[email protected]/src/environment.ts";
export type { Loader } from "https://deno.land/x/[email protected]/src/loader.ts";
export type { Token } from "https://deno.land/x/[email protected]/src/tokenizer.ts";
26 changes: 20 additions & 6 deletions plugins/vento.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { engine, FileLoader } from "../deps/vento.ts";
import { engine } from "../deps/vento.ts";
import { posix } from "../deps/path.ts";
import loader from "../core/loaders/text.ts";
import { merge } from "../core/utils/object.ts";
import { normalizePath } from "../core/utils/path.ts";
Expand All @@ -7,7 +8,7 @@ import type Site from "../core/site.ts";
import type { Data } from "../core/file.ts";
import type { Engine, Helper, HelperOptions } from "../core/renderer.ts";
import type FS from "../core/fs.ts";
import type { Environment, Plugin, Token } from "../deps/vento.ts";
import type { Environment, Plugin, Token, Loader } from "../deps/vento.ts";

export interface Options {
/** The list of extensions this plugin applies to */
Expand Down Expand Up @@ -53,15 +54,16 @@ export const defaults: Options = {
},
};

class LumeLoader extends FileLoader {
class LumeLoader implements Loader {
fs: FS;
#root: string;

constructor(includes: string, fs: FS) {
super(includes);
constructor(root: string, fs: FS) {
this.#root = root;
this.fs = fs;
}

override async load(file: string) {
async load(file: string) {
const entry = this.fs.entries.get(normalizePath(file));

if (!entry) {
Expand All @@ -75,6 +77,18 @@ class LumeLoader extends FileLoader {
data: data,
};
}

resolve(from: string, file: string): string {
if (file.startsWith(".")) {
return normalizePath(posix.join(posix.dirname(from), file));
}

if (file.startsWith(this.#root)) {
return normalizePath(file);
}

return normalizePath(posix.join(this.#root, file));
}
}

/** Template engine to render Vento files */
Expand Down

0 comments on commit 6c968c9

Please sign in to comment.