eleventy-plugin-vento 2.2.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 +7 -9
- package/VentoPlugin.js +4 -0
- package/jsconfig.json +4 -1
- package/lib/ssr.js +23 -0
- package/package.json +6 -3
- package/tests/includes/includes.test.js +2 -8
- package/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/.github/workflows/ci.yml
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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:
|
|
9
|
+
test:
|
|
10
|
+
uses: ./.github/workflows/ci.yml
|
|
11
|
+
|
|
12
12
|
release:
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
|
+
needs: test
|
|
14
15
|
permissions:
|
|
15
16
|
contents: write # to be able to publish a GitHub release
|
|
16
17
|
id-token: write # to enable use of OIDC for npm provenance
|
|
@@ -24,9 +25,6 @@ jobs:
|
|
|
24
25
|
- name: Setup
|
|
25
26
|
uses: ./.github/actions/setup
|
|
26
27
|
|
|
27
|
-
- name: Check project for errors
|
|
28
|
-
run: pnpm test
|
|
29
|
-
|
|
30
28
|
- name: Verify provenance attestations and registry signatures
|
|
31
29
|
run: npm audit signatures
|
|
32
30
|
|
|
@@ -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,6 +70,9 @@ 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 }));
|
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,6 +1,6 @@
|
|
|
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
6
|
"packageManager": "pnpm@9.3.0",
|
|
@@ -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
|
},
|
|
@@ -35,11 +38,11 @@
|
|
|
35
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",
|
|
45
|
+
"eslint": "9.4.0",
|
|
43
46
|
"globals": "15.4.0",
|
|
44
47
|
"semantic-release": "24.0.0",
|
|
45
48
|
"vitest": "1.6.0"
|
|
@@ -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
|
});
|
|
@@ -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
|
+
});
|