eleventy-plugin-vento 2.5.0 → 3.0.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +223 -0
  2. package/LICENSE +1 -1
  3. package/package.json +61 -56
  4. package/readme.md +98 -76
  5. package/src/engine.js +85 -0
  6. package/src/index.js +130 -0
  7. package/src/modules/create-vento-tag.js +56 -0
  8. package/src/modules/ignore-tag.js +15 -0
  9. package/src/modules/utils.js +22 -0
  10. package/.editorconfig +0 -16
  11. package/.github/actions/setup/action.yml +0 -25
  12. package/.github/renovate.json +0 -13
  13. package/.github/workflows/ci.yml +0 -15
  14. package/.github/workflows/release.yml +0 -33
  15. package/.node-version +0 -1
  16. package/.vscode/settings.json +0 -4
  17. package/.vscode/tests.code-snippets +0 -16
  18. package/VentoPlugin.js +0 -130
  19. package/eslint.config.js +0 -67
  20. package/jsconfig.json +0 -11
  21. package/lib/ssr.js +0 -23
  22. package/release.config.js +0 -31
  23. package/tests/autotrim/__snapshots__/autotrim-all.html +0 -53
  24. package/tests/autotrim/__snapshots__/autotrim-single.html +0 -75
  25. package/tests/autotrim/autotrim.test.js +0 -17
  26. package/tests/autotrim/build/autotrim-all.html +0 -53
  27. package/tests/autotrim/build/autotrim-single.html +0 -75
  28. package/tests/autotrim/index.vto +0 -23
  29. package/tests/basic/__snapshots__/template-basic.html +0 -4
  30. package/tests/basic/basic.test.js +0 -9
  31. package/tests/basic/index.vto +0 -7
  32. package/tests/filters/__snapshots__/filters-arguments.html +0 -1
  33. package/tests/filters/__snapshots__/filters-basic.html +0 -2
  34. package/tests/filters/basic.vto +0 -5
  35. package/tests/filters/filters.test.js +0 -33
  36. package/tests/filters/with-arguments.vto +0 -1
  37. package/tests/filters/with-this.vto +0 -1
  38. package/tests/get-instance.js +0 -35
  39. package/tests/includes/__snapshots__/includes-basic.html +0 -8
  40. package/tests/includes/__snapshots__/includes-data.html +0 -8
  41. package/tests/includes/_includes/partial.vto +0 -4
  42. package/tests/includes/basic.vto +0 -7
  43. package/tests/includes/includes.test.js +0 -14
  44. package/tests/includes/with-data.vto +0 -7
  45. package/tests/layouts/__snapshots__/example-layout-1.html +0 -27
  46. package/tests/layouts/__snapshots__/example-layout-2.html +0 -24
  47. package/tests/layouts/_includes/layout1.vto +0 -20
  48. package/tests/layouts/_includes/layout2.vto +0 -17
  49. package/tests/layouts/layouts.test.js +0 -14
  50. package/tests/layouts/page1.vto +0 -11
  51. package/tests/layouts/page2.vto +0 -11
  52. package/tests/permalinks/__snapshots__/permalink-nested.html +0 -15
  53. package/tests/permalinks/__snapshots__/permalink-root.html +0 -15
  54. package/tests/permalinks/_includes/layout.vto +0 -13
  55. package/tests/permalinks/at-nested.vto +0 -7
  56. package/tests/permalinks/at-root.vto +0 -7
  57. package/tests/permalinks/dynamic/dynamic-permalink.vto +0 -6
  58. package/tests/permalinks/dynamic/dynamic.11tydata.json +0 -3
  59. package/tests/permalinks/dynamic-js/dynamic-js.11tydata.js +0 -5
  60. package/tests/permalinks/dynamic-js/dynamic-permalink-js.vto +0 -6
  61. package/tests/permalinks/permalinks.test.js +0 -25
  62. package/tests/permalinks/skip.vto +0 -7
  63. package/tests/shortcodes/__snapshots__/shortcode-with-arguments.html +0 -2
  64. package/tests/shortcodes/basic.vto +0 -1
  65. package/tests/shortcodes/shortcodes.test.js +0 -19
  66. package/tests/shortcodes/with-arguments.vto +0 -2
  67. package/tests/ssr/__snapshots__/ssr-data.html +0 -1
  68. package/tests/ssr/__snapshots__/ssr-echo.html +0 -7
  69. package/tests/ssr/__snapshots__/ssr-exec.html +0 -1
  70. package/tests/ssr/__snapshots__/ssr-for.html +0 -3
  71. package/tests/ssr/__snapshots__/ssr-if.html +0 -5
  72. package/tests/ssr/data.vto +0 -1
  73. package/tests/ssr/echo.vto +0 -7
  74. package/tests/ssr/exec.vto +0 -1
  75. package/tests/ssr/for.vto +0 -3
  76. package/tests/ssr/if.vto +0 -5
  77. package/tests/ssr/ssr.test.js +0 -29
