eleventy-plugin-vento 2.1.0 → 2.3.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/.github/workflows/ci.yml +1 -2
- package/.github/workflows/release.yml +4 -6
- package/VentoPlugin.js +8 -3
- package/eslint.config.js +1 -1
- package/jsconfig.json +4 -1
- package/lib/ssr.js +23 -0
- package/package.json +9 -6
- package/release.config.js +1 -1
- package/{test → tests}/includes/includes.test.js +2 -8
- package/tests/permalinks/dynamic-js/dynamic-js.11tydata.js +5 -0
- package/tests/permalinks/dynamic-js/dynamic-permalink-js.vto +6 -0
- package/{test → tests}/permalinks/permalinks.test.js +4 -10
- package/{test → tests}/shortcodes/shortcodes.test.js +5 -10
- package/tests/ssr/__snapshots__/ssr-data.html +1 -0
- package/tests/ssr/__snapshots__/ssr-echo.html +7 -0
- package/tests/ssr/__snapshots__/ssr-exec.html +1 -0
- package/tests/ssr/__snapshots__/ssr-for.html +3 -0
- package/tests/ssr/__snapshots__/ssr-if.html +5 -0
- package/tests/ssr/data.vto +1 -0
- package/tests/ssr/echo.vto +7 -0
- package/tests/ssr/exec.vto +1 -0
- package/tests/ssr/for.vto +3 -0
- package/tests/ssr/if.vto +5 -0
- package/tests/ssr/ssr.test.js +29 -0
- /package/{test → tests}/autotrim/__snapshots__/autotrim-all.html +0 -0
- /package/{test → tests}/autotrim/__snapshots__/autotrim-single.html +0 -0
- /package/{test → tests}/autotrim/autotrim.test.js +0 -0
- /package/{test → tests}/autotrim/build/autotrim-all.html +0 -0
- /package/{test → tests}/autotrim/build/autotrim-single.html +0 -0
- /package/{test → tests}/autotrim/index.vto +0 -0
- /package/{test → tests}/basic/__snapshots__/template-basic.html +0 -0
- /package/{test → tests}/basic/basic.test.js +0 -0
- /package/{test → tests}/basic/index.vto +0 -0
- /package/{test → tests}/filters/__snapshots__/filters-arguments.html +0 -0
- /package/{test → tests}/filters/__snapshots__/filters-basic.html +0 -0
- /package/{test → tests}/filters/basic.vto +0 -0
- /package/{test → tests}/filters/filters.test.js +0 -0
- /package/{test → tests}/filters/with-arguments.vto +0 -0
- /package/{test → tests}/filters/with-this.vto +0 -0
- /package/{test → tests}/get-instance.js +0 -0
- /package/{test → tests}/includes/__snapshots__/includes-basic.html +0 -0
- /package/{test → tests}/includes/__snapshots__/includes-data.html +0 -0
- /package/{test → tests}/includes/_includes/partial.vto +0 -0
- /package/{test → tests}/includes/basic.vto +0 -0
- /package/{test → tests}/includes/with-data.vto +0 -0
- /package/{test → tests}/layouts/__snapshots__/example-layout-1.html +0 -0
- /package/{test → tests}/layouts/__snapshots__/example-layout-2.html +0 -0
- /package/{test → tests}/layouts/_includes/layout1.vto +0 -0
- /package/{test → tests}/layouts/_includes/layout2.vto +0 -0
- /package/{test → tests}/layouts/layouts.test.js +0 -0
- /package/{test → tests}/layouts/page1.vto +0 -0
- /package/{test → tests}/layouts/page2.vto +0 -0
- /package/{test → tests}/permalinks/__snapshots__/permalink-nested.html +0 -0
- /package/{test → tests}/permalinks/__snapshots__/permalink-root.html +0 -0
- /package/{test → tests}/permalinks/_includes/layout.vto +0 -0
- /package/{test → tests}/permalinks/at-nested.vto +0 -0
- /package/{test → tests}/permalinks/at-root.vto +0 -0
- /package/{test → tests}/permalinks/dynamic/dynamic-permalink.vto +0 -0
- /package/{test → tests}/permalinks/dynamic/dynamic.11tydata.json +0 -0
- /package/{test → tests}/permalinks/skip.vto +0 -0
- /package/{test → tests}/shortcodes/__snapshots__/shortcode-with-arguments.html +0 -0
- /package/{test → tests}/shortcodes/basic.vto +0 -0
- /package/{test → tests}/shortcodes/with-arguments.vto +0 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
# Run releases every monday and wednesday
|
|
2
|
-
# at 12:33 UTC (or manually)
|
|
3
|
-
|
|
4
1
|
name: Release
|
|
5
2
|
|
|
6
3
|
on:
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, alpha, beta, next]
|
|
9
6
|
workflow_dispatch:
|
|
10
7
|
|
|
11
8
|
jobs:
|
|
12
9
|
test:
|
|
13
10
|
uses: ./.github/workflows/ci.yml
|
|
11
|
+
|
|
14
12
|
release:
|
|
15
13
|
runs-on: ubuntu-latest
|
|
16
14
|
needs: test
|
|
@@ -34,4 +32,4 @@ jobs:
|
|
|
34
32
|
env:
|
|
35
33
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
36
34
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
37
|
-
run: pnpm exec semantic-release
|
|
35
|
+
run: pnpm exec semantic-release --dryrun
|
package/VentoPlugin.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import VentoJs from 'ventojs';
|
|
17
|
+
import { ssr } from '#lib/ssr.js';
|
|
17
18
|
|
|
18
19
|
// Expose autotrim plugin defaults
|
|
19
20
|
import {
|
|
@@ -69,17 +70,21 @@ export function VentoPlugin(eleventyConfig, options = {}) {
|
|
|
69
70
|
// Load user-defined plugins into vento
|
|
70
71
|
for (const plugin of options.plugins) env.use(plugin);
|
|
71
72
|
|
|
73
|
+
// Load ssr plugin
|
|
74
|
+
env.use(ssr);
|
|
75
|
+
|
|
72
76
|
// Add autotrim plugin if enabled
|
|
73
77
|
if (options.trimTags === true) env.use(autoTrim());
|
|
74
78
|
else if (options.trimTags) env.use(autoTrim({ tags: options.trimTags }));
|
|
75
79
|
|
|
80
|
+
eleventyConfig.on('eleventy.before', () => env.cache.clear());
|
|
81
|
+
|
|
76
82
|
// Add vto as a template format and create a custom template for it
|
|
77
83
|
eleventyConfig.addTemplateFormats('vto');
|
|
78
84
|
eleventyConfig.addExtension('vto', {
|
|
79
85
|
outputFileExtension: 'html',
|
|
80
86
|
|
|
81
87
|
async compile(inputContent, inputPath) {
|
|
82
|
-
env.cache.clear();
|
|
83
88
|
return async (data) => {
|
|
84
89
|
if (options.addHelpers) {
|
|
85
90
|
// Extract a possible namespace from the addHelpers option
|
|
@@ -113,10 +118,10 @@ export function VentoPlugin(eleventyConfig, options = {}) {
|
|
|
113
118
|
},
|
|
114
119
|
|
|
115
120
|
compileOptions: {
|
|
116
|
-
permalink(linkContents
|
|
121
|
+
permalink(linkContents) {
|
|
117
122
|
if (typeof linkContents !== 'string') return linkContents;
|
|
118
123
|
return async (data) => {
|
|
119
|
-
const result = await env.runString(linkContents, data
|
|
124
|
+
const result = await env.runString(linkContents, data);
|
|
120
125
|
return result.content;
|
|
121
126
|
};
|
|
122
127
|
},
|
package/eslint.config.js
CHANGED
package/jsconfig.json
CHANGED
package/lib/ssr.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('ventojs/src/tokenizer.js').Token} Token
|
|
3
|
+
* @typedef {import('ventojs/src/environment.js').Environment} Environment
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** @param {Environment} env */
|
|
7
|
+
export function ssr(env) {
|
|
8
|
+
env.tags.push(ssrTag);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} code
|
|
13
|
+
* @param {Environment} env
|
|
14
|
+
* @param {string} output
|
|
15
|
+
* @param {Token[]} tokens
|
|
16
|
+
*/
|
|
17
|
+
function ssrTag(env, code, output, _tokens) {
|
|
18
|
+
if (!code.startsWith('!')) return;
|
|
19
|
+
|
|
20
|
+
const compiled = `{{${code.replace(/!(>?)\s+/, '$1 ')} }}`;
|
|
21
|
+
|
|
22
|
+
return `${output} += "${compiled}";`;
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eleventy-plugin-vento",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Adds support for the Vento templating language to Eleventy.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"packageManager": "pnpm@9.
|
|
6
|
+
"packageManager": "pnpm@9.3.0",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=16"
|
|
9
9
|
},
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"lint": "eslint **/*.js --config ./eslint.config.js"
|
|
13
13
|
},
|
|
14
14
|
"main": "./VentoPlugin.js",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#lib/*": "./lib/*"
|
|
17
|
+
},
|
|
15
18
|
"exports": {
|
|
16
19
|
".": "./VentoPlugin.js"
|
|
17
20
|
},
|
|
@@ -32,15 +35,15 @@
|
|
|
32
35
|
},
|
|
33
36
|
"license": "MIT",
|
|
34
37
|
"dependencies": {
|
|
35
|
-
"ventojs": "0.12.
|
|
38
|
+
"ventojs": "0.12.7"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
|
-
"@11ty/eleventy": "3.0.0-alpha.
|
|
41
|
+
"@11ty/eleventy": "3.0.0-alpha.11",
|
|
39
42
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
40
|
-
"eslint": "9.4.0",
|
|
41
43
|
"eslint-config-flat-gitignore": "0.1.5",
|
|
42
44
|
"eslint-config-prettier": "9.1.0",
|
|
43
|
-
"
|
|
45
|
+
"eslint": "9.4.0",
|
|
46
|
+
"globals": "15.4.0",
|
|
44
47
|
"semantic-release": "24.0.0",
|
|
45
48
|
"vitest": "1.6.0"
|
|
46
49
|
},
|
package/release.config.js
CHANGED
|
@@ -3,7 +3,7 @@ const presetConfig = {
|
|
|
3
3
|
{ type: 'feat', section: 'New Features' },
|
|
4
4
|
{ type: 'fix', section: 'Bug Fixes' },
|
|
5
5
|
{ type: 'refactor', section: 'Refactorings' },
|
|
6
|
-
{ type: 'docs',
|
|
6
|
+
{ type: 'docs', section: 'Documentation' },
|
|
7
7
|
{ type: 'chore', hidden: true },
|
|
8
8
|
{ type: 'perf', hidden: true },
|
|
9
9
|
{ type: 'style', hidden: true },
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { expect, test } from 'vitest';
|
|
2
2
|
import { runBuild } from '../get-instance.js';
|
|
3
3
|
|
|
4
|
-
console.log(import.meta.dirname);
|
|
5
|
-
|
|
6
4
|
const results = await runBuild(import.meta.dirname);
|
|
7
5
|
|
|
8
6
|
test('include a page', async () => {
|
|
9
7
|
const page = results.find(({ url }) => url === '/basic/');
|
|
10
|
-
await expect(page.content).toMatchFileSnapshot(
|
|
11
|
-
'./__snapshots__/includes-basic.html'
|
|
12
|
-
);
|
|
8
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/includes-basic.html');
|
|
13
9
|
});
|
|
14
10
|
|
|
15
11
|
test('include a page with data passing', async () => {
|
|
16
12
|
const page = results.find(({ url }) => url === '/with-data/');
|
|
17
|
-
await expect(page.content).toMatchFileSnapshot(
|
|
18
|
-
'./__snapshots__/includes-data.html'
|
|
19
|
-
);
|
|
13
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/includes-data.html');
|
|
20
14
|
});
|
|
@@ -5,27 +5,21 @@ const results = await runBuild(import.meta.dirname);
|
|
|
5
5
|
|
|
6
6
|
test('render a page at a nested permalink', async () => {
|
|
7
7
|
const page = results.find(({ url }) => url === '/page/at/nested/permalink/');
|
|
8
|
-
await expect(page.content).toMatchFileSnapshot(
|
|
9
|
-
'./__snapshots__/permalink-nested.html'
|
|
10
|
-
);
|
|
8
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/permalink-nested.html');
|
|
11
9
|
});
|
|
12
10
|
|
|
13
11
|
test('render a page at root url', async () => {
|
|
14
12
|
const page = results.find(({ url }) => url === '/');
|
|
15
|
-
expect(page.content).toMatchFileSnapshot(
|
|
16
|
-
'./__snapshots__/permalink-root.html'
|
|
17
|
-
);
|
|
13
|
+
expect(page.content).toMatchFileSnapshot('./__snapshots__/permalink-root.html');
|
|
18
14
|
});
|
|
19
15
|
|
|
20
16
|
test('render a page at a dynamic permalink', async () => {
|
|
21
|
-
const page = results.find(
|
|
22
|
-
({ url }) => url === '/directory-data-test-page.html'
|
|
23
|
-
);
|
|
17
|
+
const page = results.find(({ url }) => url === '/directory-data-test-page.html');
|
|
24
18
|
|
|
25
19
|
expect(page).toBeDefined();
|
|
26
20
|
});
|
|
27
21
|
|
|
28
22
|
test('skips rendering a file', () => {
|
|
29
23
|
const writtenTemplates = results.filter(({ url }) => Boolean(url));
|
|
30
|
-
expect(writtenTemplates.length).toBe(
|
|
24
|
+
expect(writtenTemplates.length).toBe(4);
|
|
31
25
|
});
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import { test } from 'vitest';
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
2
|
import { runBuild } from '../get-instance.js';
|
|
3
3
|
|
|
4
4
|
const results = await runBuild(import.meta.dirname, {
|
|
5
5
|
eleventy(configApi) {
|
|
6
6
|
configApi.addShortcode('helloWorld', () => 'Hello world!');
|
|
7
|
-
configApi.addShortcode(
|
|
8
|
-
'possumPosse',
|
|
9
|
-
(number = 'the') => `Release ${number} possums!!!`
|
|
10
|
-
);
|
|
7
|
+
configApi.addShortcode('possumPosse', (number = 'the') => `Release ${number} possums!!!`);
|
|
11
8
|
},
|
|
12
9
|
});
|
|
13
10
|
|
|
14
|
-
test
|
|
11
|
+
test('shortcode without argument', () => {
|
|
15
12
|
const page = results.find(({ url }) => url === '/basic/');
|
|
16
13
|
expect(page.content).toBe('Hello world!\n');
|
|
17
14
|
});
|
|
18
15
|
|
|
19
|
-
test
|
|
16
|
+
test('shortcode with arguments', async () => {
|
|
20
17
|
const page = results.find(({ url }) => url === '/with-arguments/');
|
|
21
|
-
await expect(page.content).toMatchFileSnapshot(
|
|
22
|
-
'./__snapshots__/shortcode-with-arguments.html'
|
|
23
|
-
);
|
|
18
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/shortcode-with-arguments.html');
|
|
24
19
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p>{{ dynamicValue }}</p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{> console.log('hello world!') }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p>{{! dynamicValue }}</p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{!> console.log('hello world!') }}
|
package/tests/ssr/if.vto
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { runBuild } from '../get-instance.js';
|
|
3
|
+
|
|
4
|
+
const results = await runBuild(import.meta.dirname);
|
|
5
|
+
|
|
6
|
+
test('render if', async () => {
|
|
7
|
+
const page = results.find(({ url }) => url === '/if/');
|
|
8
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/ssr-if.html');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('render data', async () => {
|
|
12
|
+
const page = results.find(({ url }) => url === '/data/');
|
|
13
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/ssr-data.html');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('render for', async () => {
|
|
17
|
+
const page = results.find(({ url }) => url === '/for/');
|
|
18
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/ssr-for.html');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('render echo', async () => {
|
|
22
|
+
const page = results.find(({ url }) => url === '/echo/');
|
|
23
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/ssr-echo.html');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('render exec', async () => {
|
|
27
|
+
const page = results.find(({ url }) => url === '/exec/');
|
|
28
|
+
await expect(page.content).toMatchFileSnapshot('./__snapshots__/ssr-exec.html');
|
|
29
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|