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 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
- return await env.runString(inputContent, data, inputPath).then((result) => result.content);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-vento",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "Adds support for the Vento templating language to Eleventy.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@9.1.4",
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
- [Vento Filters](#vento-filters)<br>
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
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Directory data test page
3
+ layout: page-layout.vto
4
+ ---
5
+
6
+ This page has directory data set with dynamic permalinks
@@ -0,0 +1,3 @@
1
+ {
2
+ "permalink": "/{{ title |> slugify }}.html"
3
+ }
@@ -19,5 +19,5 @@ export default async function (eleventyConfig) {
19
19
  trimTags: [...ventoDefaultTrimTags, 'for'],
20
20
  });
21
21
 
22
- eleventyConfig.addShortcode('possumPosse', () => 'Release the possums!!!');
22
+ eleventyConfig.addShortcode('possumPosse', (number = 'the') => `Release ${number} possums!!!`);
23
23
  }
@@ -0,0 +1,7 @@
1
+ ---
2
+ permalink: /test/page/permalink/
3
+ title: Test page
4
+ layout: page-layout.vto
5
+ ---
6
+
7
+ This content lives at `/test/page/permalink/`
@@ -0,0 +1,6 @@
1
+ ---
2
+ permalink: /
3
+ layout: page-layout.vto
4
+ ---
5
+
6
+ This should render on the homepage.
@@ -3,4 +3,4 @@ title: Page with shortcodes
3
3
  layout: page-layout.vto
4
4
  ---
5
5
 
6
- {{ possumPosse() }}
6
+ {{ possumPosse(32) }}