eleventy-plugin-vento 2.0.0-beta.1 → 2.0.0-beta.2

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
@@ -69,15 +69,13 @@ export function VentoPlugin(eleventyConfig, options = {}) {
69
69
  // Add autotrim plugin if enabled
70
70
  if (options.trimTags) env.use(autoTrim({ tags: options.trimTags || ventoDefaultTrimTags }));
71
71
 
72
- eleventyConfig.on('eleventy.before', () => {
73
- env.cache.clear();
74
- });
75
-
76
72
  // Add vto as a template format and create a custom template for it
77
73
  eleventyConfig.addTemplateFormats('vto');
78
74
  eleventyConfig.addExtension('vto', {
79
75
  outputFileExtension: 'html',
76
+
80
77
  async compile(inputContent, inputPath) {
78
+ env.cache.clear();
81
79
  return async (data) => {
82
80
  if (options.addHelpers) {
83
81
  // Extract a possible namespace from the addHelpers option
@@ -98,8 +96,21 @@ export function VentoPlugin(eleventyConfig, options = {}) {
98
96
  else data = { ...data, ...helperFunctions };
99
97
  }
100
98
 
101
- return await env.runString(inputContent, data, inputPath).then((result) => result.content);
99
+ const result = await env.runString(inputContent, data, inputPath);
100
+
101
+ return result.content;
102
102
  };
103
103
  },
104
+
105
+ compileOptions: {
106
+ permalink(linkContents, inputPath) {
107
+ console.log(linkContents);
108
+ if (!linkContents) return linkContents;
109
+ return async (data) => {
110
+ const result = await env.runString(linkContents, data, inputPath);
111
+ return result.content;
112
+ };
113
+ },
114
+ },
104
115
  });
105
116
  }
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.2",
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) }}