eleventy-plugin-vento 4.1.0 → 4.1.1
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 +61 -0
- package/dist/{index.d.ts → plugin.d.ts} +11 -15
- package/dist/{index.js → plugin.js} +77 -76
- package/package.json +18 -17
- package/readme.md +4 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# eleventy-plugin-vento
|
|
2
2
|
|
|
3
|
+
## 4.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 335f21e: Select type updates (shouldn't affect compilation, however should improve DX)
|
|
8
|
+
|
|
9
|
+
Changes are:
|
|
10
|
+
|
|
11
|
+
- split types into separate files
|
|
12
|
+
- namespace `ventojs` type imports
|
|
13
|
+
- make `PluginOptions` optional by default
|
|
14
|
+
- make Eleventy types more readable
|
|
15
|
+
- declare a special (`EleventyVentoEnvironment`) for this plugin to replace Vento's own `Environment`
|
|
16
|
+
|
|
17
|
+
- 070109a: Refactored files and functions internally that shouldn't have any impact on usage or performance:
|
|
18
|
+
|
|
19
|
+
- Split `debug` functions into separate exports, renamed `runCompatiblityCheck -> compatibilityCheck` (dd4c379b)
|
|
20
|
+
- Utilities are now split into separate files (e06a83ab)
|
|
21
|
+
- Main file renamed from `index.ts` to `plugin.ts` (1b122d2a)
|
|
22
|
+
|
|
23
|
+
- c382be0: Wrap all filters as regular synchronous functions to avoid ambiguity with sync and async handling. (fixes #96)
|
|
24
|
+
|
|
25
|
+
This change enforces explicit use of the `await` keyword to unwrap returned values from filters before chaining more or printing the result.
|
|
26
|
+
|
|
27
|
+
```diff
|
|
28
|
+
<!-- Single filters -->
|
|
29
|
+
- {{ "Hello, async!" |> someAsyncFilter }}
|
|
30
|
+
+ {{ "Hello, async!" |> await someAsyncFilter }}
|
|
31
|
+
|
|
32
|
+
<!-- Filter chains -->
|
|
33
|
+
- {{ "Hello, async!" |> someAsyncFilter |> someSyncFilter }}
|
|
34
|
+
+ {{ "Hello, async!" |> await someAsyncFilter |> someSyncFilter }}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
See the [Vento docs on async chains](https://vento.js.org/syntax/pipes/#chain-pipes) for more information.
|
|
38
|
+
|
|
39
|
+
- 9eaa059: Update `debug` to v4.4.0
|
|
40
|
+
- 0b0f96a: Update ventojs to v1.12.14
|
|
41
|
+
|
|
42
|
+
## 4.1.1-beta.0
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 335f21e: Select type updates (shouldn't affect compilation, however should improve DX)
|
|
47
|
+
|
|
48
|
+
Changes are:
|
|
49
|
+
|
|
50
|
+
- split types into separate files
|
|
51
|
+
- namespace `ventojs` type imports
|
|
52
|
+
- make `PluginOptions` optional by default
|
|
53
|
+
- make Eleventy types more readable
|
|
54
|
+
- declare a special (`EleventyVentoEnvironment`) for this plugin to replace Vento's own `Environment`
|
|
55
|
+
|
|
56
|
+
- 9eaa059: Update `debug` to v4.4.0
|
|
57
|
+
- f387b5e: Update `ventojs` to v1.12.13
|
|
58
|
+
- 070109a: Refactored files and functions internally that shouldn't have any impact on usage or performance:
|
|
59
|
+
|
|
60
|
+
- Split `debug` functions into separate exports, renamed `runCompatiblityCheck -> compatibilityCheck` (dd4c379b)
|
|
61
|
+
- Utilities are now split into separate files (e06a83ab)
|
|
62
|
+
- Main file renamed from `index.ts` to `plugin.ts` (1b122d2a)
|
|
63
|
+
|
|
3
64
|
## 4.1.0
|
|
4
65
|
|
|
5
66
|
### Minor Changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import UserConfig from '@11ty/eleventy/UserConfig';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import * as ventojs from 'ventojs';
|
|
3
4
|
import { Plugin } from 'ventojs/src/environment.js';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
interface VentoPluginOptions {
|
|
6
|
+
interface PluginOptions {
|
|
7
7
|
/**
|
|
8
8
|
* An array of Vento plugins
|
|
9
9
|
*/
|
|
10
|
-
plugins
|
|
10
|
+
plugins?: Plugin[];
|
|
11
11
|
/**
|
|
12
12
|
* Enables Vento's autotrim plugin.
|
|
13
13
|
* ```js
|
|
@@ -20,13 +20,13 @@ interface VentoPluginOptions {
|
|
|
20
20
|
* autotrim: true
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
autotrim
|
|
23
|
+
autotrim?: LiteralUnion<'@11ty' | '@vento', string>[] | boolean;
|
|
24
24
|
/** Enable use of Eleventy filters */
|
|
25
|
-
filters
|
|
25
|
+
filters?: boolean;
|
|
26
26
|
/** Enable use of Eleventy shortcodes */
|
|
27
|
-
shortcodes
|
|
27
|
+
shortcodes?: boolean;
|
|
28
28
|
/** Enable use of Eleventy paired shortcodes */
|
|
29
|
-
pairedShortcodes
|
|
29
|
+
pairedShortcodes?: boolean;
|
|
30
30
|
/**
|
|
31
31
|
* A Vento configuration object.
|
|
32
32
|
*
|
|
@@ -34,13 +34,9 @@ interface VentoPluginOptions {
|
|
|
34
34
|
* Eleventy's own `dir.includes` location.**
|
|
35
35
|
* @see {@link https://vento.js.org/configuration/}
|
|
36
36
|
*/
|
|
37
|
-
ventoOptions
|
|
37
|
+
ventoOptions?: ventojs.Options;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
* @file Main plugin declaration
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
declare function VentoPlugin(eleventyConfig: UserConfig, userOptions: Partial<VentoPluginOptions>): void;
|
|
40
|
+
declare function VentoPlugin(eleventyConfig: UserConfig, userOptions: PluginOptions): void;
|
|
45
41
|
|
|
46
42
|
export { VentoPlugin };
|
|
@@ -1,88 +1,65 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/plugin.ts
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import autotrimPlugin, { defaultTags as autotrimDefaultTags } from "ventojs/plugins/auto_trim.js";
|
|
4
4
|
|
|
5
5
|
// src/engine.ts
|
|
6
|
-
import
|
|
6
|
+
import createVentoEnv from "ventojs";
|
|
7
7
|
|
|
8
|
-
// src/create-vento-tag.ts
|
|
9
|
-
function createVentoTag(
|
|
10
|
-
const IS_PAIRED =
|
|
8
|
+
// src/utils/create-vento-tag.ts
|
|
9
|
+
function createVentoTag(tagInfo) {
|
|
10
|
+
const IS_PAIRED = tagInfo.group === "pairedShortcodes";
|
|
11
|
+
let INT = 0;
|
|
11
12
|
const tag = (env, code, output, tokens) => {
|
|
12
|
-
if (!code.startsWith(
|
|
13
|
+
if (!code.startsWith(tagInfo.name)) return;
|
|
13
14
|
const { dataVarname } = env.options;
|
|
14
15
|
const thisArg = `{
|
|
15
16
|
page: ${dataVarname}.page,
|
|
16
17
|
eleventy: ${dataVarname}.eleventy
|
|
17
18
|
}`;
|
|
18
|
-
const fn = `__env.utils.eleventyFunctions.${
|
|
19
|
-
const args = [code.replace(
|
|
20
|
-
const varname = output.startsWith("__shortcode_content") ? `${output}_precomp` : "__shortcode_content";
|
|
19
|
+
const fn = `__env.utils.eleventyFunctions.${tagInfo.group}.${tagInfo.name}`;
|
|
20
|
+
const args = [code.replace(tagInfo.name, "").trim()];
|
|
21
21
|
const compiled = [];
|
|
22
22
|
if (IS_PAIRED) {
|
|
23
|
-
|
|
23
|
+
const nestedVarname = `__arg${INT++}`;
|
|
24
|
+
args.unshift(env.compileFilters(tokens, nestedVarname, env.options.autoescape));
|
|
24
25
|
compiled.push(
|
|
25
26
|
"{",
|
|
26
|
-
`let ${
|
|
27
|
-
...env.compileTokens(tokens,
|
|
27
|
+
`let ${nestedVarname} = "";`,
|
|
28
|
+
...env.compileTokens(tokens, nestedVarname, [`/${tagInfo.name}`])
|
|
28
29
|
);
|
|
29
|
-
if (tokens.length > 0 && (tokens[0][0] !== "tag" || tokens[0][1] !== `/${
|
|
30
|
-
throw new Error(`Vento: Missing closing tag for ${
|
|
30
|
+
if (tokens.length > 0 && (tokens[0][0] !== "tag" || tokens[0][1] !== `/${tagInfo.name}`)) {
|
|
31
|
+
throw new Error(`Vento: Missing closing tag for ${tagInfo.name} tag: ${code}`);
|
|
31
32
|
}
|
|
32
33
|
tokens.shift();
|
|
33
34
|
}
|
|
34
35
|
args.unshift(thisArg);
|
|
35
36
|
compiled.push(
|
|
36
37
|
"{",
|
|
37
|
-
`const
|
|
38
|
-
`${output} += ${env.compileFilters(tokens, "
|
|
38
|
+
`const __result = await ${fn}.call(${args.filter(Boolean).join(", ")});`,
|
|
39
|
+
`${output} += ${env.compileFilters(tokens, "__result", env.options.autoescape)}`,
|
|
39
40
|
"}"
|
|
40
41
|
);
|
|
41
42
|
if (IS_PAIRED) {
|
|
42
43
|
compiled.push("}");
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
return compiledTag;
|
|
45
|
+
return compiled.join("\n");
|
|
46
46
|
};
|
|
47
47
|
return Object.defineProperty(tag, "name", {
|
|
48
|
-
value:
|
|
48
|
+
value: `${tagInfo.name}_${IS_PAIRED ? `EleventyPairedTag` : `EleventyTag`}`
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// src/utils.ts
|
|
52
|
+
// src/utils/debuggers.ts
|
|
53
53
|
import createDebugger from "debug";
|
|
54
54
|
var debugBaseNamespace = "Eleventy:Vento";
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
render: createDebugger(`${debugBaseNamespace}:Render`)
|
|
59
|
-
};
|
|
60
|
-
var REQUIRED_API_METHODS = [
|
|
61
|
-
["getShortcodes", "v3.0.0-alpha.15"],
|
|
62
|
-
["getPairedShortcodes", "v3.0.0-alpha.15"],
|
|
63
|
-
["getFilters", "v3.0.0-alpha.15"],
|
|
64
|
-
["addExtension", "v1.0.0"]
|
|
65
|
-
];
|
|
66
|
-
function runCompatibilityCheck(config) {
|
|
67
|
-
DEBUG.main("Run compatibility check");
|
|
68
|
-
for (const [method, version] of REQUIRED_API_METHODS) {
|
|
69
|
-
if (!(method in config)) {
|
|
70
|
-
console.error(
|
|
71
|
-
"[eleventy-plugin-vento] Plugin compatibility error:",
|
|
72
|
-
`\`${method}\``,
|
|
73
|
-
"not found. Please use Eleventy",
|
|
74
|
-
version,
|
|
75
|
-
"or later."
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
55
|
+
var debugMain = createDebugger(debugBaseNamespace);
|
|
56
|
+
var debugCache = createDebugger(`${debugBaseNamespace}:Cache`);
|
|
57
|
+
var debugRender = createDebugger(`${debugBaseNamespace}:Render`);
|
|
80
58
|
|
|
81
59
|
// src/engine.ts
|
|
82
60
|
function createVentoEngine(options) {
|
|
83
|
-
const env =
|
|
61
|
+
const env = createVentoEnv(options);
|
|
84
62
|
env.utils.eleventyFunctions = { shortcodes: {}, pairedShortcodes: {} };
|
|
85
|
-
env.utils._11tyCtx = {};
|
|
86
63
|
function loadPlugins(plugins) {
|
|
87
64
|
for (const plugin of plugins) {
|
|
88
65
|
env.use(plugin);
|
|
@@ -90,31 +67,33 @@ function createVentoEngine(options) {
|
|
|
90
67
|
}
|
|
91
68
|
function loadFilters(filters) {
|
|
92
69
|
for (const [name, fn] of Object.entries(filters)) {
|
|
93
|
-
env.filters[name] =
|
|
94
|
-
|
|
95
|
-
return
|
|
70
|
+
env.filters[name] = function(...args) {
|
|
71
|
+
const { page, eleventy } = this.data;
|
|
72
|
+
return fn.apply({ ...this, page, eleventy }, args);
|
|
96
73
|
};
|
|
97
74
|
}
|
|
98
75
|
}
|
|
99
76
|
function loadShortcodes(shortcodes) {
|
|
100
77
|
for (const [name, fn] of Object.entries(shortcodes)) {
|
|
101
78
|
env.utils.eleventyFunctions.shortcodes[name] = fn;
|
|
102
|
-
|
|
79
|
+
const shortcodeTag = createVentoTag({ name, group: "shortcodes" });
|
|
80
|
+
env.tags.push(shortcodeTag);
|
|
103
81
|
}
|
|
104
82
|
}
|
|
105
83
|
function loadPairedShortcodes(pairedShortcodes) {
|
|
106
84
|
for (const [name, fn] of Object.entries(pairedShortcodes)) {
|
|
107
85
|
env.utils.eleventyFunctions.pairedShortcodes[name] = fn;
|
|
108
|
-
|
|
86
|
+
const shortcodeTag = createVentoTag({ name, group: "pairedShortcodes" });
|
|
87
|
+
env.tags.push(shortcodeTag);
|
|
109
88
|
}
|
|
110
89
|
}
|
|
111
90
|
function getTemplateFunction(source, file, useVentoCache = true) {
|
|
112
91
|
let template = env.cache.get(file);
|
|
113
|
-
if (template
|
|
114
|
-
|
|
92
|
+
if ((template == null ? void 0 : template.source) === source) {
|
|
93
|
+
debugCache("Cache HIT for `%s`, used precompiled template", file);
|
|
115
94
|
} else {
|
|
116
95
|
template = env.compile(source, file);
|
|
117
|
-
|
|
96
|
+
debugCache(
|
|
118
97
|
`Cache MISS for \`%s\`, compiled new template:
|
|
119
98
|
Use Vento cache: %o
|
|
120
99
|
|
|
@@ -138,15 +117,37 @@ ${template}`,
|
|
|
138
117
|
};
|
|
139
118
|
}
|
|
140
119
|
async function renderVentoTemplate(template, data, from) {
|
|
141
|
-
|
|
120
|
+
debugRender("Rendering `%s`", from);
|
|
142
121
|
const { content } = await template(data);
|
|
143
122
|
return content;
|
|
144
123
|
}
|
|
145
124
|
|
|
146
|
-
// src/
|
|
125
|
+
// src/utils/compat-check.ts
|
|
126
|
+
var REQUIRED_API_METHODS = [
|
|
127
|
+
["getShortcodes", "v3.0.0-alpha.15"],
|
|
128
|
+
["getPairedShortcodes", "v3.0.0-alpha.15"],
|
|
129
|
+
["getFilters", "v3.0.0-alpha.15"],
|
|
130
|
+
["addExtension", "v1.0.0"]
|
|
131
|
+
];
|
|
132
|
+
function compatibilityCheck(config) {
|
|
133
|
+
debugMain("Run compatibility check");
|
|
134
|
+
for (const [method, version] of REQUIRED_API_METHODS) {
|
|
135
|
+
if (!(method in config)) {
|
|
136
|
+
console.error(
|
|
137
|
+
"[eleventy-plugin-vento] Plugin compatibility error:",
|
|
138
|
+
`\`${method}\``,
|
|
139
|
+
"not found. Please use Eleventy",
|
|
140
|
+
version,
|
|
141
|
+
"or later."
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/plugin.ts
|
|
147
148
|
function VentoPlugin(eleventyConfig, userOptions) {
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
debugMain("Initializing eleventy-plugin-vento");
|
|
150
|
+
compatibilityCheck(eleventyConfig);
|
|
150
151
|
const options = {
|
|
151
152
|
// Define defaults
|
|
152
153
|
autotrim: false,
|
|
@@ -160,13 +161,13 @@ function VentoPlugin(eleventyConfig, userOptions) {
|
|
|
160
161
|
// Merge in user-provided options
|
|
161
162
|
...userOptions
|
|
162
163
|
};
|
|
163
|
-
|
|
164
|
+
debugMain("Merged default and user config: %O", options);
|
|
164
165
|
const filters = eleventyConfig.getFilters();
|
|
165
|
-
|
|
166
|
+
debugMain("Reading filters from Eleventy: %o", filters);
|
|
166
167
|
const shortcodes = eleventyConfig.getShortcodes();
|
|
167
|
-
|
|
168
|
+
debugMain("Reading shortcodes from Eleventy: %o", shortcodes);
|
|
168
169
|
const pairedShortcodes = eleventyConfig.getPairedShortcodes();
|
|
169
|
-
|
|
170
|
+
debugMain("Reading paired shortcodes from Eleventy: %o", pairedShortcodes);
|
|
170
171
|
if (options.autotrim) {
|
|
171
172
|
const defaults = ["@vento", "@11ty"];
|
|
172
173
|
const tagSet = new Set(options.autotrim === true ? defaults : options.autotrim);
|
|
@@ -182,42 +183,42 @@ function VentoPlugin(eleventyConfig, userOptions) {
|
|
|
182
183
|
tagSet.add(name);
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
|
-
|
|
186
|
+
debugMain("Enabled autotrim for tags: %o", tagSet);
|
|
186
187
|
options.plugins.push(autotrimPlugin({ tags: [...tagSet] }));
|
|
187
188
|
}
|
|
188
|
-
|
|
189
|
+
debugMain("Initializing Vento environment");
|
|
189
190
|
const engine = createVentoEngine(options.ventoOptions);
|
|
190
|
-
|
|
191
|
+
debugMain("Loading plugins: %o", options.plugins);
|
|
191
192
|
engine.loadPlugins(options.plugins);
|
|
192
193
|
if (options.filters) {
|
|
193
|
-
|
|
194
|
+
debugMain("Loading filters: %o", filters);
|
|
194
195
|
engine.loadFilters(filters);
|
|
195
196
|
}
|
|
196
197
|
if (options.shortcodes) {
|
|
197
|
-
|
|
198
|
+
debugMain("Loading shortcodes: %o", shortcodes);
|
|
198
199
|
engine.loadShortcodes(shortcodes);
|
|
199
200
|
}
|
|
200
201
|
if (options.pairedShortcodes) {
|
|
201
|
-
|
|
202
|
+
debugMain("Loading paired shortcodes: %o", pairedShortcodes);
|
|
202
203
|
engine.loadPairedShortcodes(pairedShortcodes);
|
|
203
204
|
}
|
|
204
|
-
|
|
205
|
+
debugMain("Registering Vento cache handler on eleventy.beforeWatch event");
|
|
205
206
|
eleventyConfig.on("eleventy.beforeWatch", async (updatedFiles) => {
|
|
206
207
|
for (let file of updatedFiles) {
|
|
207
208
|
file = path.normalize(file);
|
|
208
|
-
|
|
209
|
+
debugCache("Delete cache entry for %s", file);
|
|
209
210
|
engine.cache.delete(file);
|
|
210
211
|
}
|
|
211
212
|
});
|
|
212
|
-
|
|
213
|
+
debugMain("Registering .vto as a template format");
|
|
213
214
|
eleventyConfig.addTemplateFormats("vto");
|
|
214
|
-
|
|
215
|
+
debugMain("Registering .vto extension with eleventy");
|
|
215
216
|
eleventyConfig.addExtension("vto", {
|
|
216
217
|
outputFileExtension: "html",
|
|
217
218
|
read: true,
|
|
218
219
|
compile(inputContent, inputPath) {
|
|
219
220
|
inputPath = path.normalize(inputPath);
|
|
220
|
-
|
|
221
|
+
debugMain("Getting template function for `%s`", inputPath);
|
|
221
222
|
const template = engine.getTemplateFunction(inputContent, inputPath, false);
|
|
222
223
|
return async (data) => await renderVentoTemplate(template, data, inputPath);
|
|
223
224
|
},
|
|
@@ -228,13 +229,13 @@ function VentoPlugin(eleventyConfig, userOptions) {
|
|
|
228
229
|
return permalinkContent;
|
|
229
230
|
}
|
|
230
231
|
inputPath = "Permalink::" + path.normalize(inputPath);
|
|
231
|
-
|
|
232
|
+
debugMain("Getting template function for `%s`", inputPath);
|
|
232
233
|
const template = engine.getTemplateFunction(permalinkContent, inputPath);
|
|
233
234
|
return async (data) => await renderVentoTemplate(template, data, inputPath);
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
});
|
|
237
|
-
|
|
238
|
+
debugMain("eleventy-plugin-vento initialized");
|
|
238
239
|
}
|
|
239
240
|
export {
|
|
240
241
|
VentoPlugin
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eleventy-plugin-vento",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Adds support for the Vento templating language to Eleventy.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18"
|
|
8
8
|
},
|
|
9
|
-
"types": "./dist/
|
|
9
|
+
"types": "./dist/plugin.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"import": "./dist/
|
|
13
|
-
"types": "./dist/
|
|
12
|
+
"import": "./dist/plugin.js",
|
|
13
|
+
"types": "./dist/plugin.d.ts"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
@@ -36,25 +36,27 @@
|
|
|
36
36
|
},
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"debug": "4.
|
|
40
|
-
"ventojs": "1.12.
|
|
39
|
+
"debug": "4.4.0",
|
|
40
|
+
"ventojs": "1.12.14"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"11ty.ts": "0.0.5",
|
|
44
|
-
"@11ty/eleventy": "3.0.
|
|
45
|
-
"@changesets/cli": "2.27.
|
|
46
|
-
"@eslint/js": "9.
|
|
44
|
+
"@11ty/eleventy": "3.0.1-alpha.1",
|
|
45
|
+
"@changesets/cli": "2.27.11",
|
|
46
|
+
"@eslint/js": "9.17.0",
|
|
47
47
|
"@types/debug": "4.1.12",
|
|
48
48
|
"@types/eslint-config-prettier": "6.11.3",
|
|
49
49
|
"@types/eslint__js": "8.42.3",
|
|
50
|
-
"@types/node": "22.
|
|
51
|
-
"eslint": "9.
|
|
50
|
+
"@types/node": "22.10.5",
|
|
51
|
+
"eslint": "9.17.0",
|
|
52
52
|
"eslint-config-prettier": "9.1.0",
|
|
53
53
|
"eslint-plugin-unicorn": "56.0.1",
|
|
54
|
+
"globals": "15.14.0",
|
|
54
55
|
"tsup": "8.3.5",
|
|
56
|
+
"type-fest": "4.31.0",
|
|
55
57
|
"typescript": "5.7.2",
|
|
56
|
-
"typescript-eslint": "8.
|
|
57
|
-
"vitest": "2.1.
|
|
58
|
+
"typescript-eslint": "8.19.0",
|
|
59
|
+
"vitest": "2.1.8"
|
|
58
60
|
},
|
|
59
61
|
"prettier": {
|
|
60
62
|
"bracketSameLine": true,
|
|
@@ -64,14 +66,13 @@
|
|
|
64
66
|
},
|
|
65
67
|
"scripts": {
|
|
66
68
|
"test": "vitest --run",
|
|
67
|
-
"check": "pnpm --color run '
|
|
68
|
-
"lint": "eslint '.'",
|
|
69
|
-
"
|
|
69
|
+
"check": "pnpm --color run '/^check:/'",
|
|
70
|
+
"check:lint": "eslint '.'",
|
|
71
|
+
"check:types": "tsc --noEmit",
|
|
70
72
|
"build": "tsup",
|
|
71
73
|
"dev": "tsup --watch ./src",
|
|
72
74
|
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
|
|
73
75
|
"ci:publish": "changeset publish",
|
|
74
|
-
"ci:generate-changesets": "node ./scripts/generate-changesets.js",
|
|
75
76
|
"format": "pnpm dlx prettier --config ./package.json --write ."
|
|
76
77
|
}
|
|
77
78
|
}
|
package/readme.md
CHANGED
|
@@ -62,9 +62,6 @@ export default function (eleventyConfig) {
|
|
|
62
62
|
// to trim the default tags (see section on Auto-trimming)
|
|
63
63
|
autotrim: false,
|
|
64
64
|
|
|
65
|
-
// Enable/disable ignore tag syntax (see section on ignoring tags)
|
|
66
|
-
ignoreTag: false,
|
|
67
|
-
|
|
68
65
|
// A Vento configuration object
|
|
69
66
|
ventoOptions: {
|
|
70
67
|
includes: eleventyConfig.directories.includes,
|
|
@@ -92,27 +89,9 @@ If you'd prefer to set filters yourself (via a plugin or other method) or preven
|
|
|
92
89
|
|
|
93
90
|
### Filters and `this`
|
|
94
91
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
{
|
|
99
|
-
env, // Vento environment
|
|
100
|
-
data, // all template global data
|
|
101
|
-
page, // this.page
|
|
102
|
-
eleventy, // this.eleventy
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
This feature enables re-use of the Vento environment this plugin provides, within Eleventy filters. As an example use case, you could create a filter that compiles dynamic data and cache it with Vento's own cache:
|
|
107
|
-
|
|
108
|
-
```js
|
|
109
|
-
eleventyConfig.addFilter('vento', function (content) {
|
|
110
|
-
const res = this.env.runString(content, this.data);
|
|
111
|
-
return res.content;
|
|
112
|
-
});
|
|
113
|
-
```
|
|
92
|
+
Eleventy provides filters with scoped data via the `this.page` and `this.eleventy` objects (see [Filters#Scoped data in Filters](https://www.11ty.dev/docs/filters/#scoped-data-in-filters) in Eleventy's docs for more details). Likewise, Vento provides filters with `this.env` and `this.data` representing the Vento environment and the current template data. This plugin merges both objects together to make `this.page` (and `eleventy`/`env`/`data`) available on all filters processed by Vento.
|
|
114
93
|
|
|
115
|
-
|
|
94
|
+
This feature enables re-use of the Vento environment this plugin provides, within Eleventy filters. As an example use case, you could create a filter that compiles dynamic data and cache it with Vento's own cache to improve performance:
|
|
116
95
|
|
|
117
96
|
```js
|
|
118
97
|
import 'hash' from 'node:crypto'; // since Node v20.12.0
|
|
@@ -180,7 +159,8 @@ Eleventy: See [Shortcodes](https://www.11ty.dev/docs/shortcodes/) and the sub-se
|
|
|
180
159
|
|
|
181
160
|
## Vento Plugins
|
|
182
161
|
|
|
183
|
-
|
|
162
|
+
> [!NOTE]
|
|
163
|
+
> The `auto_trim` plugin that ships with Vento has a specific implementation in the scope of this plugin. See [Auto-Trimming Tags](#auto-trimming-tags) for more details.\_
|
|
184
164
|
|
|
185
165
|
If you'd like to extend the Vento library with any plugins, include them in an array passed to the `plugins` option.
|
|
186
166
|
|