eleventy-plugin-vento 2.0.0-beta.1 → 2.0.0-beta.3
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/VentoPlugin.js +22 -7
- package/package.json +1 -1
- package/readme.md +2 -2
- package/test/input/directory-data/dir-data.vto +6 -0
- package/test/input/directory-data/directory-data.11tydata.json +3 -0
- package/test/input/eleventy.config.js +1 -1
- package/test/input/permalinks.vto +7 -0
- package/test/input/root.vto +6 -0
- package/test/input/with-shortcodes.vto +1 -1
package/VentoPlugin.js
CHANGED
|
@@ -63,21 +63,24 @@ export function VentoPlugin(eleventyConfig, options = {}) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// Load filters into vento
|
|
67
|
+
for (const filter in filters) {
|
|
68
|
+
env.filters[filter] = filters[filter];
|
|
69
|
+
}
|
|
70
|
+
|
|
66
71
|
// Load user-defined plugins into vento
|
|
67
72
|
for (const plugin of options.plugins) env.use(plugin);
|
|
68
73
|
|
|
69
74
|
// Add autotrim plugin if enabled
|
|
70
75
|
if (options.trimTags) env.use(autoTrim({ tags: options.trimTags || ventoDefaultTrimTags }));
|
|
71
76
|
|
|
72
|
-
eleventyConfig.on('eleventy.before', () => {
|
|
73
|
-
env.cache.clear();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
77
|
// Add vto as a template format and create a custom template for it
|
|
77
78
|
eleventyConfig.addTemplateFormats('vto');
|
|
78
79
|
eleventyConfig.addExtension('vto', {
|
|
79
80
|
outputFileExtension: 'html',
|
|
81
|
+
|
|
80
82
|
async compile(inputContent, inputPath) {
|
|
83
|
+
env.cache.clear();
|
|
81
84
|
return async (data) => {
|
|
82
85
|
if (options.addHelpers) {
|
|
83
86
|
// Extract a possible namespace from the addHelpers option
|
|
@@ -89,8 +92,8 @@ export function VentoPlugin(eleventyConfig, options = {}) {
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
// Rebind filters the same way
|
|
92
|
-
for (const filter in filters) {
|
|
93
|
-
env.filters[filter] = filters[filter].bind(data);
|
|
95
|
+
for (const filter in env.filters) {
|
|
96
|
+
env.filters[filter] = env.filters[filter].bind(data);
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
// Merge helpers into page data
|
|
@@ -98,8 +101,20 @@ export function VentoPlugin(eleventyConfig, options = {}) {
|
|
|
98
101
|
else data = { ...data, ...helperFunctions };
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
|
|
104
|
+
const result = await env.runString(inputContent, data, inputPath);
|
|
105
|
+
|
|
106
|
+
return result.content;
|
|
102
107
|
};
|
|
103
108
|
},
|
|
109
|
+
|
|
110
|
+
compileOptions: {
|
|
111
|
+
permalink(linkContents, inputPath) {
|
|
112
|
+
if (!linkContents) return linkContents;
|
|
113
|
+
return async (data) => {
|
|
114
|
+
const result = await env.runString(linkContents, data, inputPath);
|
|
115
|
+
return result.content;
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
},
|
|
104
119
|
});
|
|
105
120
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -5,7 +5,7 @@ An [Eleventy](https://11ty.dev/) plugin that adds support for [Vento](https://ve
|
|
|
5
5
|
[Installing](#installing)<br>
|
|
6
6
|
[Usage](#usage)<br>
|
|
7
7
|
[Plugin Options](#plugin-options)<br>
|
|
8
|
-
[
|
|
8
|
+
[Filters](#filters)<br>
|
|
9
9
|
[Vento Plugins](#vento-plugins)<br>
|
|
10
10
|
[Auto-Trimming Tags](#auto-trimming-tags)<br>
|
|
11
11
|
[JavaScript Helpers](#javascript-helpers)<br>
|
|
@@ -49,7 +49,7 @@ export default function (eleventyConfig) {
|
|
|
49
49
|
addHelpers: true,
|
|
50
50
|
|
|
51
51
|
// Define tags that should be trimmed, or set to true
|
|
52
|
-
// to trim the default tags
|
|
52
|
+
// to trim the default tags (see section on Auto-trimming)
|
|
53
53
|
trimTags: [],
|
|
54
54
|
|
|
55
55
|
// A Vento configuration object
|
|
@@ -19,5 +19,5 @@ export default async function (eleventyConfig) {
|
|
|
19
19
|
trimTags: [...ventoDefaultTrimTags, 'for'],
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
eleventyConfig.addShortcode('possumPosse', () =>
|
|
22
|
+
eleventyConfig.addShortcode('possumPosse', (number = 'the') => `Release ${number} possums!!!`);
|
|
23
23
|
}
|