package/release.config.js DELETED
@@ -1,31 +0,0 @@
1
- const presetConfig = {
2
- types: [
3
- { type: 'feat', section: 'New Features' },
4
- { type: 'fix', section: 'Bug Fixes' },
5
- { type: 'refactor', section: 'Refactors' },
6
- { type: 'upstream', section: 'Dependency Updates' },
7
- { type: 'docs', hidden: true },
8
- { type: 'chore', hidden: true },
9
- { type: 'perf', hidden: true },
10
- { type: 'style', hidden: true },
11
- { type: 'test', hidden: true },
12
- ],
13
- };
14
-
15
- const releaseRules = [
16
- { breaking: true, release: 'major' },
17
- { type: 'upstream', release: 'minor' },
18
- ];
19
-
20
- /** @type {import('semantic-release').Options} */
21
- export default {
22
- preset: 'conventionalcommits',
23
- presetConfig,
24
- releaseRules,
25
- plugins: [
26
- ['@semantic-release/commit-analyzer'],
27
- '@semantic-release/release-notes-generator',
28
- '@semantic-release/npm',
29
- '@semantic-release/github',
30
- ],
31
- };
@@ -1,53 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Document</title>
7
- </head>
8
- <body>
9
- <main>
10
- <section>
11
- <h1>1</h1>
12
- <p>This is section 1</p>
13
- </section>
14
- <section>
15
- <h1>2</h1>
16
- <p>This is section 2</p>
17
- </section>
18
- <section>
19
- <h1>3</h1>
20
- <p>This is section 3</p>
21
- </section>
22
- <section>
23
- <h1>4</h1>
24
- <p>This is section 4</p>
25
- </section>
26
- Section 5 is next!!
27
- <section>
28
- <h1>5</h1>
29
- <p>This is section 5</p>
30
- </section>
31
- <section>
32
- <h1>6</h1>
33
- <p>This is section 6</p>
34
- </section>
35
- <section>
36
- <h1>7</h1>
37
- <p>This is section 7</p>
38
- </section>
39
- <section>
40
- <h1>8</h1>
41
- <p>This is section 8</p>
42
- </section>
43
- <section>
44
- <h1>9</h1>
45
- <p>This is section 9</p>
46
- </section>
47
- <section>
48
- <h1>10</h1>
49
- <p>This is section 10</p>
50
- </section>
51
- </main>
52
- </body>
53
- </html>
@@ -1,75 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Document</title>
7
- </head>
8
- <body>
9
- <main>
10
-
11
-
12
- <section>
13
- <h1>1</h1>
14
- <p>This is section 1</p>
15
- </section>
16
-
17
-
18
- <section>
19
- <h1>2</h1>
20
- <p>This is section 2</p>
21
- </section>
22
-
23
-
24
- <section>
25
- <h1>3</h1>
26
- <p>This is section 3</p>
27
- </section>
28
-
29
-
30
- <section>
31
- <h1>4</h1>
32
- <p>This is section 4</p>
33
- </section>
34
-
35
-
36
- Section 5 is next!!
37
-
38
- <section>
39
- <h1>5</h1>
40
- <p>This is section 5</p>
41
- </section>
42
-
43
-
44
- <section>
45
- <h1>6</h1>
46
- <p>This is section 6</p>
47
- </section>
48
-
49
-
50
- <section>
51
- <h1>7</h1>
52
- <p>This is section 7</p>
53
- </section>
54
-
55
-
56
- <section>
57
- <h1>8</h1>
58
- <p>This is section 8</p>
59
- </section>
60
-
61
-
62
- <section>
63
- <h1>9</h1>
64
- <p>This is section 9</p>
65
- </section>
66
-
67
-
68
- <section>
69
- <h1>10</h1>
70
- <p>This is section 10</p>
71
- </section>
72
-
73
- </main>
74
- </body>
75
- </html>
@@ -1,17 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { runBuild } from '#test-instance';
3
-
4
- const [trimSingle, trimAll] = await Promise.all([
5
- runBuild(import.meta.dirname, { vento: { trimTags: ['set'] } }),
6
- runBuild(import.meta.dirname, { vento: { trimTags: true } }),
7
- ]);
8
-
9
- test('should trim a single tag', async () => {
10
- const page = trimSingle[0];
11
- await expect(page.content).toMatchFileSnapshot('./build/autotrim-single.html');
12
- });
13
-
14
- test('should trim all tags', async () => {
15
- const page = trimAll[0];
16
- await expect(page.content).toMatchFileSnapshot('./build/autotrim-all.html');
17
- });
@@ -1,53 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Document</title>
7
- </head>
8
- <body>
9
- <main>
10
- <section>
11
- <h1>1</h1>
12
- <p>This is section 1</p>
13
- </section>
14
- <section>
15
- <h1>2</h1>
16
- <p>This is section 2</p>
17
- </section>
18
- <section>
19
- <h1>3</h1>
20
- <p>This is section 3</p>
21
- </section>
22
- <section>
23
- <h1>4</h1>
24
- <p>This is section 4</p>
25
- </section>
26
- Section 5 is next!!
27
- <section>
28
- <h1>5</h1>
29
- <p>This is section 5</p>
30
- </section>
31
- <section>
32
- <h1>6</h1>
33
- <p>This is section 6</p>
34
- </section>
35
- <section>
36
- <h1>7</h1>
37
- <p>This is section 7</p>
38
- </section>
39
- <section>
40
- <h1>8</h1>
41
- <p>This is section 8</p>
42
- </section>
43
- <section>
44
- <h1>9</h1>
45
- <p>This is section 9</p>
46
- </section>
47
- <section>
48
- <h1>10</h1>
49
- <p>This is section 10</p>
50
- </section>
51
- </main>
52
- </body>
53
- </html>
@@ -1,75 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Document</title>
7
- </head>
8
- <body>
9
- <main>
10
-
11
-
12
- <section>
13
- <h1>1</h1>
14
- <p>This is section 1</p>
15
- </section>
16
-
17
-
18
- <section>
19
- <h1>2</h1>
20
- <p>This is section 2</p>
21
- </section>
22
-
23
-
24
- <section>
25
- <h1>3</h1>
26
- <p>This is section 3</p>
27
- </section>
28
-
29
-
30
- <section>
31
- <h1>4</h1>
32
- <p>This is section 4</p>
33
- </section>
34
-
35
-
36
- Section 5 is next!!
37
-
38
- <section>
39
- <h1>5</h1>
40
- <p>This is section 5</p>
41
- </section>
42
-
43
-
44
- <section>
45
- <h1>6</h1>
46
- <p>This is section 6</p>
47
- </section>
48
-
49
-
50
- <section>
51
- <h1>7</h1>
52
- <p>This is section 7</p>
53
- </section>
54
-
55
-
56
- <section>
57
- <h1>8</h1>
58
- <p>This is section 8</p>
59
- </section>
60
-
61
-
62
- <section>
63
- <h1>9</h1>
64
- <p>This is section 9</p>
65
- </section>
66
-
67
-
68
- <section>
69
- <h1>10</h1>
70
- <p>This is section 10</p>
71
- </section>
72
-
73
- </main>
74
- </body>
75
- </html>
@@ -1,23 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Document</title>
7
- </head>
8
- <body>
9
- {{ set numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }}
10
- <main>
11
- {{ for num of numbers }}
12
- {{ set current = `section ${num}` }}
13
- {{ if num === 5 }}
14
- Section 5 is next!!
15
- {{ /if }}
16
- <section>
17
- <h1>{{ num }}</h1>
18
- <p>This is {{ current }}</p>
19
- </section>
20
- {{ /for }}
21
- </main>
22
- </body>
23
- </html>
@@ -1,4 +0,0 @@
1
-
2
- <h1>Basic Page</h1>
3
-
4
- This is a standalone page.
@@ -1,9 +0,0 @@
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 a basic template', async () => {
7
- const page = results[0];
8
- await expect(page.content).toMatchFileSnapshot('./__snapshots__/template-basic.html');
9
- });
@@ -1,7 +0,0 @@
1
- ---
2
- title: Basic Page
3
- ---
4
-
5
- <h1>{{ title }}</h1>
6
-
7
- This is a standalone page.
@@ -1 +0,0 @@
1
- This is a <strong>really cool</strong> filter.
@@ -1,2 +0,0 @@
1
-
2
- Page title is 'A BASIC PAGE'
@@ -1,5 +0,0 @@
1
- ---
2
- title: A basic page
3
- ---
4
-
5
- Page title is '{{ title |> uppercase }}'
@@ -1,33 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { runBuild } from '#test-instance';
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
- });
19
-
20
- test('transforms string with built-in method', async () => {
21
- const page = results.find(({ url }) => url === '/basic/');
22
- await expect(page.content).toMatchFileSnapshot('./__snapshots__/filters-basic.html');
23
- });
24
-
25
- test('transforms string with passed arguments', async () => {
26
- const page = results.find(({ url }) => url === '/with-arguments/');
27
- await expect(page.content).toMatchFileSnapshot('./__snapshots__/filters-arguments.html');
28
- });
29
-
30
- test('verify page context in scoped data', async () => {
31
- const page = results.find(({ url }) => url === '/with-this/');
32
- expect(page.content).toBe('true\n');
33
- });
@@ -1 +0,0 @@
1
- This is a {{ 'really cool' |> wrapWith('strong') }} filter.
@@ -1 +0,0 @@
1
- {{ page.url |> pageUrlCompare }}
@@ -1,35 +0,0 @@
1
- import { VentoPlugin } from 'eleventy-plugin-vento';
2
- import Eleventy from '@11ty/eleventy';
3
-
4
- /**
5
- * @typedef {object} ExtensionsOptions
6
- * @property {import('eleventy-plugin-vento').VentoPluginOptions} vento
7
- * @property {import('@11ty/eleventy/src/UserConfig.js')} eleventy
8
- *
9
- * @typedef {{ url: string, inputPath: string, outputPath: string, rawInput: string, content: string }} PageObject
10
- * @typedef {PageObject[]} EleventyOutput
11
- */
12
-
13
- /**
14
- * @param {string} fromInput
15
- * @param {ExtensionsOptions} [extensions={}]
16
- */
17
- export async function runBuild(fromInput, extensions = {}) {
18
- const instance = new Eleventy(fromInput, '_site', {
19
- quiet: true,
20
-
21
- /** @param {import('@11ty/eleventy/src/UserConfig.js').default} eleventyConfig */
22
- config(eleventyConfig) {
23
- eleventyConfig.addPlugin(VentoPlugin, extensions.vento || {});
24
-
25
- eleventyConfig.ignores.add('**/__snapshots__/**');
26
-
27
- if (extensions.eleventy) extensions.eleventy.call(this, eleventyConfig);
28
- },
29
- });
30
-
31
- /** @type {Promise<EleventyOutput>} */
32
- const results = await instance.toJSON();
33
-
34
- return results;
35
- }
@@ -1,8 +0,0 @@
1
-
2
- <h1>Page with includes</h1>
3
-
4
- <section class="include">
5
- <p>This content is included.</p>
6
- <p>Passed data for `extra` key: ''</p>
7
- </section>
8
-
@@ -1,8 +0,0 @@
1
-
2
- <h1>Page with includes (data passing)</h1>
3
-
4
- <section class="include">
5
- <p>This content is included.</p>
6
- <p>Passed data for `extra` key: 'super fancy data'</p>
7
- </section>
8
-
@@ -1,4 +0,0 @@
1
- <section class="include">
2
- <p>This content is included.</p>
3
- <p>Passed data for `extra` key: '{{ extra }}'</p>
4
- </section>
@@ -1,7 +0,0 @@
1
- ---
2
- title: Page with includes
3
- ---
4
-
5
- <h1>{{ title }}</h1>
6
-
7
- {{ include 'partial.vto' }}
@@ -1,14 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { runBuild } from '#test-instance';
3
-
4
- const results = await runBuild(import.meta.dirname);
5
-
6
- test('include a page', async () => {
7
- const page = results.find(({ url }) => url === '/basic/');
8
- await expect(page.content).toMatchFileSnapshot('./__snapshots__/includes-basic.html');
9
- });
10
-
11
- test('include a page with data passing', async () => {
12
- const page = results.find(({ url }) => url === '/with-data/');
13
- await expect(page.content).toMatchFileSnapshot('./__snapshots__/includes-data.html');
14
- });
@@ -1,7 +0,0 @@
1
- ---
2
- title: Page with includes (data passing)
3
- ---
4
-
5
- <h1>{{ title }}</h1>
6
-
7
- {{ include 'partial.vto' { extra: 'super fancy data' } }}
@@ -1,27 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with layout</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Page title: Page with layout</h1>
11
- </header>
12
- <main>
13
- <section>This is an alternative layout.</section>
14
- <section>
15
- <p>This is a page that uses the first layout.</p>
16
-
17
- <p>This is another paragraph.</p>
18
- <p>This is another paragraph.</p>
19
- <p>This is another paragraph.</p>
20
-
21
- </section>
22
- </main>
23
- <footer>
24
- <p>I am a footer, outside the layout</p>
25
- </footer>
26
- </body>
27
- </html>
@@ -1,24 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with layout</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Page title: Page with layout</h1>
11
- </header>
12
- <main>
13
- <p>This is a page that uses the second layout.</p>
14
-
15
- <p>This is another paragraph.</p>
16
- <p>This is another paragraph.</p>
17
- <p>This is another paragraph.</p>
18
-
19
- </main>
20
- <footer>
21
- <p>I am a footer, outside the layout</p>
22
- </footer>
23
- </body>
24
- </html>
@@ -1,20 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>{{ title }}</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Page title: {{ title }}</h1>
11
- </header>
12
- <main>
13
- <section>This is an alternative layout.</section>
14
- <section>{{ content }}</section>
15
- </main>
16
- <footer>
17
- <p>I am a footer, outside the layout</p>
18
- </footer>
19
- </body>
20
- </html>
@@ -1,17 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>{{ title }}</title>
7
- </head>
8
- <body>
9
- <header>
10
- <h1>Page title: {{ title }}</h1>
11
- </header>
12
- <main>{{ content }}</main>
13
- <footer>
14
- <p>I am a footer, outside the layout</p>
15
- </footer>
16
- </body>
17
- </html>
@@ -1,14 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { runBuild } from '#test-instance';
3
-
4
- const results = await runBuild(import.meta.dirname);
5
-
6
- test('render page with example layout 1', async () => {
7
- const page = results.find(({ url }) => url === '/page1/');
8
- await expect(page.content).toMatchFileSnapshot('./__snapshots__/example-layout-1.html');
9
- });
10
-
11
- test('render page with example layout 2', async () => {
12
- const page = results.find(({ url }) => url === '/page2/');
13
- await expect(page.content).toMatchFileSnapshot('./__snapshots__/example-layout-2.html');
14
- });
@@ -1,11 +0,0 @@
1
- ---
2
- title: Page with layout
3
- layout: layout1.vto
4
- ---
5
-
6
- <p>This is a page that uses the first layout.</p>
7
-
8
- <p>This is another paragraph.</p>
9
- <p>This is another paragraph.</p>
10
- <p>This is another paragraph.</p>
11
-
@@ -1,11 +0,0 @@
1
- ---
2
- title: Page with layout
3
- layout: layout2.vto
4
- ---
5
-
6
- <p>This is a page that uses the second layout.</p>
7
-
8
- <p>This is another paragraph.</p>
9
- <p>This is another paragraph.</p>
10
- <p>This is another paragraph.</p>
11
-
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head><title>Nested Page</title></head>
4
- <body>
5
- <header>
6
- <h1>Page title: Nested Page</h1>
7
- </header>
8
- <main>
9
- This content lives at `/page/at/nested/permalink/`
10
- </main>
11
- <footer>
12
- <p>Page footer</p>
13
- </footer>
14
- </body>
15
- </html>
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head><title>Root page</title></head>
4
- <body>
5
- <header>
6
- <h1>Page title: Root page</h1>
7
- </header>
8
- <main>
9
- This should render on the homepage.
10
- </main>
11
- <footer>
12
- <p>Page footer</p>
13
- </footer>
14
- </body>
15
- </html>