eleventy-plugin-vento 2.4.0 → 2.6.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/VentoPlugin.js CHANGED
@@ -82,8 +82,13 @@ export function VentoPlugin(eleventyConfig, options = {}) {
82
82
  // Add vto as a template format and create a custom template for it
83
83
  eleventyConfig.addTemplateFormats('vto');
84
84
  eleventyConfig.addExtension('vto', {
85
+ // Set output extension
85
86
  outputFileExtension: 'html',
86
87
 
88
+ // Read vto files into eleventy
89
+ read: true,
90
+
91
+ // Main compile function
87
92
  async compile(inputContent, inputPath) {
88
93
  return async (data) => {
89
94
  if (options.addHelpers) {
@@ -113,11 +118,16 @@ export function VentoPlugin(eleventyConfig, options = {}) {
113
118
 
114
119
  const result = await env.runString(inputContent, data, inputPath);
115
120
 
121
+ if (data.page?.rawInput !== inputContent) {
122
+ env.cache.delete(inputPath);
123
+ }
124
+
116
125
  return result.content;
117
126
  };
118
127
  },
119
128
 
120
129
  compileOptions: {
130
+ // Custom permalink compilation
121
131
  permalink(linkContents) {
122
132
  if (typeof linkContents !== 'string') return linkContents;
123
133
  return async (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-vento",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "Adds support for the Vento templating language to Eleventy.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@9.5.0",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "license": "MIT",
38
38
  "dependencies": {
39
- "ventojs": "0.12.8"
39
+ "ventojs": "0.12.9"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@11ty/eleventy": "3.0.0-alpha.14",
@@ -46,7 +46,7 @@
46
46
  "eslint-config-prettier": "9.1.0",
47
47
  "globals": "15.8.0",
48
48
  "semantic-release": "24.0.0",
49
- "vitest": "1.6.0"
49
+ "vitest": "2.0.2"
50
50
  },
51
51
  "prettier": {
52
52
  "bracketSameLine": true,
@@ -0,0 +1,4 @@
1
+
2
+ <h1>Dynamically generated from a custom key</h1>
3
+
4
+ <p>a custom key</p>
@@ -0,0 +1,9 @@
1
+ import { expect, test } from 'vitest';
2
+ import { runBuild } from '#test-instance';
3
+
4
+ const results = await runBuild(import.meta.dirname);
5
+
6
+ test('renders computed data from local key', async () => {
7
+ const page = results.find(({ url }) => url === '/from-local-key/');
8
+ await expect(page.content).toMatchFileSnapshot('./__snapshots__/from-local-key.html');
9
+ });
@@ -0,0 +1,9 @@
1
+ ---
2
+ eleventyComputed:
3
+ title: "Dynamically generated from {{ customKey }}"
4
+ customKey: "a custom key"
5
+ ---
6
+
7
+ <h1>{{ title }}</h1>
8
+
9
+ <p>{{ customKey }}</p>
@@ -0,0 +1,4 @@
1
+
2
+ <p>2 + 2 = 4</p>
3
+
4
+ <p>This is a cool page</p>
@@ -0,0 +1,2 @@
1
+ <p>2 + 2 = 4</p>
2
+ <p>This is a cool page</p>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: This is a cool page
3
+ ---
4
+
5
+ <p>2 + 2 = {{ 2 + 2 }}</p>
6
+
7
+ <p>{{ title }}</p>
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: This is a cool page
3
+ ---
4
+
5
+ 2 + 2 = {{ 2 + 2 }}
6
+
7
+ {{ title }}
@@ -0,0 +1,4 @@
1
+ export const config = {
2
+ markdownTemplateEngine: 'vto',
3
+ htmlTemplateEngine: 'vto',
4
+ };
@@ -0,0 +1,14 @@
1
+ import { expect, test } from 'vitest';
2
+ import { runBuild } from '#test-instance';
3
+
4
+ export const results = await runBuild(import.meta.dirname);
5
+
6
+ test('renders markdown file with Vento', async () => {
7
+ const page = results.find(({ url }) => url === '/as-md-engine/');
8
+ await expect(page.content).toMatchFileSnapshot('./__snapshots__/as-md-engine.html');
9
+ });
10
+
11
+ test('renders html file with Vento', async () => {
12
+ const page = results.find(({ url }) => url === '/as-html-engine/');
13
+ await expect(page.content).toMatchFileSnapshot('./__snapshots__/as-html-engine.html');
14
+ });
@@ -0,0 +1,13 @@
1
+ export default function (eleventyConfig) {
2
+ eleventyConfig.addFilter(
3
+ 'uppercase',
4
+ /** @param {string} content */
5
+ (content) => content.toUpperCase()
6
+ );
7
+
8
+ eleventyConfig.addFilter('wrapWith', (content, tag) => `<${tag}>${content}</${tag}>`);
9
+
10
+ eleventyConfig.addFilter('pageUrlCompare', function (url) {
11
+ return url === this.page.url;
12
+ });
13
+ }
@@ -1,21 +1,7 @@
1
1
  import { expect, test } from 'vitest';
2
2
  import { runBuild } from '#test-instance';
3
3
 
4
- const results = await runBuild(import.meta.dirname, {
5
- eleventy(configApi) {
6
- configApi.addFilter(
7
- 'uppercase',
8
- /** @param {string} content */
9
- (content) => content.toUpperCase()
10
- );
11
-
12
- configApi.addFilter('wrapWith', (content, tag) => `<${tag}>${content}</${tag}>`);
13
-
14
- configApi.addFilter('pageUrlCompare', function (url) {
15
- return url === this.page.url;
16
- });
17
- },
18
- });
4
+ const results = await runBuild(import.meta.dirname);
19
5
 
20
6
  test('transforms string with built-in method', async () => {
21
7
  const page = results.find(({ url }) => url === '/basic/');
@@ -1,10 +1,13 @@
1
+ import path from 'node:path';
1
2
  import { VentoPlugin } from 'eleventy-plugin-vento';
2
3
  import Eleventy from '@11ty/eleventy';
3
4
 
4
5
  /**
6
+ * @typedef {import('@11ty/eleventy/src/UserConfig.js').default} EleventyUserConfig
7
+ *
5
8
  * @typedef {object} ExtensionsOptions
6
9
  * @property {import('eleventy-plugin-vento').VentoPluginOptions} vento
7
- * @property {import('@11ty/eleventy/src/UserConfig.js')} eleventy
10
+ * @property {(configApi: EleventyUserConfig) => void} eleventy
8
11
  *
9
12
  * @typedef {{ url: string, inputPath: string, outputPath: string, rawInput: string, content: string }} PageObject
10
13
  * @typedef {PageObject[]} EleventyOutput
@@ -18,13 +21,13 @@ export async function runBuild(fromInput, extensions = {}) {
18
21
  const instance = new Eleventy(fromInput, '_site', {
19
22
  quiet: true,
20
23
 
21
- /** @param {import('@11ty/eleventy/src/UserConfig.js').default} eleventyConfig */
24
+ configPath: path.join(fromInput, 'eleventy.config.js'),
25
+
26
+ /** @param {EleventyUserConfig} eleventyConfig */
22
27
  config(eleventyConfig) {
23
28
  eleventyConfig.addPlugin(VentoPlugin, extensions.vento || {});
24
29
 
25
30
  eleventyConfig.ignores.add('**/__snapshots__/**');
26
-
27
- if (extensions.eleventy) extensions.eleventy.call(this, eleventyConfig);
28
31
  },
29
32
  });
30
33
 
@@ -0,0 +1,4 @@
1
+ export default function (eleventyConfig) {
2
+ eleventyConfig.addShortcode('helloWorld', () => 'Hello world!');
3
+ eleventyConfig.addShortcode('possumPosse', (number = 'the') => `Release ${number} possums!!!`);
4
+ }
@@ -1,12 +1,7 @@
1
1
  import { expect, test } from 'vitest';
2
2
  import { runBuild } from '#test-instance';
3
3
 
4
- const results = await runBuild(import.meta.dirname, {
5
- eleventy(configApi) {
6
- configApi.addShortcode('helloWorld', () => 'Hello world!');
7
- configApi.addShortcode('possumPosse', (number = 'the') => `Release ${number} possums!!!`);
8
- },
9
- });
4
+ const results = await runBuild(import.meta.dirname);
10
5
 
11
6
  test('shortcode without argument', () => {
12
7
  const page = results.find(({ url }) => url === '/basic/');