From 6c968c9cc1c7ba6d17d5ffa6a3bdc4d82567cedc Mon Sep 17 00:00:00 2001 From: Laura Rubio Date: Tue, 29 Oct 2024 14:09:57 +0100 Subject: [PATCH] fix cache invalidation on windows --- CHANGELOG.md | 1 + deps/vento.ts | 2 +- plugins/vento.ts | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc445eb2..5662524a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]. diff --git a/deps/vento.ts b/deps/vento.ts index c7c8371f..f6a08183 100644 --- a/deps/vento.ts +++ b/deps/vento.ts @@ -1,8 +1,8 @@ export { default as engine } from "https://deno.land/x/vento@v1.12.10/mod.ts"; -export { FileLoader } from "https://deno.land/x/vento@v1.12.10/src/loader.ts"; export type { Environment, Plugin, } from "https://deno.land/x/vento@v1.12.10/src/environment.ts"; +export type { Loader } from "https://deno.land/x/vento@v1.12.10/src/loader.ts"; export type { Token } from "https://deno.land/x/vento@v1.12.10/src/tokenizer.ts"; diff --git a/plugins/vento.ts b/plugins/vento.ts index f8081ba0..593d7a7f 100644 --- a/plugins/vento.ts +++ b/plugins/vento.ts @@ -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"; @@ -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 */ @@ -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) { @@ -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 */