eleventy-plugin-vento 5.4.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +19 -17
- package/dist/plugin.d.mts +0 -105
- package/dist/plugin.mjs +0 -259
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# eleventy-plugin-vento
|
|
2
2
|
|
|
3
|
+
## 5.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a8f6efe: Update Vento to v2.4.0 ([release notes](https://github.com/ventojs/vento/blob/HEAD/CHANGELOG.md#240---2026-07-09))
|
|
8
|
+
|
|
9
|
+
## 5.4.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 138db0f: Refactor Vento engine internal methods, should not introduce any functionally breaking changes
|
|
14
|
+
- 2f42cc1: Refactor render function declaration
|
|
15
|
+
- Replaced `getTemplateFunction` with `getRenderFunction`
|
|
16
|
+
- New method now returns the render function signature Eleventy expects with all error handling logic built in, eliminating the need for a separate render function handler
|
|
17
|
+
|
|
3
18
|
## 5.4.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eleventy-plugin-vento",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Adds support for the Vento templating language to Eleventy.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
"CHANGELOG.md",
|
|
20
20
|
"readme.md"
|
|
21
21
|
],
|
|
22
|
-
"repository":
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git@github.com:noelforte/eleventy-plugin-vento.git"
|
|
25
|
+
},
|
|
23
26
|
"bugs": {
|
|
24
27
|
"url": "https://github.com/noelforte/eleventy-plugin-vento/issues"
|
|
25
28
|
},
|
|
@@ -37,24 +40,23 @@
|
|
|
37
40
|
"license": "MIT",
|
|
38
41
|
"dependencies": {
|
|
39
42
|
"debug": "4.4.3",
|
|
40
|
-
"ventojs": "2.
|
|
43
|
+
"ventojs": "2.4.0"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
|
-
"11ty
|
|
44
|
-
"@
|
|
45
|
-
"@changesets/cli": "2.30.0",
|
|
46
|
+
"@11ty/eleventy": "3.1.6",
|
|
47
|
+
"@changesets/cli": "2.31.0",
|
|
46
48
|
"@eslint/js": "10.0.1",
|
|
47
|
-
"@types/debug": "4.1.
|
|
48
|
-
"@types/node": "24.
|
|
49
|
-
"eslint": "10.0
|
|
49
|
+
"@types/debug": "4.1.13",
|
|
50
|
+
"@types/node": "24.13.3",
|
|
51
|
+
"eslint": "10.7.0",
|
|
50
52
|
"eslint-config-prettier": "10.1.8",
|
|
51
|
-
"eslint-plugin-unicorn": "
|
|
52
|
-
"globals": "17.
|
|
53
|
-
"knip": "
|
|
54
|
-
"prettier": "3.
|
|
55
|
-
"tsdown": "0.
|
|
56
|
-
"typescript": "
|
|
57
|
-
"typescript-eslint": "8.
|
|
58
|
-
"vitest": "4.
|
|
53
|
+
"eslint-plugin-unicorn": "71.1.0",
|
|
54
|
+
"globals": "17.7.0",
|
|
55
|
+
"knip": "6.26.0",
|
|
56
|
+
"prettier": "3.9.5",
|
|
57
|
+
"tsdown": "0.22.4",
|
|
58
|
+
"typescript": "6.0.3",
|
|
59
|
+
"typescript-eslint": "8.63.0",
|
|
60
|
+
"vitest": "4.1.10"
|
|
59
61
|
}
|
|
60
62
|
}
|
package/dist/plugin.d.mts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as ventojs from "ventojs";
|
|
3
|
-
import _UserConfig from "@11ty/eleventy/UserConfig";
|
|
4
|
-
import { Plugin } from "ventojs/core/environment.js";
|
|
5
|
-
|
|
6
|
-
//#region node_modules/.pnpm/11ty.ts@0.0.7_@11ty+eleventy@3.1.2/node_modules/11ty.ts/dist/index.d.ts
|
|
7
|
-
declare global {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
9
|
-
interface SymbolConstructor {
|
|
10
|
-
readonly observable: symbol;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
15
|
-
|
|
16
|
-
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
17
|
-
|
|
18
|
-
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
19
|
-
|
|
20
|
-
@example
|
|
21
|
-
```
|
|
22
|
-
import type {LiteralUnion} from 'type-fest';
|
|
23
|
-
|
|
24
|
-
// Before
|
|
25
|
-
|
|
26
|
-
type Pet = 'dog' | 'cat' | string;
|
|
27
|
-
|
|
28
|
-
const pet: Pet = '';
|
|
29
|
-
// Start typing in your TypeScript-enabled IDE.
|
|
30
|
-
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
31
|
-
|
|
32
|
-
// After
|
|
33
|
-
|
|
34
|
-
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
35
|
-
|
|
36
|
-
const pet: Pet2 = '';
|
|
37
|
-
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
@category Type
|
|
41
|
-
*/
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/types/utilities.d.ts
|
|
44
|
-
/**
|
|
45
|
-
* Matches any given string so autocomplete in literal unions works as expected
|
|
46
|
-
*/
|
|
47
|
-
type AnyString = string & Record<never, never>;
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/types/eleventy.d.ts
|
|
50
|
-
interface UserConfig extends _UserConfig {
|
|
51
|
-
directories: {
|
|
52
|
-
input: string;
|
|
53
|
-
output: string;
|
|
54
|
-
includes: string;
|
|
55
|
-
layouts: string;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/types/options.d.ts
|
|
60
|
-
interface PluginOptions {
|
|
61
|
-
/**
|
|
62
|
-
* An array of Vento plugins
|
|
63
|
-
*/
|
|
64
|
-
plugins: Plugin[];
|
|
65
|
-
/**
|
|
66
|
-
* Enables Vento's autotrim plugin.
|
|
67
|
-
* @example
|
|
68
|
-
* // Set to an array of tags
|
|
69
|
-
* autotrim: ['tag1', 'tag2']
|
|
70
|
-
* @example
|
|
71
|
-
* // Use Vento's defaults and Eleventy paired shortcodes
|
|
72
|
-
* // Setting `true` is functionally equivalent to both
|
|
73
|
-
* // `@vento` and `@11ty` being present
|
|
74
|
-
* autotrim: ['@vento', '@11ty']
|
|
75
|
-
* autotrim: true
|
|
76
|
-
*/
|
|
77
|
-
autotrim: ('@11ty' | '@vento' | AnyString)[] | boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Enable use of Eleventy filters
|
|
80
|
-
*/
|
|
81
|
-
filters: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Enable use of Eleventy shortcodes
|
|
84
|
-
*/
|
|
85
|
-
shortcodes: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Enable use of Eleventy paired shortcodes
|
|
88
|
-
*/
|
|
89
|
-
pairedShortcodes: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* A Vento configuration object.
|
|
92
|
-
* @see {@link https://vento.js.org/configuration/}
|
|
93
|
-
* @default
|
|
94
|
-
* {
|
|
95
|
-
* // Defaults to Eleventy's own `includes` directory
|
|
96
|
-
* includes: eleventyConfig.directories.includes
|
|
97
|
-
* }
|
|
98
|
-
*/
|
|
99
|
-
ventoOptions: ventojs.Options;
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/plugin.d.ts
|
|
103
|
-
declare function VentoPlugin(eleventyConfig: UserConfig, userOptions?: Partial<PluginOptions>): void;
|
|
104
|
-
//#endregion
|
|
105
|
-
export { VentoPlugin };
|
package/dist/plugin.mjs
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import autotrimPlugin, { defaultTags } from "ventojs/plugins/auto_trim.js";
|
|
3
|
-
import createVentoEnv from "ventojs";
|
|
4
|
-
import { VentoError } from "ventojs/core/errors.js";
|
|
5
|
-
import { styleText } from "node:util";
|
|
6
|
-
import createDebugger from "debug";
|
|
7
|
-
//#region src/utils/create-vento-tag.ts
|
|
8
|
-
function createVentoTag(tagInfo) {
|
|
9
|
-
let LEVEL = 1;
|
|
10
|
-
const IS_PAIRED = tagInfo.group === "pairedShortcodes";
|
|
11
|
-
const tag = (env, token, output, tokens) => {
|
|
12
|
-
const code = token[1];
|
|
13
|
-
if (!(code === tagInfo.name || code.startsWith(`${tagInfo.name} `))) return;
|
|
14
|
-
const { dataVarname } = env.options;
|
|
15
|
-
const thisArg = `{
|
|
16
|
-
page: ${dataVarname}.page,
|
|
17
|
-
eleventy: ${dataVarname}.eleventy
|
|
18
|
-
}`;
|
|
19
|
-
const fn = `__env.utils.eleventyFunctions.${tagInfo.group}.${tagInfo.name}`;
|
|
20
|
-
const args = [code.replace(tagInfo.name, "").trim()];
|
|
21
|
-
const compiled = [];
|
|
22
|
-
if (IS_PAIRED) {
|
|
23
|
-
const nestedVarname = `__content${output.startsWith("__content") ? LEVEL++ : 0}`;
|
|
24
|
-
args.unshift(env.compileFilters(tokens, nestedVarname, env.options.autoescape));
|
|
25
|
-
compiled.push("{", `let ${nestedVarname} = "";`, ...env.compileTokens(tokens, nestedVarname, `/${tagInfo.name}`));
|
|
26
|
-
}
|
|
27
|
-
args.unshift(thisArg);
|
|
28
|
-
compiled.push("{", `const __result = await ${fn}.call(${args.filter(Boolean).join(", ")});`, `${output} += ${env.compileFilters(tokens, "__result", env.options.autoescape)}`, "}");
|
|
29
|
-
if (IS_PAIRED) compiled.push("}");
|
|
30
|
-
return compiled.join("\n");
|
|
31
|
-
};
|
|
32
|
-
return Object.defineProperty(tag, "name", { value: `${tagInfo.name}_${IS_PAIRED ? `EleventyPairedTag` : `EleventyTag`}` });
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/utils/logging.ts
|
|
36
|
-
const debug = {
|
|
37
|
-
main: createDebugger("Eleventy:Vento"),
|
|
38
|
-
get cache() {
|
|
39
|
-
return this.main.extend("Cache");
|
|
40
|
-
},
|
|
41
|
-
get render() {
|
|
42
|
-
return this.main.extend("Render");
|
|
43
|
-
},
|
|
44
|
-
get error() {
|
|
45
|
-
return this.main.extend("Error");
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
function warn(...messages) {
|
|
49
|
-
for (const message of messages) console.error(styleText("gray", "[warning]"), styleText("yellow", message));
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/utils/errors.ts
|
|
53
|
-
const LINE_TERMINATOR = /(\r\n?|[\n\u2028\u2029])/;
|
|
54
|
-
var EleventyVentoError = class extends Error {
|
|
55
|
-
constructor(message, context, cause) {
|
|
56
|
-
super(message, { cause });
|
|
57
|
-
this.context = context;
|
|
58
|
-
}
|
|
59
|
-
static async createFromContext(error) {
|
|
60
|
-
const ctx = await error.getContext();
|
|
61
|
-
const err = new this("An unknown error occured processing Vento templates", ctx, error);
|
|
62
|
-
if (ctx.position === void 0 || ctx.file === void 0) warn(`A \`${ctx.type}\` was thrown, but the exact position within the source code cannot be obtained`, "Use DEBUG=\"Eleventy:Vento*\" to view raw `ErrorContext` information");
|
|
63
|
-
debug.error("Received `ErrorContext` from Vento: %O", ctx);
|
|
64
|
-
if (ctx.file === void 0) return err;
|
|
65
|
-
err.message = `${ctx.type} in ${ctx.file}`;
|
|
66
|
-
if (ctx.position === void 0 || ctx.source === void 0) return err;
|
|
67
|
-
const sourceLines = codeToLines(ctx.source);
|
|
68
|
-
const [sourceLine, sourceColumn] = locateInCode(sourceLines, ctx.position);
|
|
69
|
-
err.message += `:${sourceLine}:${sourceColumn}:\n\n`;
|
|
70
|
-
const pad = sourceLine.toString().length;
|
|
71
|
-
const indent = " ".repeat(pad);
|
|
72
|
-
for (let line = Math.max(sourceLine - 3, 1); line <= sourceLine; line++) err.message += `${`${line}`.padStart(pad)} │ ${sourceLines[line - 1].trimEnd()}\n`;
|
|
73
|
-
err.message += `${indent} ${" ".repeat(sourceColumn - 1)}^`;
|
|
74
|
-
if (!ctx.code || ctx.line === void 0 || ctx.column === void 0) return err;
|
|
75
|
-
const codelines = codeToLines(ctx.code);
|
|
76
|
-
err.message += `\n\n${indent} │ /// compiled Vento function for ${ctx.file} ///\n${indent} │ ${codelines[ctx.line - 1].trimEnd()}\n${indent} ${" ".repeat(ctx.column - 1)}^`;
|
|
77
|
-
return err;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Converts a code string to an array of lines
|
|
82
|
-
*/
|
|
83
|
-
function codeToLines(code) {
|
|
84
|
-
const doubleLines = code.split(LINE_TERMINATOR);
|
|
85
|
-
const lines = [];
|
|
86
|
-
for (let i = 0; i < doubleLines.length; i += 2) lines.push(`${doubleLines[i]}${doubleLines[i + 1] ?? ""}`);
|
|
87
|
-
return lines;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Identifies the line/column location from a character index
|
|
91
|
-
*/
|
|
92
|
-
function locateInCode(lines, position) {
|
|
93
|
-
if (position < 0) return [1, 1];
|
|
94
|
-
let index = 0;
|
|
95
|
-
for (const [line, content] of lines.entries()) {
|
|
96
|
-
const { length } = content;
|
|
97
|
-
if (position < index + length) return [line + 1, position - index + 1];
|
|
98
|
-
index += length;
|
|
99
|
-
}
|
|
100
|
-
throw new Error(`Positon ${position} is out of bounds for the provided source`);
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/engine.ts
|
|
104
|
-
function createVentoEngine(options) {
|
|
105
|
-
const env = createVentoEnv(options);
|
|
106
|
-
env.utils.eleventyFunctions = {
|
|
107
|
-
shortcodes: {},
|
|
108
|
-
pairedShortcodes: {}
|
|
109
|
-
};
|
|
110
|
-
function loadPlugins(plugins) {
|
|
111
|
-
for (const plugin of plugins) env.use(plugin);
|
|
112
|
-
}
|
|
113
|
-
function loadFilters(filters) {
|
|
114
|
-
for (const [name, fn] of Object.entries(filters)) env.filters[name] = function(...args) {
|
|
115
|
-
const { page, eleventy } = this.data;
|
|
116
|
-
return fn.apply({
|
|
117
|
-
...this,
|
|
118
|
-
page,
|
|
119
|
-
eleventy
|
|
120
|
-
}, args);
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function loadShortcodes(shortcodes) {
|
|
124
|
-
for (const [name, fn] of Object.entries(shortcodes)) {
|
|
125
|
-
env.utils.eleventyFunctions.shortcodes[name] = fn;
|
|
126
|
-
const shortcodeTag = createVentoTag({
|
|
127
|
-
name,
|
|
128
|
-
group: "shortcodes"
|
|
129
|
-
});
|
|
130
|
-
env.tags.push(shortcodeTag);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function loadPairedShortcodes(pairedShortcodes) {
|
|
134
|
-
for (const [name, fn] of Object.entries(pairedShortcodes)) {
|
|
135
|
-
env.utils.eleventyFunctions.pairedShortcodes[name] = fn;
|
|
136
|
-
const shortcodeTag = createVentoTag({
|
|
137
|
-
name,
|
|
138
|
-
group: "pairedShortcodes"
|
|
139
|
-
});
|
|
140
|
-
env.tags.push(shortcodeTag);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async function getTemplateFunction(source, file, useVentoCache = true) {
|
|
144
|
-
let template = await env.cache.get(file);
|
|
145
|
-
if (template?.source === source) {
|
|
146
|
-
debug.cache("Cache HIT for `%s`, using precompiled template", file);
|
|
147
|
-
return template;
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
debug.cache("Cache MISS for `%s`, will compile new template function", file);
|
|
151
|
-
template = env.compile(source, file);
|
|
152
|
-
if (useVentoCache) env.cache.set(file, template);
|
|
153
|
-
return template;
|
|
154
|
-
} catch (error) {
|
|
155
|
-
if (error instanceof VentoError) throw await EleventyVentoError.createFromContext(error);
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
cache: env.cache,
|
|
161
|
-
loadPlugins,
|
|
162
|
-
loadFilters,
|
|
163
|
-
loadShortcodes,
|
|
164
|
-
loadPairedShortcodes,
|
|
165
|
-
getTemplateFunction
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
async function renderVentoTemplate(template, data, from) {
|
|
169
|
-
try {
|
|
170
|
-
debug.render("Rendering `%s`", from);
|
|
171
|
-
const { content } = await template(data);
|
|
172
|
-
return content;
|
|
173
|
-
} catch (error) {
|
|
174
|
-
if (error instanceof VentoError) throw await EleventyVentoError.createFromContext(error);
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/plugin.ts
|
|
180
|
-
function VentoPlugin(eleventyConfig, userOptions) {
|
|
181
|
-
debug.main("Initializing eleventy-plugin-vento");
|
|
182
|
-
eleventyConfig.versionCheck(">=3.0.0");
|
|
183
|
-
const options = {
|
|
184
|
-
autotrim: false,
|
|
185
|
-
plugins: [],
|
|
186
|
-
filters: true,
|
|
187
|
-
shortcodes: true,
|
|
188
|
-
pairedShortcodes: true,
|
|
189
|
-
ventoOptions: { includes: eleventyConfig.directories.includes },
|
|
190
|
-
...userOptions
|
|
191
|
-
};
|
|
192
|
-
debug.main("Merged default and user config: %O", options);
|
|
193
|
-
const filters = eleventyConfig.getFilters();
|
|
194
|
-
debug.main("Reading filters from Eleventy: %o", filters);
|
|
195
|
-
const shortcodes = eleventyConfig.getShortcodes();
|
|
196
|
-
debug.main("Reading shortcodes from Eleventy: %o", shortcodes);
|
|
197
|
-
const pairedShortcodes = eleventyConfig.getPairedShortcodes();
|
|
198
|
-
debug.main("Reading paired shortcodes from Eleventy: %o", pairedShortcodes);
|
|
199
|
-
if (options.autotrim) {
|
|
200
|
-
const tagSet = new Set(options.autotrim === true ? ["@vento", "@11ty"] : options.autotrim);
|
|
201
|
-
if (tagSet.has("@vento")) {
|
|
202
|
-
tagSet.delete("@vento");
|
|
203
|
-
for (const name of defaultTags) tagSet.add(name);
|
|
204
|
-
}
|
|
205
|
-
if (tagSet.has("@11ty")) {
|
|
206
|
-
tagSet.delete("@11ty");
|
|
207
|
-
for (const name in pairedShortcodes) tagSet.add(name);
|
|
208
|
-
}
|
|
209
|
-
debug.main("Enabled autotrim for tags: %o", tagSet);
|
|
210
|
-
options.plugins.push(autotrimPlugin({ tags: [...tagSet] }));
|
|
211
|
-
}
|
|
212
|
-
debug.main("Initializing Vento environment");
|
|
213
|
-
const engine = createVentoEngine(options.ventoOptions);
|
|
214
|
-
debug.main("Loading plugins: %o", options.plugins);
|
|
215
|
-
engine.loadPlugins(options.plugins);
|
|
216
|
-
if (options.filters) {
|
|
217
|
-
debug.main("Loading filters: %o", filters);
|
|
218
|
-
engine.loadFilters(filters);
|
|
219
|
-
}
|
|
220
|
-
if (options.shortcodes) {
|
|
221
|
-
debug.main("Loading shortcodes: %o", shortcodes);
|
|
222
|
-
engine.loadShortcodes(shortcodes);
|
|
223
|
-
}
|
|
224
|
-
if (options.pairedShortcodes) {
|
|
225
|
-
debug.main("Loading paired shortcodes: %o", pairedShortcodes);
|
|
226
|
-
engine.loadPairedShortcodes(pairedShortcodes);
|
|
227
|
-
}
|
|
228
|
-
debug.main("Registering Vento cache handler on eleventy.beforeWatch event");
|
|
229
|
-
eleventyConfig.on("eleventy.beforeWatch", async (updatedFiles) => {
|
|
230
|
-
for (let file of updatedFiles) {
|
|
231
|
-
file = path.normalize(file);
|
|
232
|
-
debug.cache("Delete cache entry for %s", file);
|
|
233
|
-
engine.cache.delete(file);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
debug.main("Registering .vto as a template format");
|
|
237
|
-
eleventyConfig.addTemplateFormats("vto");
|
|
238
|
-
debug.main("Registering .vto extension with eleventy");
|
|
239
|
-
eleventyConfig.addExtension("vto", {
|
|
240
|
-
outputFileExtension: "html",
|
|
241
|
-
read: true,
|
|
242
|
-
async compile(inputContent, inputPath) {
|
|
243
|
-
inputPath = path.normalize(inputPath);
|
|
244
|
-
debug.main("Getting template function for `%s`", inputPath);
|
|
245
|
-
const template = await engine.getTemplateFunction(inputContent, inputPath, false);
|
|
246
|
-
return async (data) => await renderVentoTemplate(template, data, inputPath);
|
|
247
|
-
},
|
|
248
|
-
compileOptions: { async permalink(permalinkContent, inputPath) {
|
|
249
|
-
if (typeof permalinkContent !== "string" || !/\{\{\s+.+\s+\}\}/.test(permalinkContent)) return permalinkContent;
|
|
250
|
-
inputPath = "EleventyVentoDynamicPermalink:".concat(path.normalize(inputPath));
|
|
251
|
-
debug.main("Getting template function for `%s`", inputPath);
|
|
252
|
-
const template = await engine.getTemplateFunction(permalinkContent, inputPath);
|
|
253
|
-
return async (data) => await renderVentoTemplate(template, data, inputPath);
|
|
254
|
-
} }
|
|
255
|
-
});
|
|
256
|
-
debug.main("eleventy-plugin-vento initialized");
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
export { VentoPlugin };
|