author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
699
13.06.2021 15:11:11
18,000
7dcbdd13b1167af94d6512b7fc1f0041e1ba969a
Separate gitignore and eleventyignore tests into new file
[ { "change_type": "ADD", "old_path": null, "new_path": "test/EleventyFilesGitIgnoreEleventyIgnoreTest.js", "diff": "+const test = require(\"ava\");\n+const EleventyFiles = require(\"../src/EleventyFiles\");\n+const TemplatePath = require(\"../src/TemplatePath\");\n+const TemplateConfig = require(\"../src/TemplateConfig\");\n+\n+/* .eleventyignore and .gitignore combos */\n+\n+test(\"Get ignores (no .eleventyignore no .gitignore)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore1\",\n+ \"test/stubs/ignore1/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore1/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (no .eleventyignore)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore2\",\n+ \"test/stubs/ignore2/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalrootgitignore/thisshouldnotexist12345\",\n+ \"./test/stubs/ignorelocalrootgitignore/test.md\",\n+ \"./test/stubs/ignore2/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (no .eleventyignore, using setUseGitIgnore(false))\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore2\",\n+ \"test/stubs/ignore2/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+\n+ evf._setConfig({\n+ useGitIgnore: false,\n+ dir: {\n+ includes: \"_includes\",\n+ },\n+ });\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore2/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (no .gitignore)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore3\",\n+ \"test/stubs/ignore3/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore3/ignoredFolder/**\",\n+ \"./test/stubs/ignore3/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore3/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (project .eleventyignore and root .gitignore)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore4\",\n+ \"test/stubs/ignore4/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalrootgitignore/thisshouldnotexist12345\",\n+ \"./test/stubs/ignorelocalrootgitignore/test.md\",\n+ \"./test/stubs/ignore4/ignoredFolder/**\",\n+ \"./test/stubs/ignore4/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore4/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (project .eleventyignore and root .gitignore, using setUseGitIgnore(false))\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore4\",\n+ \"test/stubs/ignore4/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+\n+ evf._setConfig({\n+ useGitIgnore: false,\n+ dir: {\n+ includes: \"_includes\",\n+ },\n+ });\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalrootgitignore/test.md\",\n+ \"./test/stubs/ignore4/ignoredFolder/**\",\n+ \"./test/stubs/ignore4/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore4/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (no .eleventyignore .gitignore exists but empty)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore5\",\n+ \"test/stubs/ignore5/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore5/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore is empty)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore6\",\n+ \"test/stubs/ignore6/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore6/ignoredFolder/**\",\n+ \"./test/stubs/ignore6/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore6/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (no .eleventyignore .gitignore exists but has spaces inside)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore7\",\n+ \"test/stubs/ignore7/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore7/_site/**\",\n+ ]);\n+});\n+\n+test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore has spaces inside)\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs/ignore8\",\n+ \"test/stubs/ignore8/_site\",\n+ [],\n+ eleventyConfig\n+ );\n+ evf.init();\n+ evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n+\n+ t.deepEqual(evf.getIgnores(), [\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore8/ignoredFolder/**\",\n+ \"./test/stubs/ignore8/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore8/_site/**\",\n+ ]);\n+});\n+\n+test(\"Bad expected output, this indicates a bug upstream in a dependency. Input to 'src' and empty includes dir (issue #403, full paths in eleventyignore)\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs-403\",\n+ \"test/stubs-403/_site\",\n+ [\"liquid\"],\n+ eleventyConfig\n+ );\n+ evf.setEleventyIgnoreContent(\n+ \"!\" + TemplatePath.absolutePath(\"test/stubs-403/_includes\") + \"/**\"\n+ );\n+ evf._setConfig({\n+ useGitIgnore: false,\n+ dir: {\n+ input: \"test/stubs-403\",\n+ output: \"_site\",\n+ includes: \"\",\n+ data: false,\n+ },\n+ });\n+ evf.init();\n+\n+ t.deepEqual(await evf.getFiles(), [\n+ \"./test/stubs-403/template.liquid\",\n+ // This is bad, because it uses an absolutePath above. it should be excluded\n+ \"./test/stubs-403/_includes/include.liquid\",\n+ ]);\n+});\n+\n+test(\"Workaround for Bad expected output, this indicates a bug upstream in a dependency. Input to 'src' and empty includes dir (issue #403, full paths in eleventyignore)\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs-403\",\n+ \"test/stubs-403/_site\",\n+ [\"liquid\"],\n+ eleventyConfig\n+ );\n+ evf.setEleventyIgnoreContent(\"!./test/stubs-403/_includes/**\");\n+ evf._setConfig({\n+ useGitIgnore: false,\n+ dir: {\n+ input: \"test/stubs-403\",\n+ output: \"_site\",\n+ includes: \"\",\n+ data: false,\n+ },\n+ });\n+ evf.init();\n+\n+ t.deepEqual(await evf.getFiles(), [\"./test/stubs-403/template.liquid\"]);\n+});\n+\n+test(\"Issue #403: all .eleventyignores should be relative paths not absolute paths\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let evf = new EleventyFiles(\n+ \"test/stubs-403\",\n+ \"test/stubs-403/_site\",\n+ [\"liquid\"],\n+ eleventyConfig\n+ );\n+ evf._setConfig({\n+ useGitIgnore: false,\n+ dir: {\n+ input: \"test/stubs-403\",\n+ output: \"_site\",\n+ includes: \"\",\n+ data: false,\n+ },\n+ });\n+ evf.init();\n+\n+ let globs = await evf.getFileGlobs();\n+ t.is(\n+ globs.filter((glob) => {\n+ return glob.indexOf(TemplatePath.absolutePath()) > -1;\n+ }).length,\n+ 0\n+ );\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesTest.js", "new_path": "test/EleventyFilesTest.js", "diff": "@@ -259,219 +259,6 @@ test(\".eleventyignore files\", async (t) => {\n);\n});\n-/* .eleventyignore and .gitignore combos */\n-test(\"Get ignores (no .eleventyignore no .gitignore)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore1\",\n- \"test/stubs/ignore1/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n-\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore1/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (no .eleventyignore)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore2\",\n- \"test/stubs/ignore2/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./test/stubs/ignorelocalrootgitignore/thisshouldnotexist12345\",\n- \"./test/stubs/ignorelocalrootgitignore/test.md\",\n- \"./test/stubs/ignore2/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (no .eleventyignore, using setUseGitIgnore(false))\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore2\",\n- \"test/stubs/ignore2/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n-\n- evf._setConfig({\n- useGitIgnore: false,\n- dir: {\n- includes: \"_includes\",\n- },\n- });\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore2/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (no .gitignore)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore3\",\n- \"test/stubs/ignore3/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore3/ignoredFolder/**\",\n- \"./test/stubs/ignore3/ignoredFolder/ignored.md\",\n- \"./test/stubs/ignore3/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (project .eleventyignore and root .gitignore)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore4\",\n- \"test/stubs/ignore4/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./test/stubs/ignorelocalrootgitignore/thisshouldnotexist12345\",\n- \"./test/stubs/ignorelocalrootgitignore/test.md\",\n- \"./test/stubs/ignore4/ignoredFolder/**\",\n- \"./test/stubs/ignore4/ignoredFolder/ignored.md\",\n- \"./test/stubs/ignore4/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (project .eleventyignore and root .gitignore, using setUseGitIgnore(false))\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore4\",\n- \"test/stubs/ignore4/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n-\n- evf._setConfig({\n- useGitIgnore: false,\n- dir: {\n- includes: \"_includes\",\n- },\n- });\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./test/stubs/ignorelocalrootgitignore/test.md\",\n- \"./test/stubs/ignore4/ignoredFolder/**\",\n- \"./test/stubs/ignore4/ignoredFolder/ignored.md\",\n- \"./test/stubs/ignore4/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (no .eleventyignore .gitignore exists but empty)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore5\",\n- \"test/stubs/ignore5/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n-\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore5/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore is empty)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore6\",\n- \"test/stubs/ignore6/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore6/ignoredFolder/**\",\n- \"./test/stubs/ignore6/ignoredFolder/ignored.md\",\n- \"./test/stubs/ignore6/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (no .eleventyignore .gitignore exists but has spaces inside)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore7\",\n- \"test/stubs/ignore7/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n-\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore7/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore has spaces inside)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore8\",\n- \"test/stubs/ignore8/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore8/ignoredFolder/**\",\n- \"./test/stubs/ignore8/ignoredFolder/ignored.md\",\n- \"./test/stubs/ignore8/_site/**\",\n- ]);\n-});\n-/* End .eleventyignore and .gitignore combos */\n-\ntest(\"getTemplateData caching\", (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet evf = new EleventyFiles(\n@@ -551,86 +338,6 @@ test(\"Input to 'src' and empty includes dir (issue #403)\", (t) => {\n]);\n});\n-test(\"Bad expected output, this indicates a bug upstream in a dependency. Input to 'src' and empty includes dir (issue #403, full paths in eleventyignore)\", async (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs-403\",\n- \"test/stubs-403/_site\",\n- [\"liquid\"],\n- eleventyConfig\n- );\n- evf.setEleventyIgnoreContent(\n- \"!\" + TemplatePath.absolutePath(\"test/stubs-403/_includes\") + \"/**\"\n- );\n- evf._setConfig({\n- useGitIgnore: false,\n- dir: {\n- input: \"test/stubs-403\",\n- output: \"_site\",\n- includes: \"\",\n- data: false,\n- },\n- });\n- evf.init();\n-\n- t.deepEqual(await evf.getFiles(), [\n- \"./test/stubs-403/template.liquid\",\n- // This is bad, because it uses an absolutePath above. it should be excluded\n- \"./test/stubs-403/_includes/include.liquid\",\n- ]);\n-});\n-\n-test(\"Workaround for Bad expected output, this indicates a bug upstream in a dependency. Input to 'src' and empty includes dir (issue #403, full paths in eleventyignore)\", async (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs-403\",\n- \"test/stubs-403/_site\",\n- [\"liquid\"],\n- eleventyConfig\n- );\n- evf.setEleventyIgnoreContent(\"!./test/stubs-403/_includes/**\");\n- evf._setConfig({\n- useGitIgnore: false,\n- dir: {\n- input: \"test/stubs-403\",\n- output: \"_site\",\n- includes: \"\",\n- data: false,\n- },\n- });\n- evf.init();\n-\n- t.deepEqual(await evf.getFiles(), [\"./test/stubs-403/template.liquid\"]);\n-});\n-\n-test(\"Issue #403: all .eleventyignores should be relative paths not absolute paths\", async (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs-403\",\n- \"test/stubs-403/_site\",\n- [\"liquid\"],\n- eleventyConfig\n- );\n- evf._setConfig({\n- useGitIgnore: false,\n- dir: {\n- input: \"test/stubs-403\",\n- output: \"_site\",\n- includes: \"\",\n- data: false,\n- },\n- });\n- evf.init();\n-\n- let globs = await evf.getFileGlobs();\n- t.is(\n- globs.filter((glob) => {\n- return glob.indexOf(TemplatePath.absolutePath()) > -1;\n- }).length,\n- 0\n- );\n-});\n-\ntest(\"Glob Watcher Files\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet evf = new EleventyFiles(\n" } ]
JavaScript
MIT License
11ty/eleventy
Separate gitignore and eleventyignore tests into new file
699
14.06.2021 07:22:21
18,000
6e20f63b20562d97c3a2b40ae911d1820f5bd584
Always ignore node_modules by default. Previous behavior only ignored node_modules by default if you did not have a .gitignore or your .gitignore was empty. Opt-out using `eleventyConfig.ignores.delete("node_modules/**");` Also adds a configuration option to allow modification of ignores: `eleventyConfig.ignores.add("my_ignore_file.md");` Fixes Fixes Fixes
[ { "change_type": "MODIFY", "old_path": "src/EleventyFiles.js", "new_path": "src/EleventyFiles.js", "diff": "@@ -112,6 +112,10 @@ class EleventyFiles {\n/* For testing */\n_setConfig(config) {\n+ if (!config.ignores) {\n+ config.ignores = new Set();\n+ config.ignores.add(\"node_modules/**\");\n+ }\nthis.config = config;\nthis.initConfig();\n}\n@@ -200,47 +204,28 @@ class EleventyFiles {\nreturn Array.from(uniqueIgnores);\n}\n- static getFileIgnores(ignoreFiles, defaultIfFileDoesNotExist) {\n+ static getFileIgnores(ignoreFiles) {\nif (!Array.isArray(ignoreFiles)) {\nignoreFiles = [ignoreFiles];\n}\nlet ignores = [];\n- let fileFound = false;\n- let dirs = [];\nfor (let ignorePath of ignoreFiles) {\nignorePath = TemplatePath.normalize(ignorePath);\nlet dir = TemplatePath.getDirFromFilePath(ignorePath);\n- dirs.push(dir);\nif (fs.existsSync(ignorePath) && fs.statSync(ignorePath).size > 0) {\n- fileFound = true;\nlet ignoreContent = fs.readFileSync(ignorePath, \"utf-8\");\n- // make sure that empty .gitignore with spaces takes default ignore.\n- if (ignoreContent.trim().length === 0) {\n- fileFound = false;\n- } else {\nignores = ignores.concat(\nEleventyFiles.normalizeIgnoreContent(dir, ignoreContent)\n);\n}\n}\n- }\n- if (!fileFound && defaultIfFileDoesNotExist) {\n- ignores.push(TemplateGlob.normalizePath(defaultIfFileDoesNotExist));\n- for (let dir of dirs) {\n- ignores.push(\n- TemplateGlob.normalizePath(dir, defaultIfFileDoesNotExist)\n- );\n- }\n- }\n+ ignores.forEach((path) => debug(`${ignoreFiles} ignoring: ${path}`));\n- ignores.forEach(function (path) {\n- debug(`${ignoreFiles} ignoring: ${path}`);\n- });\nreturn ignores;\n}\n@@ -296,15 +281,18 @@ class EleventyFiles {\n}\ngetIgnores() {\n- let files = [];\nlet rootDirectory = this.localPathRoot || TemplatePath.getWorkingDir();\n+ let files = [];\n+\n+ for (let ignore of this.config.ignores) {\n+ files = files.concat(TemplateGlob.normalizePath(rootDirectory, ignore));\n+ }\nif (this.config.useGitIgnore) {\nfiles = files.concat(\n- EleventyFiles.getFileIgnores(\n- [TemplatePath.join(rootDirectory, \".gitignore\")],\n- \"node_modules/**\"\n- )\n+ EleventyFiles.getFileIgnores([\n+ TemplatePath.join(rootDirectory, \".gitignore\"),\n+ ])\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -53,7 +53,11 @@ class UserConfig {\nthis.activeNamespace = \"\";\nthis.DateTime = DateTime;\nthis.dynamicPermalinks = true;\n+\nthis.useGitIgnore = true;\n+ this.ignores = new Set();\n+ this.ignores.add(\"node_modules/**\");\n+\nthis.dataDeepMerge = true;\nthis.extensionMap = new Set();\nthis.watchJavaScriptDependencies = true;\n@@ -708,6 +712,7 @@ class UserConfig {\nlibraryOverrides: this.libraryOverrides,\ndynamicPermalinks: this.dynamicPermalinks,\nuseGitIgnore: this.useGitIgnore,\n+ ignores: this.ignores,\ndataDeepMerge: this.dataDeepMerge,\nwatchJavaScriptDependencies: this.watchJavaScriptDependencies,\nadditionalWatchTargets: this.additionalWatchTargets,\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesGitIgnoreEleventyIgnoreTest.js", "new_path": "test/EleventyFilesGitIgnoreEleventyIgnoreTest.js", "diff": "@@ -18,7 +18,6 @@ test(\"Get ignores (no .eleventyignore no .gitignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n\"./test/stubs/ignorelocalroot/node_modules/**\",\n\"./test/stubs/ignorelocalroot/test.md\",\n\"./test/stubs/ignore1/_site/**\",\n@@ -37,6 +36,7 @@ test(\"Get ignores (no .eleventyignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\nt.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalrootgitignore/node_modules/**\",\n\"./test/stubs/ignorelocalrootgitignore/thisshouldnotexist12345\",\n\"./test/stubs/ignorelocalrootgitignore/test.md\",\n\"./test/stubs/ignore2/_site/**\",\n@@ -62,6 +62,7 @@ test(\"Get ignores (no .eleventyignore, using setUseGitIgnore(false))\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n\"./test/stubs/ignorelocalroot/test.md\",\n\"./test/stubs/ignore2/_site/**\",\n]);\n@@ -79,7 +80,6 @@ test(\"Get ignores (no .gitignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n\"./test/stubs/ignorelocalroot/node_modules/**\",\n\"./test/stubs/ignorelocalroot/test.md\",\n\"./test/stubs/ignore3/ignoredFolder/**\",\n@@ -100,6 +100,7 @@ test(\"Get ignores (project .eleventyignore and root .gitignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\nt.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalrootgitignore/node_modules/**\",\n\"./test/stubs/ignorelocalrootgitignore/thisshouldnotexist12345\",\n\"./test/stubs/ignorelocalrootgitignore/test.md\",\n\"./test/stubs/ignore4/ignoredFolder/**\",\n@@ -127,6 +128,7 @@ test(\"Get ignores (project .eleventyignore and root .gitignore, using setUseGitI\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalrootgitignore\");\nt.deepEqual(evf.getIgnores(), [\n+ \"./test/stubs/ignorelocalrootgitignore/node_modules/**\",\n\"./test/stubs/ignorelocalrootgitignore/test.md\",\n\"./test/stubs/ignore4/ignoredFolder/**\",\n\"./test/stubs/ignore4/ignoredFolder/ignored.md\",\n@@ -147,7 +149,6 @@ test(\"Get ignores (no .eleventyignore .gitignore exists but empty)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n\"./test/stubs/ignorelocalroot/node_modules/**\",\n\"./test/stubs/ignorelocalroot/test.md\",\n\"./test/stubs/ignore5/_site/**\",\n@@ -166,7 +167,6 @@ test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore is\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n\"./test/stubs/ignorelocalroot/node_modules/**\",\n\"./test/stubs/ignorelocalroot/test.md\",\n\"./test/stubs/ignore6/ignoredFolder/**\",\n@@ -175,47 +175,6 @@ test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore is\n]);\n});\n-test(\"Get ignores (no .eleventyignore .gitignore exists but has spaces inside)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore7\",\n- \"test/stubs/ignore7/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n-\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore7/_site/**\",\n- ]);\n-});\n-\n-test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore has spaces inside)\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs/ignore8\",\n- \"test/stubs/ignore8/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n- evf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\n-\n- t.deepEqual(evf.getIgnores(), [\n- \"./node_modules/**\",\n- \"./test/stubs/ignorelocalroot/node_modules/**\",\n- \"./test/stubs/ignorelocalroot/test.md\",\n- \"./test/stubs/ignore8/ignoredFolder/**\",\n- \"./test/stubs/ignore8/ignoredFolder/ignored.md\",\n- \"./test/stubs/ignore8/_site/**\",\n- ]);\n-});\n-\ntest(\"Bad expected output, this indicates a bug upstream in a dependency. Input to 'src' and empty includes dir (issue #403, full paths in eleventyignore)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet evf = new EleventyFiles(\n@@ -224,9 +183,11 @@ test(\"Bad expected output, this indicates a bug upstream in a dependency. Input\n[\"liquid\"],\neleventyConfig\n);\n+\nevf.setEleventyIgnoreContent(\n\"!\" + TemplatePath.absolutePath(\"test/stubs-403/_includes\") + \"/**\"\n);\n+\nevf._setConfig({\nuseGitIgnore: false,\ndir: {\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesTest.js", "new_path": "test/EleventyFilesTest.js", "diff": "const test = require(\"ava\");\nconst fastglob = require(\"fast-glob\");\nconst EleventyFiles = require(\"../src/EleventyFiles\");\n-const TemplatePath = require(\"../src/TemplatePath\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst TemplatePassthroughManager = require(\"../src/TemplatePassthroughManager\");\n@@ -224,13 +223,9 @@ test(\"Parse multiple .eleventyignores\", (t) => {\n);\n});\n-test(\"defaults if passed file name does not exist\", (t) => {\n- let ignores = EleventyFiles.getFileIgnores(\n- \".thisfiledoesnotexist\",\n- \"node_modules/**\"\n- );\n- t.truthy(ignores.length);\n- t.is(ignores[0], \"./node_modules/**\");\n+test(\"Passed file name does not exist\", (t) => {\n+ let ignores = EleventyFiles.getFileIgnores(\".thisfiledoesnotexist\");\n+ t.deepEqual(ignores, []);\n});\ntest(\".eleventyignore files\", async (t) => {\n" }, { "change_type": "DELETE", "old_path": "test/stubs/ignore7/.gitignore", "new_path": null, "diff": "-\n" }, { "change_type": "DELETE", "old_path": "test/stubs/ignore7/ignoredFolder/ignored.md", "new_path": null, "diff": "-# This should be ignored\n" }, { "change_type": "DELETE", "old_path": "test/stubs/ignore8/.eleventyignore", "new_path": null, "diff": "-ignoredFolder\n-./ignoredFolder/ignored.md\n-# This is a comment\n" }, { "change_type": "DELETE", "old_path": "test/stubs/ignore8/.gitignore", "new_path": null, "diff": "-\n" }, { "change_type": "DELETE", "old_path": "test/stubs/ignore8/ignoredFolder/ignored.md", "new_path": null, "diff": "-# This should be ignored\n" } ]
JavaScript
MIT License
11ty/eleventy
Always ignore node_modules by default. Previous behavior only ignored node_modules by default if you did not have a .gitignore or your .gitignore was empty. Opt-out using `eleventyConfig.ignores.delete("node_modules/**");` Also adds a configuration option to allow modification of ignores: `eleventyConfig.ignores.add("my_ignore_file.md");` Fixes #383 Fixes #1405 Fixes #894
699
14.06.2021 09:48:37
18,000
0407ef72e28c1010bca1883b35e2c59fec6cc45c
Removes experimental requirement for
[ { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -652,10 +652,6 @@ class UserConfig {\n}\naddExtension(fileExtension, options = {}) {\n- if (!process.env.ELEVENTY_EXPERIMENTAL) {\n- return;\n- }\n-\nthis.extensionMap.add(\nObject.assign(\n{\n" } ]
JavaScript
MIT License
11ty/eleventy
Removes experimental requirement for https://github.com/11ty/eleventy/issues/117
699
14.06.2021 17:43:29
18,000
a502bb104f81554acb068b2ff2ef0c6746f0fbf1
Fix for templates that have both build and serverless
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -256,12 +256,11 @@ class Template extends TemplateContent {\n// Makes page.url out of the serverless pathname\ngetServerlessOutputHref(data, resolvedLink) {\n- if (resolvedLink === false) {\nlet pathname = get(data, \"eleventy.serverless.pathname\");\nif (pathname) {\nreturn pathname;\n}\n- }\n+\nreturn resolvedLink;\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix https://github.com/11ty/eleventy/issues/1832 for templates that have both build and serverless
699
15.06.2021 07:04:38
18,000
bb70c464996f9c955cf0aee4cd136ee0a1817451
Fixes issues related to (both path and link should be false in serverless mode)
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -254,14 +254,11 @@ class Template extends TemplateContent {\nreturn this._usePermalinkRoot;\n}\n- // Makes page.url out of the serverless pathname\n- getServerlessOutputHref(data, resolvedLink) {\n+ _getServerlessPath(data) {\nlet pathname = get(data, \"eleventy.serverless.pathname\");\nif (pathname) {\nreturn pathname;\n}\n-\n- return resolvedLink;\n}\n// TODO instead of htmlIOException, do a global search to check if output path = input path and then add extra suffix\n@@ -275,15 +272,28 @@ class Template extends TemplateContent {\npath = link.toPath(this.outputDir);\n}\n+ // Makes page.url out of the serverless pathname\n+ let serverlessPath = this._getServerlessPath(data);\n+ if (serverlessPath) {\n+ return {\n+ link: false,\n+ href: serverlessPath,\n+ path: false,\n+ };\n+ }\n+\nreturn {\nlink: link.toLink(),\n- href: this.getServerlessOutputHref(data, link.toHref()),\n+ href: link.toHref(),\npath: path,\n};\n}\n// Preferred to use the singular `getOutputLocations` above.\nasync getOutputLink(data) {\n+ if (this._getServerlessPath(data)) {\n+ return false;\n+ }\nlet link = await this._getLink(data);\nreturn link.toLink();\n}\n@@ -291,11 +301,14 @@ class Template extends TemplateContent {\n// Preferred to use the singular `getOutputLocations` above.\nasync getOutputHref(data) {\nlet link = await this._getLink(data);\n- return this.getServerlessOutputHref(data, link.toHref());\n+ return this._getServerlessPath(data) || link.toHref();\n}\n// Preferred to use the singular `getOutputLocations` above.\nasync getOutputPath(data) {\n+ if (this._getServerlessPath(data)) {\n+ return false;\n+ }\nlet link = await this._getLink(data);\nif (await this.usePermalinkRoot()) {\nreturn link.toPathFromRoot();\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -2315,12 +2315,85 @@ test(\"Resolve page.url from eleventy serverless data\", async (t) => {\n},\n},\npermalink: {\n- serverless: \"/serverless/\",\n+ serverless: \"/serverless/\", // this is ignored and pathname above is used!\n},\n};\nlet outputHref = await tmpl.getOutputHref(fakeData);\nt.is(outputHref, \"/test/\");\n- let { href } = await tmpl.getOutputLocations(fakeData);\n+ let outputLink = await tmpl.getOutputLink(fakeData);\n+ t.is(outputLink, false);\n+\n+ let outputPath = await tmpl.getOutputPath(fakeData);\n+ t.is(outputPath, false);\n+\n+ let { href, link, path } = await tmpl.getOutputLocations(fakeData);\nt.is(href, \"/test/\");\n+ t.is(link, false);\n+ t.is(path, false);\n+});\n+\n+test(\"Resolve page.url from eleventy serverless data (when build also exists in permalink)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ let fakeData = {\n+ eleventy: {\n+ serverless: {\n+ pathname: \"/test/\",\n+ },\n+ },\n+ permalink: {\n+ build: \"/build/\",\n+ serverless: \"/serverless/\", // this is ignored and pathname above is used!\n+ },\n+ };\n+\n+ let outputHref = await tmpl.getOutputHref(fakeData);\n+ t.is(outputHref, \"/test/\");\n+\n+ // These should be false because the eleventy.serverless object is set.\n+ // When in build-mode they would not be false.\n+ let outputLink = await tmpl.getOutputLink(fakeData);\n+ t.is(outputLink, false);\n+\n+ let outputPath = await tmpl.getOutputPath(fakeData);\n+ t.is(outputPath, false);\n+\n+ let { href, link, path } = await tmpl.getOutputLocations(fakeData);\n+ t.is(href, \"/test/\");\n+ t.is(link, false);\n+ t.is(path, false);\n+});\n+\n+test(\"Do not resolve page.url from eleventy serverless data (when build also exists in permalink)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ let fakeData = {\n+ permalink: {\n+ build: \"/build/\",\n+ serverless: \"/serverless/\",\n+ },\n+ };\n+\n+ let outputHref = await tmpl.getOutputHref(fakeData);\n+ t.is(outputHref, \"/build/\");\n+\n+ // These should be false because the eleventy.serverless object is set.\n+ // When in build-mode they would not be false.\n+ let outputLink = await tmpl.getOutputLink(fakeData);\n+ t.is(outputLink, \"/build/index.html\");\n+\n+ let outputPath = await tmpl.getOutputPath(fakeData);\n+ t.is(outputPath, \"./test/stubs/_site/build/index.html\");\n+\n+ let { href, link, path } = await tmpl.getOutputLocations(fakeData);\n+ t.is(href, \"/build/\");\n+ t.is(link, \"/build/index.html\");\n+ t.is(path, \"./test/stubs/_site/build/index.html\");\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes issues related to #1832 (both path and link should be false in serverless mode)
699
15.06.2021 16:28:40
18,000
ff824ba9ddc012521d96412ee789847018c0ba03
Option to use build url for page.url in serverless mode.
[ { "change_type": "MODIFY", "old_path": "src/Serverless.js", "new_path": "src/Serverless.js", "diff": "@@ -21,6 +21,8 @@ class Serverless {\n{\ninputDir: \".\",\nfunctionsDir: \"functions/\",\n+ // Whether the serverless pathname overrides the page.url data value.\n+ pathnameOverridesPageUrl: true,\nmatchUrlToPattern(path, urlToCompare) {\nlet pattern = new UrlPattern(urlToCompare);\nreturn pattern.match(path);\n@@ -146,6 +148,7 @@ class Serverless {\n// Add the params to Global Data\neleventyConfig.addGlobalData(\"eleventy.serverless\", {\npathname: this.path,\n+ pathnameOverridesPageUrl: this.options.pathnameOverridesPageUrl,\nquery: this.options.query,\npath: pathParams,\n});\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -254,6 +254,10 @@ class Template extends TemplateContent {\nreturn this._usePermalinkRoot;\n}\n+ _useServerlessOverride(data) {\n+ return get(data, \"eleventy.serverless.pathnameOverridesPageUrl\", true);\n+ }\n+\n_getServerlessPath(data) {\nlet pathname = get(data, \"eleventy.serverless.pathname\");\nif (pathname) {\n@@ -277,7 +281,9 @@ class Template extends TemplateContent {\nif (serverlessPath) {\nreturn {\nlink: false,\n- href: serverlessPath,\n+ href: this._useServerlessOverride(data)\n+ ? serverlessPath\n+ : link.toHref(),\npath: false,\n};\n}\n@@ -301,7 +307,10 @@ class Template extends TemplateContent {\n// Preferred to use the singular `getOutputLocations` above.\nasync getOutputHref(data) {\nlet link = await this._getLink(data);\n- return this._getServerlessPath(data) || link.toHref();\n+ let pathname = this._getServerlessPath(data);\n+ return pathname && this._useServerlessOverride(data)\n+ ? pathname\n+ : link.toHref();\n}\n// Preferred to use the singular `getOutputLocations` above.\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -2396,3 +2396,39 @@ test(\"Do not resolve page.url from eleventy serverless data (when build also exi\nt.is(link, \"/build/index.html\");\nt.is(path, \"./test/stubs/_site/build/index.html\");\n});\n+\n+test(\"Do not override page.url with serverless url\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ let fakeData = {\n+ eleventy: {\n+ serverless: {\n+ pathname: \"/test/\",\n+ pathnameOverridesPageUrl: false,\n+ },\n+ },\n+ permalink: {\n+ build: \"/build/\",\n+ serverless: \"/serverless/\",\n+ },\n+ };\n+\n+ let outputHref = await tmpl.getOutputHref(fakeData);\n+ t.is(outputHref, \"/build/\");\n+\n+ // These should be false because the eleventy.serverless object is set.\n+ // When in build-mode they would not be false.\n+ let outputLink = await tmpl.getOutputLink(fakeData);\n+ t.is(outputLink, false);\n+\n+ let outputPath = await tmpl.getOutputPath(fakeData);\n+ t.is(outputPath, false);\n+\n+ let { href, link, path } = await tmpl.getOutputLocations(fakeData);\n+ t.is(href, \"/build/\");\n+ t.is(link, false);\n+ t.is(path, false);\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Option to use build url for page.url in serverless mode.
699
16.06.2021 09:27:06
18,000
3344c8e054c59ea4bdb8385f9e51ce90f2d94fe5
Fix for page.filePathStem in serverless mode.
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -96,6 +96,13 @@ class Eleventy {\n*/\nthis.isDryRun = false;\n+ /**\n+ * @member {Boolean} - Explicit input directory (usually used when input is a single file/serverless)\n+ */\n+ if (options.inputDir) {\n+ this.setInputDir(options.inputDir);\n+ }\n+\nif (performance) {\ndebug(\"Eleventy warm up time (in ms) %o\", performance.now());\n}\n@@ -374,6 +381,7 @@ Verbose Output: ${this.verboseMode}`);\ngetEnvironmentVariableValues() {\nlet configPath = this.eleventyConfig.getLocalProjectConfigFile();\nlet absolutePathToConfig = TemplatePath.absolutePath(configPath);\n+ // TODO(zachleat): if config is not in root (e.g. using --config=)\nlet root = TemplatePath.getDirFromFilePath(absolutePathToConfig);\nreturn {\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyFiles.js", "new_path": "src/EleventyFiles.js", "diff": "@@ -70,6 +70,7 @@ class EleventyFiles {\nif (this.input === this.inputDir) {\nthis.templateGlobs = this.extensionMap.getGlobs(this.inputDir);\n} else {\n+ // input is not a directory\nthis.templateGlobs = TemplateGlob.map([this.input]);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Serverless.js", "new_path": "src/Serverless.js", "diff": "@@ -113,7 +113,7 @@ class Serverless {\nprocess.chdir(this.dir);\n}\n- let inputDir = path.join(this.dir, this.options.inputDir);\n+ let inputDir = this.options.inputDir;\nlet configPath = path.join(this.dir, this.configFilename);\nlet { pathParams, inputPath } = this.matchUrlPattern(this.path);\n@@ -133,11 +133,12 @@ class Serverless {\ndebug(`Input dir: ${inputDir}`);\ndebug(`Requested URL: ${this.path}`);\n- debug(`Path params: ${pathParams}`);\n+ debug(\"Path params: %o\", pathParams);\ndebug(`Input path: ${inputPath}`);\nlet elev = new Eleventy(inputPath, null, {\nconfigPath,\n+ inputDir,\nconfig: (eleventyConfig) => {\nif (Object.keys(this.options.precompiledCollections).length > 0) {\neleventyConfig.setPrecompiledCollections(\n@@ -146,16 +147,22 @@ class Serverless {\n}\n// Add the params to Global Data\n- eleventyConfig.addGlobalData(\"eleventy.serverless\", {\n+ let globalData = {\npathname: this.path,\n- pathnameOverridesPageUrl: this.options.pathnameOverridesPageUrl,\nquery: this.options.query,\npath: pathParams,\n- });\n+ };\n+\n+ // leave out if default value\n+ if (!this.options.pathnameOverridesPageUrl) {\n+ globalData.pathnameOverridesPageUrl =\n+ this.options.pathnameOverridesPageUrl;\n+ }\n+\n+ eleventyConfig.addGlobalData(\"eleventy.serverless\", globalData);\n},\n});\n- elev.setInputDir(inputDir);\nawait elev.init();\nlet json = await elev.toJSON();\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix for page.filePathStem in serverless mode.
699
22.06.2021 21:20:02
18,000
52bb4f97075089b3b61e104e76a74372a6fe17f8
Adds support for page.url in serverless templates. Resolve urls with :path :vars using the serverlessUrl filter. Use an array of urls in serverless keys. Toggle the serverless bundler on and off using the `bundlerEnabled` option in the plugin.
[ { "change_type": "MODIFY", "old_path": "src/ComputedDataTemplateString.js", "new_path": "src/ComputedDataTemplateString.js", "diff": "@@ -55,8 +55,13 @@ class ComputedDataTemplateString {\n} catch (e) {\ndebug(\"Computed Data first pass data resolution error: %o\", e);\n}\n+\n+ // page.outputPath on serverless urls returns false.\n+ if (typeof output === \"string\") {\nreturn this.findVarsInOutput(output);\n}\n+ return [];\n+ }\n}\nmodule.exports = ComputedDataTemplateString;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Filters/ServerlessUrl.js", "diff": "+const UrlPattern = require(\"url-pattern\");\n+\n+function stringify(url, urlData = {}) {\n+ let pattern = new UrlPattern(url);\n+ return pattern.stringify(urlData);\n+}\n+\n+module.exports = function (url, urlData = {}) {\n+ if (Array.isArray(url)) {\n+ return url.slice().map((entry) => stringify(entry, urlData));\n+ }\n+\n+ return stringify(url, urlData);\n+};\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/ServerlessBundlerPlugin.js", "new_path": "src/Plugins/ServerlessBundlerPlugin.js", "diff": "@@ -156,13 +156,23 @@ class BundlerHelper {\n}\nwriteDependencyEntryFile() {\n- this.writeBundlerDependenciesFile(\"eleventy-bundler-modules.js\", [\n+ // we write this even when disabled because the serverless function expects it\n+ this.writeBundlerDependenciesFile(\n+ \"eleventy-bundler-modules.js\",\n+ this.options.bundlerEnabled\n+ ? [\n\"./eleventy-app-config-modules.js\",\n\"./eleventy-app-globaldata-modules.js\",\n- ]);\n+ ]\n+ : []\n+ );\n}\nwriteDependencyConfigFile(configPath) {\n+ if (!this.options.bundlerEnabled) {\n+ return;\n+ }\n+\nlet modules = getNodeModulesList([configPath]);\nthis.writeBundlerDependenciesFile(\n\"eleventy-app-config-modules.js\",\n@@ -173,6 +183,10 @@ class BundlerHelper {\n}\nwriteDependencyGlobalDataFile(globalDataFileList) {\n+ if (!this.options.bundlerEnabled) {\n+ return;\n+ }\n+\nlet modules = getNodeModulesList(globalDataFileList);\nthis.writeBundlerDependenciesFile(\n\"eleventy-app-globaldata-modules.js\",\n@@ -233,6 +247,9 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n// Add automated redirects (appends or creates, avoids duplicate entries)\n// Also accepts a custom callback function(name, outputMap)\nredirects: \"netlify-toml\",\n+\n+ // Useful for local develop to disable all bundle copying\n+ bundlerEnabled: true,\n},\noptions\n);\n@@ -256,6 +273,10 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n});\neleventyConfig.on(\"eleventy.after\", async () => {\n+ if (!options.bundlerEnabled) {\n+ return;\n+ }\n+\n// extra copy targets\n// we put these in after a build so that we can grab files generated _by_ the build too\nif (options.copy && Array.isArray(options.copy)) {\n@@ -283,7 +304,10 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n});\neleventyConfig.on(\"eleventy.env\", (env) => {\n+ if (options.bundlerEnabled) {\nhelper.copyFile(env.config, \"eleventy.config.js\");\n+ }\n+\nhelper.writeDependencyConfigFile(env.config);\n});\n@@ -292,6 +316,10 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n});\neleventyConfig.on(\"eleventy.directories\", async (dirs) => {\n+ if (!options.bundlerEnabled) {\n+ return;\n+ }\n+\nlet promises = [];\npromises.push(helper.recursiveCopy(dirs.data));\npromises.push(helper.recursiveCopy(dirs.includes));\n@@ -341,7 +369,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nthis.copyCount++;\n// Write redirects (even if no redirects exist for this function to handle deletes)\n- if (options.redirects) {\n+ if (options.bundlerEnabled && options.redirects) {\nif (\ntypeof options.redirects === \"string\" &&\nredirectHandlers[options.redirects]\n@@ -352,7 +380,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\n}\n- if (mapEntryCount > 0) {\n+ if (options.bundlerEnabled && mapEntryCount > 0) {\n// Copy templates to bundle folder\nfor (let url in outputMap) {\nhelper.recursiveCopy(outputMap[url]);\n" }, { "change_type": "MODIFY", "old_path": "src/Serverless.js", "new_path": "src/Serverless.js", "diff": "@@ -21,8 +21,6 @@ class Serverless {\n{\ninputDir: \".\",\nfunctionsDir: \"functions/\",\n- // Whether the serverless pathname overrides the page.url data value.\n- pathnameOverridesPageUrl: true,\nmatchUrlToPattern(path, urlToCompare) {\nlet pattern = new UrlPattern(urlToCompare);\nreturn pattern.match(path);\n@@ -113,7 +111,7 @@ class Serverless {\nprocess.chdir(this.dir);\n}\n- let inputDir = this.options.inputDir;\n+ let inputDir = this.options.input || this.options.inputDir;\nlet configPath = path.join(this.dir, this.configFilename);\nlet { pathParams, inputPath } = this.matchUrlPattern(this.path);\n@@ -136,7 +134,7 @@ class Serverless {\ndebug(\"Path params: %o\", pathParams);\ndebug(`Input path: ${inputPath}`);\n- let elev = new Eleventy(inputPath, null, {\n+ let elev = new Eleventy(this.options.input || inputPath, null, {\nconfigPath,\ninputDir,\nconfig: (eleventyConfig) => {\n@@ -148,17 +146,10 @@ class Serverless {\n// Add the params to Global Data\nlet globalData = {\n- pathname: this.path,\nquery: this.options.query,\npath: pathParams,\n};\n- // leave out if default value\n- if (!this.options.pathnameOverridesPageUrl) {\n- globalData.pathnameOverridesPageUrl =\n- this.options.pathnameOverridesPageUrl;\n- }\n-\neleventyConfig.addGlobalData(\"eleventy.serverless\", globalData);\n},\n});\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -282,7 +282,15 @@ class TemplateContent {\n}\n}\n+ async renderPermalink(permalink, data, bypassMarkdown) {\n+ return this._render(permalink, data, bypassMarkdown);\n+ }\n+\nasync render(str, data, bypassMarkdown) {\n+ return this._render(str, data, bypassMarkdown);\n+ }\n+\n+ async _render(str, data, bypassMarkdown) {\ntry {\nlet fn = await this.compile(str, bypassMarkdown);\nlet templateBenchmark = bench.get(\"Template Render\");\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -462,6 +462,9 @@ class TemplateData {\ndeleteRequireCache(localPath);\nlet returnValue = require(localPath);\n+ // TODO special exception for Global data `permalink.js`\n+ // module.exports = (data) => `${data.page.filePathStem}/`; // Does not work\n+ // module.exports = () => ((data) => `${data.page.filePathStem}/`); // Works\nif (typeof returnValue === \"function\") {\nreturnValue = await returnValue(this.configApiGlobalData || {});\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePermalink.js", "new_path": "src/TemplatePermalink.js", "diff": "@@ -11,18 +11,35 @@ class TemplatePermalink {\nthis._isRendered = true;\nthis._writeToFileSystem = true;\n- let rawLink;\n+ let buildLink;\n+\nif (isLinkAnObject) {\nif (\"build\" in link) {\n- rawLink = link.build;\n+ buildLink = link.build;\n+ }\n+\n+ // find the first string key\n+ for (let key in link) {\n+ if (typeof key !== \"string\") {\n+ continue;\n+ }\n+ if (key !== \"build\" && link[key] !== false) {\n+ // is array of serverless urls, use the first one\n+ if (Array.isArray(link[key])) {\n+ this.primaryServerlessUrl = link[key][0];\n+ } else {\n+ this.primaryServerlessUrl = link[key];\n+ }\n+ }\n+ break;\n}\n} else {\n- rawLink = link;\n+ buildLink = link;\n}\n// permalink: false and permalink: build: false\n- if (typeof rawLink === \"boolean\") {\n- if (rawLink === false) {\n+ if (typeof buildLink === \"boolean\") {\n+ if (buildLink === false) {\nthis._writeToFileSystem = false;\n} else {\nthrow new Error(\n@@ -33,8 +50,8 @@ class TemplatePermalink {\n}false\\`?`\n);\n}\n- } else if (rawLink) {\n- this.rawLink = rawLink;\n+ } else if (buildLink) {\n+ this.buildLink = buildLink;\n}\nthis.serverlessUrls = {};\n@@ -57,17 +74,19 @@ class TemplatePermalink {\nreturn this.serverlessUrls;\n}\n- _cleanLink(link) {\n+ _addDefaultLinkFilename(link) {\nreturn link + (link.substr(-1) === \"/\" ? \"index.html\" : \"\");\n}\ntoLink() {\n- if (!this.rawLink) {\n+ if (this.primaryServerlessUrl) {\n+ return this.primaryServerlessUrl;\n+ } else if (!this.buildLink) {\n// empty or false\nreturn false;\n}\n- let cleanLink = this._cleanLink(this.rawLink);\n+ let cleanLink = this._addDefaultLinkFilename(this.buildLink);\nlet parsed = parsePath(cleanLink);\nreturn TemplatePath.join(\n@@ -84,7 +103,9 @@ class TemplatePermalink {\n// index.html becomes /\n// test/index.html becomes test/\ntoHref() {\n- if (!this.rawLink) {\n+ if (this.primaryServerlessUrl) {\n+ return this.primaryServerlessUrl;\n+ } else if (!this.buildLink) {\n// empty or false\nreturn false;\n}\n@@ -102,6 +123,10 @@ class TemplatePermalink {\n}\ntoPath(outputDir) {\n+ if (!this.buildLink) {\n+ return false;\n+ }\n+\nlet uri = this.toLink();\nif (uri === false) {\n@@ -112,6 +137,10 @@ class TemplatePermalink {\n}\ntoPathFromRoot() {\n+ if (!this.buildLink) {\n+ return false;\n+ }\n+\nlet uri = this.toLink();\nif (uri === false) {\n" }, { "change_type": "MODIFY", "old_path": "src/defaultConfig.js", "new_path": "src/defaultConfig.js", "diff": "const urlFilter = require(\"./Filters/Url\");\n+const serverlessUrlFilter = require(\"./Filters/ServerlessUrl\");\nconst slugFilter = require(\"./Filters/Slug\");\nconst getCollectionItem = require(\"./Filters/GetCollectionItem\");\n@@ -12,6 +13,8 @@ module.exports = function (config) {\n});\nconfig.addFilter(\"log\", console.log);\n+ config.addFilter(\"serverlessUrl\", serverlessUrlFilter);\n+\nconfig.addFilter(\"getCollectionItem\", (collection, page) =>\ngetCollectionItem(collection, page)\n);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePermalinkTest.js", "new_path": "test/TemplatePermalinkTest.js", "diff": "@@ -171,45 +171,89 @@ test(\"Permalink Object, just build\", (t) => {\n});\ntest(\"Permalink Object, serverless URLs\", (t) => {\n+ // serverless\nt.is(\nnew TemplatePermalink({\nserverless: \"permalinksubfolder/test.html\",\n}).toLink(),\n- false\n+ \"permalinksubfolder/test.html\"\n);\nt.is(\nnew TemplatePermalink({\nserverless: \"permalinksubfolder/test.html\",\n}).toHref(),\n- false\n+ \"permalinksubfolder/test.html\"\n);\n+ // request\nt.is(\nnew TemplatePermalink({\nrequest: \"/url/\",\n}).toLink(),\n- false\n+ \"/url/\"\n);\nt.is(\nnew TemplatePermalink({\nrequest: \"/url/\",\n}).toHref(),\n- false\n+ \"/url/\"\n);\n+ // rando\nt.is(\nnew TemplatePermalink({\nrando: \"/url/\",\n}).toLink(),\n- false\n+ \"/url/\"\n);\nt.is(\nnew TemplatePermalink({\nrando: \"/url/\",\n}).toHref(),\n- false\n+ \"/url/\"\n+ );\n+});\n+\n+test(\"Permalink Object, combo build and serverless URLs\", (t) => {\n+ t.is(\n+ new TemplatePermalink({\n+ build: \"/url/\",\n+ serverless: \"/serverless/\",\n+ }).toLink(),\n+ \"/url/index.html\"\n+ );\n+\n+ t.is(\n+ new TemplatePermalink({\n+ build: \"/url/\",\n+ serverless: \"/serverless/\",\n+ }).toHref(),\n+ \"/url/\"\n+ );\n+\n+ // reordered, serverless is primary\n+ t.is(\n+ new TemplatePermalink({\n+ serverless: \"/serverless/\",\n+ build: \"/url/\",\n+ }).toLink(),\n+ \"/serverless/\"\n);\n+\n+ t.is(\n+ new TemplatePermalink({\n+ serverless: \"/serverless/\",\n+ build: \"/url/\",\n+ }).toHref(),\n+ \"/serverless/\"\n+ );\n+});\n+\n+test(\"Permalink Object, empty object\", (t) => {\n+ t.is(new TemplatePermalink({}).toLink(), false);\n+\n+ t.is(new TemplatePermalink({}).toHref(), false);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -2250,8 +2250,8 @@ test(\"permalink object without build\", async (t) => {\n\"./test/stubs/_site\"\n);\n- t.is(await tmpl.getOutputLink(), false);\n- t.is(await tmpl.getOutputHref(), false);\n+ t.is(await tmpl.getOutputLink(), \"/url/\");\n+ t.is(await tmpl.getOutputHref(), \"/url/\");\n});\ntest(\"permalink object _getLink\", async (t) => {\n@@ -2266,8 +2266,9 @@ test(\"permalink object _getLink\", async (t) => {\nserverless: \"/serverless/\",\n},\n});\n- t.is(await link.toLink(), false);\n- t.is(await link.toHref(), false);\n+ t.is(await link.toLink(), \"/serverless/\");\n+ t.is(await link.toHref(), \"/serverless/\");\n+\nt.deepEqual(link.getServerlessUrls(), {\nserverless: \"/serverless/\",\n});\n@@ -2299,75 +2300,129 @@ test(\"permalink object _getLink\", async (t) => {\nt.deepEqual(tmpl.getServerlessUrls(), {\nserverless: \"/serverless/\",\n});\n+\n+ // template syntax\n+ let link4 = await tmpl._getLink({\n+ test: \"a\",\n+ permalink: {\n+ build: \"/build{{ test }}/\",\n+ serverless: \"/serverless{{ test }}/\",\n+ },\n+ });\n+ t.is(await link4.toLink(), \"/builda/index.html\");\n+ t.is(await link4.toHref(), \"/builda/\");\n+ t.deepEqual(link4.getServerlessUrls(), {\n+ serverless: \"/serverlessa/\",\n+ });\n+ t.deepEqual(tmpl.getServerlessUrls(), {\n+ serverless: \"/serverlessa/\",\n+ });\n});\n-test(\"Resolve page.url from eleventy serverless data\", async (t) => {\n+test(\"permalink object _getLink (array of serverless URLs)\", async (t) => {\nlet tmpl = getNewTemplate(\n- \"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n+ \"./test/stubs/permalink-nobuild/permalink-nobuild.md\",\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\n- let fakeData = {\n- eleventy: {\n- serverless: {\n- pathname: \"/test/\",\n+\n+ // Array of URLs is supported\n+ let link4 = await tmpl._getLink({\n+ permalink: {\n+ serverless: [\"/serverless1/\", \"/serverless2/\"],\n},\n+ });\n+ t.is(await link4.toLink(), \"/serverless1/\");\n+ t.is(await link4.toHref(), \"/serverless1/\");\n+\n+ t.deepEqual(link4.getServerlessUrls(), {\n+ serverless: [\"/serverless1/\", \"/serverless2/\"],\n+ });\n+ t.deepEqual(tmpl.getServerlessUrls(), {\n+ serverless: [\"/serverless1/\", \"/serverless2/\"],\n+ });\n+});\n+\n+test(\"permalink object _getLink (array of serverless URLs with template syntax)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-nobuild/permalink-nobuild.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ // Array of URLs is supported\n+ let link = await tmpl._getLink({\n+ test: \"a\",\n+ permalink: {\n+ serverless: [\"/serverless1{{ test }}/\", \"/serverless2{{ test }}/\"],\n},\n+ });\n+ t.is(await link.toLink(), \"/serverless1a/\");\n+ t.is(await link.toHref(), \"/serverless1a/\");\n+\n+ t.deepEqual(link.getServerlessUrls(), {\n+ serverless: [\"/serverless1a/\", \"/serverless2a/\"],\n+ });\n+ t.deepEqual(tmpl.getServerlessUrls(), {\n+ serverless: [\"/serverless1a/\", \"/serverless2a/\"],\n+ });\n+});\n+\n+test(\"Do not resolve page.url from eleventy serverless data\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ let fakeData = {\npermalink: {\n- serverless: \"/serverless/\", // this is ignored and pathname above is used!\n+ serverless: \"/serverless/\",\n},\n};\nlet outputHref = await tmpl.getOutputHref(fakeData);\n- t.is(outputHref, \"/test/\");\n+ t.is(outputHref, \"/serverless/\");\nlet outputLink = await tmpl.getOutputLink(fakeData);\n- t.is(outputLink, false);\n+ t.is(outputLink, \"/serverless/\");\nlet outputPath = await tmpl.getOutputPath(fakeData);\nt.is(outputPath, false);\nlet { href, link, path } = await tmpl.getOutputLocations(fakeData);\n- t.is(href, \"/test/\");\n- t.is(link, false);\n+ t.is(href, \"/serverless/\");\n+ t.is(link, \"/serverless/\");\nt.is(path, false);\n});\n-test(\"Resolve page.url from eleventy serverless data (when build also exists in permalink)\", async (t) => {\n+test(\"Do not resolve page.url from eleventy serverless data (when build also exists in permalink and serverless global data exists)\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\nlet fakeData = {\n- eleventy: {\n- serverless: {\n- pathname: \"/test/\",\n- },\n- },\npermalink: {\nbuild: \"/build/\",\n- serverless: \"/serverless/\", // this is ignored and pathname above is used!\n+ serverless: \"/serverless/\",\n},\n};\nlet outputHref = await tmpl.getOutputHref(fakeData);\n- t.is(outputHref, \"/test/\");\n+ t.is(outputHref, \"/build/\");\n- // These should be false because the eleventy.serverless object is set.\n- // When in build-mode they would not be false.\nlet outputLink = await tmpl.getOutputLink(fakeData);\n- t.is(outputLink, false);\n+ t.is(outputLink, \"/build/index.html\");\nlet outputPath = await tmpl.getOutputPath(fakeData);\n- t.is(outputPath, false);\n+ t.is(outputPath, \"./test/stubs/_site/build/index.html\");\nlet { href, link, path } = await tmpl.getOutputLocations(fakeData);\n- t.is(href, \"/test/\");\n- t.is(link, false);\n- t.is(path, false);\n+ t.is(href, \"/build/\");\n+ t.is(link, \"/build/index.html\");\n+ t.is(path, \"./test/stubs/_site/build/index.html\");\n});\n-test(\"Do not resolve page.url from eleventy serverless data (when build also exists in permalink)\", async (t) => {\n+test(\"Do not resolve page.url from eleventy serverless data (when build also exists in permalink and serverless global data does not exist)\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n\"./test/stubs/\",\n@@ -2404,12 +2459,6 @@ test(\"Do not override page.url with serverless url\", async (t) => {\n\"./test/stubs/_site\"\n);\nlet fakeData = {\n- eleventy: {\n- serverless: {\n- pathname: \"/test/\",\n- pathnameOverridesPageUrl: false,\n- },\n- },\npermalink: {\nbuild: \"/build/\",\nserverless: \"/serverless/\",\n@@ -2419,16 +2468,43 @@ test(\"Do not override page.url with serverless url\", async (t) => {\nlet outputHref = await tmpl.getOutputHref(fakeData);\nt.is(outputHref, \"/build/\");\n- // These should be false because the eleventy.serverless object is set.\n- // When in build-mode they would not be false.\nlet outputLink = await tmpl.getOutputLink(fakeData);\n- t.is(outputLink, false);\n+ t.is(outputLink, \"/build/index.html\");\nlet outputPath = await tmpl.getOutputPath(fakeData);\n- t.is(outputPath, false);\n+ t.is(outputPath, \"./test/stubs/_site/build/index.html\");\nlet { href, link, path } = await tmpl.getOutputLocations(fakeData);\nt.is(href, \"/build/\");\n- t.is(link, false);\n- t.is(path, false);\n+ t.is(link, \"/build/index.html\");\n+ t.is(path, \"./test/stubs/_site/build/index.html\");\n+});\n+\n+test(\"Permalink is an object but an empty object (inherit default behavior)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-empty-object/empty-object.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ let data = await tmpl.getData();\n+\n+ let outputHref = await tmpl.getOutputHref(data);\n+ t.is(outputHref, \"/permalink-empty-object/empty-object/\");\n+\n+ let outputLink = await tmpl.getOutputLink(data);\n+ t.is(outputLink, \"permalink-empty-object/empty-object/index.html\");\n+\n+ let outputPath = await tmpl.getOutputPath(data);\n+ t.is(\n+ outputPath,\n+ \"./test/stubs/_site/permalink-empty-object/empty-object/index.html\"\n+ );\n+\n+ let { href, link, path } = await tmpl.getOutputLocations(data);\n+ t.is(href, \"/permalink-empty-object/empty-object/\");\n+ t.is(link, \"permalink-empty-object/empty-object/index.html\");\n+ t.is(\n+ path,\n+ \"./test/stubs/_site/permalink-empty-object/empty-object/index.html\"\n+ );\n});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/permalink-empty-object/empty-object.md", "diff": "+---\n+permalink: {}\n+---\n+\n+This should be the same as if permalink was not set at all.\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds support for page.url in serverless templates. Resolve urls with :path :vars using the serverlessUrl filter. Use an array of urls in serverless keys. Toggle the serverless bundler on and off using the `bundlerEnabled` option in the plugin.
699
23.06.2021 21:51:57
18,000
9936e25b7ba8abeb4d1297ed50163801d2de69f9
Prefer path to be included in the options object.
[ { "change_type": "MODIFY", "old_path": "src/Serverless.js", "new_path": "src/Serverless.js", "diff": "@@ -9,7 +9,21 @@ const debug = require(\"debug\")(\"Eleventy:Serverless\");\nclass Serverless {\nconstructor(name, path, options = {}) {\nthis.name = name;\n+\n+ // second argument is path\n+ if (typeof path === \"string\") {\nthis.path = path;\n+ } else {\n+ // options is the second argument and path is inside options\n+ options = path;\n+ this.path = options.path;\n+ }\n+\n+ if (!this.path) {\n+ throw new Error(\n+ \"`path` must exist in the options argument in Eleventy Serverless.\"\n+ );\n+ }\n// ServerlessBundlerPlugin hard-codes to this (even if you used a different file name)\nthis.configFilename = \"eleventy.config.js\";\n" } ]
JavaScript
MIT License
11ty/eleventy
Prefer path to be included in the options object.
699
23.06.2021 21:54:00
18,000
0e54cce4be241fe3fd72fedfb8ccae1b1840f223
Generate serverless function file if one does not exist.
[ { "change_type": "MODIFY", "old_path": "src/Plugins/ServerlessBundlerPlugin.js", "new_path": "src/Plugins/ServerlessBundlerPlugin.js", "diff": "const fs = require(\"fs\");\n+const fsp = fs.promises;\nconst path = require(\"path\");\nconst TOML = require(\"@iarna/toml\");\nconst copy = require(\"recursive-copy\");\n@@ -159,7 +160,7 @@ class BundlerHelper {\n// we write this even when disabled because the serverless function expects it\nthis.writeBundlerDependenciesFile(\n\"eleventy-bundler-modules.js\",\n- this.options.bundlerEnabled\n+ this.options.copyEnabled\n? [\n\"./eleventy-app-config-modules.js\",\n\"./eleventy-app-globaldata-modules.js\",\n@@ -169,7 +170,7 @@ class BundlerHelper {\n}\nwriteDependencyConfigFile(configPath) {\n- if (!this.options.bundlerEnabled) {\n+ if (!this.options.copyEnabled) {\nreturn;\n}\n@@ -183,7 +184,7 @@ class BundlerHelper {\n}\nwriteDependencyGlobalDataFile(globalDataFileList) {\n- if (!this.options.bundlerEnabled) {\n+ if (!this.options.copyEnabled) {\nreturn;\n}\n@@ -225,9 +226,36 @@ class BundlerHelper {\nres.write(result.body);\nres.end();\n- console.log(`Dynamic Render: ${req.url} (${Date.now() - start}ms)`);\n+ console.log(\n+ `Serverless (${this.name}): ${req.url} (${Date.now() - start}ms)`\n+ );\n};\n}\n+\n+ async ensureDir() {\n+ return fsp.mkdir(this.getOutputPath(\"\"), {\n+ recursive: true,\n+ });\n+ }\n+\n+ async writeServerlessFunctionFile() {\n+ let filepath = this.getOutputPath(\"index.js\");\n+ if (!fs.existsSync(filepath)) {\n+ let defaultContentPath = TemplatePath.absolutePath(\n+ __dirname,\n+ \"./DefaultServerlessFunctionContent.js\"\n+ );\n+\n+ let contents = await fsp.readFile(defaultContentPath, \"utf-8\");\n+ contents = contents.replace(/\\%\\%NAME\\%\\%/g, this.name);\n+ contents = contents.replace(/\\%\\%INPUT_DIR\\%\\%/g, this.options.inputDir);\n+ contents = contents.replace(\n+ /\\%\\%FUNCTIONS_DIR\\%\\%/g,\n+ this.options.functionsDir\n+ );\n+ return fsp.writeFile(filepath, contents);\n+ }\n+ }\n}\nfunction EleventyPlugin(eleventyConfig, options = {}) {\n@@ -249,7 +277,10 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nredirects: \"netlify-toml\",\n// Useful for local develop to disable all bundle copying\n- bundlerEnabled: true,\n+ copyEnabled: true,\n+\n+ // Input directory (used to generate the default serverless file)\n+ inputDir: \".\",\n},\noptions\n);\n@@ -269,11 +300,13 @@ function EleventyPlugin(eleventyConfig, options = {}) {\neleventyConfig.on(\"eleventy.before\", async () => {\nhelper.reset();\n+ await helper.ensureDir();\n+ await helper.writeServerlessFunctionFile();\nhelper.writeDependencyEntryFile();\n});\neleventyConfig.on(\"eleventy.after\", async () => {\n- if (!options.bundlerEnabled) {\n+ if (!options.copyEnabled) {\nreturn;\n}\n@@ -303,12 +336,14 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n);\n});\n- eleventyConfig.on(\"eleventy.env\", (env) => {\n- if (options.bundlerEnabled) {\n+ eleventyConfig.on(\"eleventy.env\", async (env) => {\n+ await helper.ensureDir();\n+\n+ if (options.copyEnabled) {\nhelper.copyFile(env.config, \"eleventy.config.js\");\n- }\nhelper.writeDependencyConfigFile(env.config);\n+ }\n});\neleventyConfig.on(\"eleventy.globalDataFiles\", (fileList) => {\n@@ -316,7 +351,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n});\neleventyConfig.on(\"eleventy.directories\", async (dirs) => {\n- if (!options.bundlerEnabled) {\n+ if (!options.copyEnabled) {\nreturn;\n}\n@@ -369,7 +404,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nthis.copyCount++;\n// Write redirects (even if no redirects exist for this function to handle deletes)\n- if (options.bundlerEnabled && options.redirects) {\n+ if (options.copyEnabled && options.redirects) {\nif (\ntypeof options.redirects === \"string\" &&\nredirectHandlers[options.redirects]\n@@ -380,7 +415,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\n}\n- if (options.bundlerEnabled && mapEntryCount > 0) {\n+ if (options.copyEnabled && mapEntryCount > 0) {\n// Copy templates to bundle folder\nfor (let url in outputMap) {\nhelper.recursiveCopy(outputMap[url]);\n" } ]
JavaScript
MIT License
11ty/eleventy
Generate serverless function file if one does not exist.
699
25.06.2021 21:30:23
18,000
571f8cf5bc124f7a0bd35d891797f377ddb54b0e
Data, Includes, and Layouts directories should not be required by the bundler.
[ { "change_type": "MODIFY", "old_path": "src/Plugins/ServerlessBundlerPlugin.js", "new_path": "src/Plugins/ServerlessBundlerPlugin.js", "diff": "const fs = require(\"fs\");\nconst fsp = fs.promises;\nconst path = require(\"path\");\n+const isGlob = require(\"is-glob\");\nconst TOML = require(\"@iarna/toml\");\nconst copy = require(\"recursive-copy\");\nconst dependencyTree = require(\"@11ty/dependency-tree\");\n@@ -127,6 +128,7 @@ class BundlerHelper {\n}\nrecursiveCopy(src, dest, options = {}) {\n+ if (isGlob(src) || fs.existsSync(src)) {\nlet finalDest = this.getOutputPath(dest || src);\nreturn copy(\nsrc,\n@@ -145,6 +147,7 @@ class BundlerHelper {\nthis.copyCount++;\n});\n}\n+ }\nwriteBundlerDependenciesFile(filename, deps = []) {\nlet modules = deps.map((name) => `require(\"${name}\");`);\n" } ]
JavaScript
MIT License
11ty/eleventy
Data, Includes, and Layouts directories should not be required by the bundler.
699
30.06.2021 10:06:41
18,000
e7811f43b80340eda349493327cdef402c7c5940
Get those console logs out of the tests.
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"bugs\": \"https://github.com/11ty/eleventy/issues\",\n\"homepage\": \"https://www.11ty.dev/\",\n\"ava\": {\n+ \"environmentVariables\": {},\n\"failFast\": false,\n\"files\": [\n\"./test/*.js\"\n" }, { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -477,6 +477,7 @@ Verbose Output: ${this.verboseMode}`);\nisVerbose = false;\n}\n+ bench.setVerboseOutput(isVerbose);\nthis.verboseMode = isVerbose;\n}\n@@ -938,7 +939,6 @@ Arguments:\n};\nthis.errorHandler.fatal(e, \"Problem writing Eleventy templates\");\n} finally {\n- // Note, this executes even though we return above in `catch`\nbench.finish();\nif (to === \"fs\") {\nthis.logger.message(\n@@ -953,11 +953,11 @@ Arguments:\ndebug(`\nGetting frustrated? Have a suggestion/feature request/feedback?\nI want to hear it! Open an issue: https://github.com/11ty/eleventy/issues/new`);\n+ }\nreturn ret;\n}\n}\n-}\nmodule.exports = Eleventy;\nmodule.exports.EleventyServerless = require(\"./Serverless\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Get those console logs out of the tests.
699
30.06.2021 11:28:27
18,000
6a9c03e4815b1baf08883661e71a3f90df8dc7d2
Use the parser to determine the symbols used in a template string (Nunjucks-only so far). This avoids using the double function execution hack and will be more reliable with things that use filters.
[ { "change_type": "MODIFY", "old_path": "src/ComputedData.js", "new_path": "src/ComputedData.js", "diff": "@@ -10,6 +10,7 @@ const debug = require(\"debug\")(\"Eleventy:ComputedData\");\nclass ComputedData {\nconstructor(config) {\nthis.computed = {};\n+ this.symbolParseFunctions = {};\nthis.templateStringKeyLookup = {};\nthis.computedKeys = new Set();\nthis.declaredDependencies = {};\n@@ -17,24 +18,33 @@ class ComputedData {\nthis.config = config;\n}\n- add(key, fn, declaredDependencies = []) {\n+ add(key, renderFn, declaredDependencies = [], symbolParseFn = undefined) {\nthis.computedKeys.add(key);\nthis.declaredDependencies[key] = declaredDependencies;\n// bind config filters/JS functions\n- if (typeof fn === \"function\") {\n+ if (typeof renderFn === \"function\") {\nlet fns = {};\nif (this.config) {\nfns = this.config.javascriptFunctions;\n}\n- fn = fn.bind(fns);\n+ renderFn = renderFn.bind(fns);\n}\n- lodashSet(this.computed, key, fn);\n+ lodashSet(this.computed, key, renderFn);\n+\n+ if (symbolParseFn) {\n+ lodashSet(this.symbolParseFunctions, key, symbolParseFn);\n+ }\n}\n- addTemplateString(key, fn, declaredDependencies = []) {\n- this.add(key, fn, declaredDependencies);\n+ addTemplateString(\n+ key,\n+ renderFn,\n+ declaredDependencies = [],\n+ symbolParseFn = undefined\n+ ) {\n+ this.add(key, renderFn, declaredDependencies, symbolParseFn);\nthis.templateStringKeyLookup[key] = true;\n}\n@@ -49,13 +59,22 @@ class ComputedData {\nif (typeof computed !== \"function\") {\n// add nodes for non functions (primitives like booleans, etc)\n+ // This will not handle template strings, as they are normalized to functions\nthis.queue.addNode(key);\n} else {\nthis.queue.uses(key, this.declaredDependencies[key]);\n+ let symbolParseFn = lodashGet(this.symbolParseFunctions, key);\n+ let varsUsed = [];\n+ if (symbolParseFn) {\n+ // use the parseForSymbols function in the TemplateEngine\n+ varsUsed = symbolParseFn();\n+ } else if (symbolParseFn !== false) {\n+ // skip resolution is this is false (just use declaredDependencies)\nlet isTemplateString = !!this.templateStringKeyLookup[key];\nlet proxy = isTemplateString ? proxyByTemplateString : proxyByProxy;\n- let varsUsed = await proxy.findVarsUsed(computed, data);\n+ varsUsed = await proxy.findVarsUsed(computed, data);\n+ }\ndebug(\"%o accesses %o variables\", key, varsUsed);\nlet filteredVarsUsed = varsUsed.filter((varUsed) => {\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "const NunjucksLib = require(\"nunjucks\");\n+const parser = NunjucksLib.parser;\n+const nodes = NunjucksLib.nodes;\nconst TemplateEngine = require(\"./TemplateEngine\");\nconst TemplatePath = require(\"../TemplatePath\");\nconst EleventyErrorUtil = require(\"../EleventyErrorUtil\");\n@@ -358,6 +360,37 @@ class Nunjucks extends TemplateEngine {\n);\n}\n+ /* Outputs an Array of lodash.get selectors */\n+ parseForSymbols(str) {\n+ let obj = parser.parse(str);\n+ let linesplit = str.split(\"\\n\");\n+ let values = obj.findAll(nodes.Value);\n+ let symbols = obj.findAll(nodes.Symbol).map((entry) => {\n+ let name = [entry.value];\n+ let nestedIndex = -1;\n+ for (let val of values) {\n+ if (nestedIndex > -1) {\n+ /* deep.object.syntax */\n+ if (linesplit[val.lineno].charAt(nestedIndex) === \".\") {\n+ name.push(val.value);\n+ nestedIndex += val.value.length + 1;\n+ } else {\n+ nestedIndex = -1;\n+ }\n+ } else if (\n+ val.lineno === entry.lineno &&\n+ val.colno === entry.colno &&\n+ val.value === entry.value\n+ ) {\n+ nestedIndex = entry.colno + entry.value.length;\n+ }\n+ }\n+ return name.join(\".\");\n+ });\n+\n+ return symbols;\n+ }\n+\nasync compile(str, inputPath) {\nif (!this.needsCompilation(str)) {\nreturn async function () {\n@@ -375,6 +408,7 @@ class Nunjucks extends TemplateEngine {\n} else {\ntmpl = new NunjucksLib.Template(str, this.njkEnv, inputPath, true);\n}\n+\nreturn async function (data) {\nreturn new Promise(function (resolve, reject) {\ntmpl.render(data, function (err, res) {\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -543,9 +543,10 @@ class Template extends TemplateContent {\ncomputedData.addTemplateString(\nparentKey,\nasync (innerData) => {\n- return await super.render(obj, innerData, true);\n+ return await this.renderComputedData(obj, innerData, true);\n},\n- declaredDependencies\n+ declaredDependencies,\n+ this.getParseForSymbolsFunction(obj)\n);\n} else {\n// Numbers, booleans, etc\n@@ -564,13 +565,15 @@ class Template extends TemplateContent {\nthis.computedData.addTemplateString(\n\"page.url\",\nasync (data) => await this.getOutputHref(data),\n- data.permalink ? [\"permalink\"] : undefined\n+ data.permalink ? [\"permalink\"] : undefined,\n+ false // skip symbol resolution\n);\nthis.computedData.addTemplateString(\n\"page.outputPath\",\nasync (data) => await this.getOutputPath(data),\n- data.permalink ? [\"permalink\"] : undefined\n+ data.permalink ? [\"permalink\"] : undefined,\n+ false // skip symbol resolution\n);\n// actually add the computed data\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -282,6 +282,18 @@ class TemplateContent {\n}\n}\n+ getParseForSymbolsFunction(str) {\n+ if (\"parseForSymbols\" in this.engine) {\n+ return () => {\n+ return this.engine.parseForSymbols(str);\n+ };\n+ }\n+ }\n+\n+ async renderComputedData(str, data) {\n+ return this._render(str, data, true);\n+ }\n+\nasync renderPermalink(permalink, data, bypassMarkdown) {\nreturn this._render(permalink, data, bypassMarkdown);\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderNunjucksTest.js", "new_path": "test/TemplateRenderNunjucksTest.js", "diff": "@@ -805,3 +805,28 @@ test(\"Nunjucks bypass compilation\", async (t) => {\nt.is(tr.engine.needsCompilation(\"<p>{% tag %}{% endtag %}</p>\"), true);\nt.is(tr.engine.needsCompilation(\"<p>test</p>\"), false);\n});\n+\n+test(\"Nunjucks Parse for Symbols\", async (t) => {\n+ let tr = getNewTemplateRender(\"njk\");\n+ let engine = tr.engine;\n+\n+ t.deepEqual(engine.parseForSymbols(\"<p>{{ name }}</p>\"), [\"name\"]);\n+ t.deepEqual(engine.parseForSymbols(\"<p>{{ eleventy.deep.nested }}</p>\"), [\n+ \"eleventy.deep.nested\",\n+ ]);\n+ t.deepEqual(engine.parseForSymbols(\"<p>{{ a }} {{ b }}</p>\"), [\"a\", \"b\"]);\n+ t.deepEqual(\n+ engine.parseForSymbols(\"<p>{% if true %}{{ c }}{% endif %}</p>\"),\n+ [\"c\"]\n+ );\n+ t.deepEqual(\n+ engine.parseForSymbols(\"<p>{% if false %}{{ c }}{% endif %}</p>\"),\n+ [\"c\"]\n+ );\n+ t.deepEqual(engine.parseForSymbols(\"{{ collections.all[0] }}>\"), [\n+ \"collections.all\",\n+ ]);\n+ t.deepEqual(engine.parseForSymbols(\"{{ collections.mine }}>\"), [\n+ \"collections.mine\",\n+ ]);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-computed-symbolparse/test.njk", "diff": "+---\n+eleventyComputed:\n+ c: \"{{ a | fail }}{{ b | fail }}\"\n+ a: \"a\"\n+ b: \"b\"\n+---\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Use the parser to determine the symbols used in a template string (Nunjucks-only so far). This avoids using the double function execution hack and will be more reliable with things that use filters.
699
30.06.2021 11:28:45
18,000
9c83e5bc513d66631f2711dac1762725b7f9327a
Move a few tests to a separate file.
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "const test = require(\"ava\");\n-const fs = require(\"fs-extra\");\nconst fsp = require(\"fs\").promises;\nconst pretty = require(\"pretty\");\n@@ -19,37 +18,6 @@ async function getRenderedData(tmpl, pageNumber = 0) {\nreturn templates[pageNumber].data;\n}\n-async function getTemplateMapEntriesWithContent(template, data) {\n- let entries = await template.getTemplateMapEntries(data);\n-\n- return Promise.all(\n- entries.map(async (entry) => {\n- entry._pages = await entry.template.getTemplates(entry.data);\n- await Promise.all(\n- entry._pages.map(async (page) => {\n- page.templateContent = await entry.template.getTemplateMapContent(\n- page\n- );\n- return page;\n- })\n- );\n- return entry;\n- })\n- );\n-}\n-\n-async function writeMapEntries(mapEntries) {\n- let promises = [];\n- for (let entry of mapEntries) {\n- if (entry.template.behavior.isWriteable()) {\n- promises.push(\n- entry.template._write(entry.outputPath, entry.templateContent)\n- );\n- }\n- }\n- return Promise.all(promises);\n-}\n-\nfunction cleanHtml(str) {\nreturn pretty(str, { ocd: true });\n}\n@@ -1375,95 +1343,6 @@ test(\"Test a linter\", async (t) => {\nawait tmpl._testCompleteRender();\n});\n-test(\"permalink: false\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/permalink-false/test.md\",\n- \"./test/stubs/\",\n- \"./test/stubs/_site\"\n- );\n-\n- let data = await tmpl.getData();\n-\n- let mapEntries = await getTemplateMapEntriesWithContent(tmpl, data);\n- for (let entry of mapEntries) {\n- t.is(entry.template.behavior.isWriteable(), false);\n- t.is(entry.data.page.url, false);\n- t.is(entry.data.page.outputPath, false);\n- }\n-\n- await writeMapEntries(mapEntries);\n-\n- // Input file exists (sanity check for paths)\n- t.is(fs.existsSync(\"./test/stubs/permalink-false/\"), true);\n- t.is(fs.existsSync(\"./test/stubs/permalink-false/test.md\"), true);\n-\n- // Output does not exist\n- t.is(fs.existsSync(\"./test/stubs/_site/permalink-false/\"), false);\n- t.is(fs.existsSync(\"./test/stubs/_site/permalink-false/test/\"), false);\n- t.is(\n- fs.existsSync(\"./test/stubs/_site/permalink-false/test/index.html\"),\n- false\n- );\n-});\n-\n-test(\"permalink: false inside of eleventyComputed, Issue #1754\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/permalink-false-computed/test.md\",\n- \"./test/stubs/\",\n- \"./test/stubs/_site\"\n- );\n-\n- let data = await tmpl.getData();\n- let mapEntries = await getTemplateMapEntriesWithContent(tmpl, data);\n- for (let entry of mapEntries) {\n- t.is(entry.template.behavior.isWriteable(), false);\n- t.is(entry.data.page.url, false);\n- t.is(entry.data.page.outputPath, false);\n- }\n- await writeMapEntries(mapEntries);\n-\n- // Input file exists (sanity check for paths)\n- t.is(fs.existsSync(\"./test/stubs/permalink-false-computed/\"), true);\n- t.is(fs.existsSync(\"./test/stubs/permalink-false-computed/test.md\"), true);\n-\n- // Output does not exist\n- t.is(fs.existsSync(\"./test/stubs/_site/permalink-false-computed/\"), false);\n- t.is(\n- fs.existsSync(\"./test/stubs/_site/permalink-false-computed/test/\"),\n- false\n- );\n- t.is(\n- fs.existsSync(\n- \"./test/stubs/_site/permalink-false-computed/test/index.html\"\n- ),\n- false\n- );\n-});\n-\n-test(\"permalink: true\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/permalink-true/permalink-true.md\",\n- \"./test/stubs/\",\n- \"./test/stubs/_site\"\n- );\n-\n- let data = await tmpl.getData();\n- await t.throwsAsync(async () => {\n- await tmpl.getOutputLink(data);\n- });\n-});\n-\n-test(\"Disable dynamic permalinks\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/dynamic-permalink/test.njk\",\n- \"./test/stubs/\",\n- \"./test/stubs/_site\"\n- );\n-\n- t.is(await tmpl.getOutputLink(), \"/{{justastring}}/index.html\");\n- t.is(await tmpl.getOutputHref(), \"/{{justastring}}/\");\n-});\n-\ntest(\"Front Matter Tags (Single)\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/templatetest-frontmatter/single.njk\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateTest_Permalink.js", "diff": "+const test = require(\"ava\");\n+const fs = require(\"fs\");\n+\n+const getNewTemplate = require(\"./_getNewTemplateForTests\");\n+\n+async function writeMapEntries(mapEntries) {\n+ let promises = [];\n+ for (let entry of mapEntries) {\n+ if (entry.template.behavior.isWriteable()) {\n+ promises.push(\n+ entry.template._write(entry.outputPath, entry.templateContent)\n+ );\n+ }\n+ }\n+ return Promise.all(promises);\n+}\n+\n+async function getTemplateMapEntriesWithContent(template, data) {\n+ let entries = await template.getTemplateMapEntries(data);\n+\n+ return Promise.all(\n+ entries.map(async (entry) => {\n+ entry._pages = await entry.template.getTemplates(entry.data);\n+ await Promise.all(\n+ entry._pages.map(async (page) => {\n+ page.templateContent = await entry.template.getTemplateMapContent(\n+ page\n+ );\n+ return page;\n+ })\n+ );\n+ return entry;\n+ })\n+ );\n+}\n+\n+test(\"permalink: false\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-false/test.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+\n+ let mapEntries = await getTemplateMapEntriesWithContent(tmpl, data);\n+ for (let entry of mapEntries) {\n+ t.is(entry.template.behavior.isWriteable(), false);\n+ t.is(entry.data.page.url, false);\n+ t.is(entry.data.page.outputPath, false);\n+ }\n+\n+ await writeMapEntries(mapEntries);\n+\n+ // Input file exists (sanity check for paths)\n+ t.is(fs.existsSync(\"./test/stubs/permalink-false/\"), true);\n+ t.is(fs.existsSync(\"./test/stubs/permalink-false/test.md\"), true);\n+\n+ // Output does not exist\n+ t.is(fs.existsSync(\"./test/stubs/_site/permalink-false/\"), false);\n+ t.is(fs.existsSync(\"./test/stubs/_site/permalink-false/test/\"), false);\n+ t.is(\n+ fs.existsSync(\"./test/stubs/_site/permalink-false/test/index.html\"),\n+ false\n+ );\n+});\n+\n+test(\"permalink: false inside of eleventyComputed, Issue #1754\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-false-computed/test.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await getTemplateMapEntriesWithContent(tmpl, data);\n+ for (let entry of mapEntries) {\n+ t.is(entry.template.behavior.isWriteable(), false);\n+ t.is(entry.data.page.url, false);\n+ t.is(entry.data.page.outputPath, false);\n+ }\n+ await writeMapEntries(mapEntries);\n+\n+ // Input file exists (sanity check for paths)\n+ t.is(fs.existsSync(\"./test/stubs/permalink-false-computed/\"), true);\n+ t.is(fs.existsSync(\"./test/stubs/permalink-false-computed/test.md\"), true);\n+\n+ // Output does not exist\n+ t.is(fs.existsSync(\"./test/stubs/_site/permalink-false-computed/\"), false);\n+ t.is(\n+ fs.existsSync(\"./test/stubs/_site/permalink-false-computed/test/\"),\n+ false\n+ );\n+ t.is(\n+ fs.existsSync(\n+ \"./test/stubs/_site/permalink-false-computed/test/index.html\"\n+ ),\n+ false\n+ );\n+});\n+\n+test(\"permalink: true\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-true/permalink-true.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ await t.throwsAsync(async () => {\n+ await tmpl.getOutputLink(data);\n+ });\n+});\n+\n+test(\"Disable dynamic permalinks\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dynamic-permalink/test.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ t.is(await tmpl.getOutputLink(), \"/{{justastring}}/index.html\");\n+ t.is(await tmpl.getOutputHref(), \"/{{justastring}}/\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Move a few tests to a separate file.
699
30.06.2021 14:36:40
18,000
79245d85bcfba3ce8e8b75d84315c6c5bd81bbd3
Add AST traversal for Liquid strings in eleventyComputed
[ { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "@@ -388,7 +388,7 @@ class Nunjucks extends TemplateEngine {\nreturn name.join(\".\");\n});\n- return symbols;\n+ return Array.from(new Set(symbols));\n}\nasync compile(str, inputPath) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -1046,3 +1046,34 @@ test(\"Liquid reverse filter in {% for %}\", async (t) => {\n);\nt.is(await fn({ test: [1, 2, 3] }), \"321\");\n});\n+\n+test(\"Liquid Parse for Symbols\", async (t) => {\n+ let tr = getNewTemplateRender(\"liquid\");\n+ let engine = tr.engine;\n+\n+ t.deepEqual(engine.parseForSymbols(\"<p>{{ name }}</p>\"), [\"name\"]);\n+ t.deepEqual(engine.parseForSymbols(\"<p>{{ eleventy.deep.nested }}</p>\"), [\n+ \"eleventy.deep.nested\",\n+ ]);\n+ t.deepEqual(engine.parseForSymbols(\"<p>{{ a }} {{ b }}</p>\"), [\"a\", \"b\"]);\n+ t.deepEqual(\n+ engine.parseForSymbols(\"<p>{% if true %}{{ c }}{% endif %}</p>\"),\n+ [\"c\"]\n+ );\n+ t.deepEqual(\n+ engine.parseForSymbols(\"<p>{% if false %}{{ c }}{% endif %}</p>\"),\n+ [\"c\"]\n+ );\n+\n+ t.deepEqual(engine.parseForSymbols(\"{{ collections.all[0] }}>\"), [\n+ // Note that the Nunjucks parser returns collections.all\n+ \"collections.all[0]\",\n+ ]);\n+ t.deepEqual(engine.parseForSymbols(\"{{ collections.mine }}>\"), [\n+ \"collections.mine\",\n+ ]);\n+\n+ t.deepEqual(engine.parseForSymbols(\"{{ collections.mine | test }}>\"), [\n+ \"collections.mine\",\n+ ]);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderNunjucksTest.js", "new_path": "test/TemplateRenderNunjucksTest.js", "diff": "@@ -824,9 +824,16 @@ test(\"Nunjucks Parse for Symbols\", async (t) => {\n[\"c\"]\n);\nt.deepEqual(engine.parseForSymbols(\"{{ collections.all[0] }}>\"), [\n+ // Note that the Liquid parser returns collections.all[0]\n\"collections.all\",\n]);\nt.deepEqual(engine.parseForSymbols(\"{{ collections.mine }}>\"), [\n\"collections.mine\",\n]);\n+\n+ t.deepEqual(engine.parseForSymbols(\"{{ collections.mine | test }}>\"), [\n+ // TODO not ideal to have `test` in here?\n+ \"test\",\n+ \"collections.mine\",\n+ ]);\n});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-computed-symbolparse/test.liquid", "diff": "+---\n+eleventyComputed:\n+ c: \"{{ a | fail }}{{ b | fail }}\"\n+ a: \"a\"\n+ b: \"b\"\n+---\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Add AST traversal for Liquid strings in eleventyComputed
713
30.06.2021 19:00:49
18,000
84449ab597302a87975f32e6b25ca3f555907d11
Feat: Allow default engine overrides using addExtension
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -10,6 +10,8 @@ class CustomEngine extends TemplateEngine {\n\"init\" in this.entry && typeof this.entry.init === \"function\";\nthis.initStarted = false;\nthis.initFinished = false;\n+\n+ this._defaultEngine = undefined;\n}\ngetExtensionMapEntry() {\n@@ -26,6 +28,10 @@ class CustomEngine extends TemplateEngine {\n);\n}\n+ setDefaultEngine(defaultEngine) {\n+ this._defaultEngine = defaultEngine;\n+ }\n+\nneedsToReadFileContents() {\nif (\"read\" in this.entry) {\nreturn this.entry.read;\n@@ -67,11 +73,32 @@ class CustomEngine extends TemplateEngine {\n}\n}\n- async compile(str, inputPath) {\n+ async compile(str, inputPath, ...args) {\nawait this._runningInit();\n+ let defaultCompiler;\n+ if (this._defaultEngine) {\n+ defaultCompiler = async (data) => {\n+ const render = await this._defaultEngine.compile(\n+ str,\n+ inputPath,\n+ ...args\n+ );\n+ return await render(data);\n+ };\n+ }\n+\n+ // Fall back to default compiler if the user does not provide their own\n+ if (!this.entry.compile && defaultCompiler) {\n+ return defaultCompiler;\n+ }\n+\n// TODO generalize this (look at JavaScript.js)\n- return this.entry.compile.bind({ config: this.config })(str, inputPath);\n+ return this.entry.compile.bind({ config: this.config })(\n+ str,\n+ inputPath,\n+ defaultCompiler\n+ );\n}\nget defaultTemplateFileExtension() {\n" } ]
JavaScript
MIT License
11ty/eleventy
Feat: Allow default engine overrides using addExtension
713
30.06.2021 19:01:20
18,000
c3b7deab7d3038e4dddffb43bdfbeb150c414579
feat: add unit tests for engine overrides
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderCustomTest.js", "new_path": "test/TemplateRenderCustomTest.js", "diff": "@@ -34,6 +34,70 @@ test(\"Custom plaintext Render\", async (t) => {\nt.is(await fn({}), \"<p>Paragraph</p>\");\n});\n+test(\"Custom Markdown Render with `compile` override\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"md\",\n+ key: \"md\",\n+ compile: function (str, inputPath) {\n+ return function (data) {\n+ return `<not-markdown>${str.trim()}</not-markdown>`;\n+ };\n+ },\n+ });\n+\n+ let tr = getNewTemplateRender(\"md\", null, eleventyConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"# Markdown?\");\n+ t.is((await fn()).trim(), \"<not-markdown># Markdown?</not-markdown>\");\n+ t.is((await fn({})).trim(), \"<not-markdown># Markdown?</not-markdown>\");\n+});\n+\n+test(\"Custom Markdown Render without `compile` override\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let initCalled = false;\n+\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"md\",\n+ key: \"md\",\n+ init: function () {\n+ initCalled = true;\n+ },\n+ });\n+\n+ let tr = getNewTemplateRender(\"md\", null, eleventyConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"# Header\");\n+ t.is(initCalled, true);\n+ t.is((await fn()).trim(), \"<h1>Header</h1>\");\n+ t.is((await fn({})).trim(), \"<h1>Header</h1>\");\n+});\n+\n+test(\"Custom Markdown Render with `compile` override + call to default compiler\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"md\",\n+ key: \"md\",\n+ compile: function (str, inputPath, defaultCompiler) {\n+ return async function (data) {\n+ const result = await defaultCompiler(data);\n+ return `<custom-wrapper>${result.trim()}</custom-wrapper>`;\n+ };\n+ },\n+ });\n+\n+ let tr = getNewTemplateRender(\"md\", null, eleventyConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"Hey {{name}}\");\n+ t.is((await fn()).trim(), \"<custom-wrapper><p>Hey</p></custom-wrapper>\");\n+ t.is(\n+ (await fn({ name: \"Zach\" })).trim(),\n+ \"<custom-wrapper><p>Hey Zach</p></custom-wrapper>\"\n+ );\n+});\n+\ntest(\"Custom Vue Render\", async (t) => {\nlet tr = getNewTemplateRender(\"vue\");\n" } ]
JavaScript
MIT License
11ty/eleventy
feat: add unit tests for engine overrides
713
01.07.2021 09:52:29
18,000
236afeee4b1c22cc7db0f09a49c4053746cc066f
refactor: move defaultCompiler to "this" context
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -94,11 +94,11 @@ class CustomEngine extends TemplateEngine {\n}\n// TODO generalize this (look at JavaScript.js)\n- return this.entry.compile.bind({ config: this.config })(\n- str,\n- inputPath,\n- defaultCompiler\n- );\n+ return this.entry.compile\n+ // give the user access to this engine's default compiler, if any\n+ .bind({ config: this.config, defaultCompiler })(str, inputPath)\n+ // bind again for access inside function (data) {...}\n+ .bind({ defaultCompiler });\n}\nget defaultTemplateFileExtension() {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderCustomTest.js", "new_path": "test/TemplateRenderCustomTest.js", "diff": "@@ -80,9 +80,9 @@ test(\"Custom Markdown Render with `compile` override + call to default compiler\"\neleventyConfig.userConfig.extensionMap.add({\nextension: \"md\",\nkey: \"md\",\n- compile: function (str, inputPath, defaultCompiler) {\n+ compile: function (str, inputPath) {\nreturn async function (data) {\n- const result = await defaultCompiler(data);\n+ const result = await this.defaultCompiler(data);\nreturn `<custom-wrapper>${result.trim()}</custom-wrapper>`;\n};\n},\n" } ]
JavaScript
MIT License
11ty/eleventy
refactor: move defaultCompiler to "this" context
713
01.07.2021 10:01:32
18,000
375aec479be5ab608aea11162f2dbf742820e7b7
Update comment in src/TemplateEngineManager.js
[ { "change_type": "MODIFY", "old_path": "src/TemplateEngineManager.js", "new_path": "src/TemplateEngineManager.js", "diff": "@@ -92,7 +92,7 @@ class TemplateEngineManager {\n// If the user providers a \"Custom\" engine using addExtension,\n// But that engine's instance is *not* custom,\n// The user must be overriding an existing engine\n- // i.e. addExtension('md', function overrideBehavior() {...})\n+ // i.e. addExtension('md', { ...overrideBehavior })\nif (\nthis.getClassNameFromTemplateKey(name) === \"Custom\" &&\ninstance.constructor.name !== \"CustomEngine\"\n" } ]
JavaScript
MIT License
11ty/eleventy
Update comment in src/TemplateEngineManager.js
699
01.07.2021 15:09:04
18,000
8a6b7bff65334c2edba08905b93a62dfb5823449
Nunjucks parser needs to know about custom tags (shortcodes)
[ { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "const NunjucksLib = require(\"nunjucks\");\n-const parser = NunjucksLib.parser;\n-const nodes = NunjucksLib.nodes;\nconst TemplateEngine = require(\"./TemplateEngine\");\nconst TemplatePath = require(\"../TemplatePath\");\nconst EleventyErrorUtil = require(\"../EleventyErrorUtil\");\n@@ -206,8 +204,8 @@ class Nunjucks extends TemplateEngine {\nreturn obj;\n}\n- addShortcode(shortcodeName, shortcodeFn, isAsync = false) {\n- function ShortcodeFunction() {\n+ _getShortcodeFn(shortcodeName, shortcodeFn, isAsync = false) {\n+ return function ShortcodeFunction() {\nthis.tags = [shortcodeName];\nthis.parse = function (parser, nodes) {\n@@ -271,13 +269,11 @@ class Nunjucks extends TemplateEngine {\n}\n}\n};\n+ };\n}\n- this.njkEnv.addExtension(shortcodeName, new ShortcodeFunction());\n- }\n-\n- addPairedShortcode(shortcodeName, shortcodeFn, isAsync = false) {\n- function PairedShortcodeFunction() {\n+ _getPairedShortcodeFn(shortcodeName, shortcodeFn, isAsync = false) {\n+ return function PairedShortcodeFunction() {\nthis.tags = [shortcodeName];\nthis.parse = function (parser, nodes) {\n@@ -341,9 +337,17 @@ class Nunjucks extends TemplateEngine {\n}\n}\n};\n+ };\n}\n- this.njkEnv.addExtension(shortcodeName, new PairedShortcodeFunction());\n+ addShortcode(shortcodeName, shortcodeFn, isAsync = false) {\n+ let fn = this._getShortcodeFn(shortcodeName, shortcodeFn, isAsync);\n+ this.njkEnv.addExtension(shortcodeName, new fn());\n+ }\n+\n+ addPairedShortcode(shortcodeName, shortcodeFn, isAsync = false) {\n+ let fn = this._getPairedShortcodeFn(shortcodeName, shortcodeFn, isAsync);\n+ this.njkEnv.addExtension(shortcodeName, new fn());\n}\nneedsCompilation(str) {\n@@ -360,9 +364,42 @@ class Nunjucks extends TemplateEngine {\n);\n}\n+ _getParseExtensions() {\n+ if (this._parseExtensions) {\n+ return this._parseExtensions;\n+ }\n+\n+ // add extensions so the parser knows about our custom tags/blocks\n+ let ext = [];\n+ for (let name in this.config.nunjucksTags) {\n+ let fn = this._getShortcodeFn(name, () => {});\n+ ext.push(new fn());\n+ }\n+ for (let name in this.config.nunjucksShortcodes) {\n+ let fn = this._getShortcodeFn(name, () => {});\n+ ext.push(new fn());\n+ }\n+ for (let name in this.config.nunjucksAsyncShortcodes) {\n+ let fn = this._getShortcodeFn(name, () => {}, true);\n+ ext.push(new fn());\n+ }\n+ for (let name in this.config.nunjucksPairedShortcodes) {\n+ let fn = this._getPairedShortcodeFn(name, () => {});\n+ ext.push(new fn());\n+ }\n+ for (let name in this.config.nunjucksAsyncPairedShortcodes) {\n+ let fn = this._getPairedShortcodeFn(name, () => {}, true);\n+ ext.push(new fn());\n+ }\n+\n+ this._parseExtensions = ext;\n+ return ext;\n+ }\n+\n/* Outputs an Array of lodash.get selectors */\nparseForSymbols(str) {\n- let obj = parser.parse(str);\n+ const { parser, nodes } = NunjucksLib;\n+ let obj = parser.parse(str, this._getParseExtensions());\nlet linesplit = str.split(\"\\n\");\nlet values = obj.findAll(nodes.Value);\nlet symbols = obj.findAll(nodes.Symbol).map((entry) => {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderNunjucksTest.js", "new_path": "test/TemplateRenderNunjucksTest.js", "diff": "@@ -837,3 +837,11 @@ test(\"Nunjucks Parse for Symbols\", async (t) => {\n\"collections.mine\",\n]);\n});\n+\n+test(\"Nunjucks Parse for Symbols with custom block\", async (t) => {\n+ let tr = getNewTemplateRender(\"njk\");\n+ let engine = tr.engine;\n+ engine.config.nunjucksShortcodes.test = function () {};\n+\n+ t.deepEqual(engine.parseForSymbols(\"<p>{{ name }} {% test %}</p>\"), [\"name\"]);\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Nunjucks parser needs to know about custom tags (shortcodes)
699
01.07.2021 16:27:43
18,000
89fd4a2e549f5a9a9061c6e8891ee128110389fa
Move a few tests
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -593,70 +593,6 @@ test(\"Clone the template\", async (t) => {\nt.is(cloned.extensionMap, tmpl.extensionMap);\n});\n-test(\"Permalink with variables!\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/permalinkdata.njk\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-candidate/index.html\");\n-});\n-\n-test(\"Permalink with variables and JS front matter!\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/permalinkdata-jsfn.njk\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug/index.html\");\n-});\n-\n-// This is broken right now, permalink must use the same template language as the template\n-test.skip(\"Use a JavaScript function for permalink in any template language\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/permalinkdata-jspermalinkfn.njk\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug/index.html\");\n-});\n-\n-test(\"Permalink with dates!\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/permalinkdate.liquid\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/2016/01/01/index.html\");\n-});\n-\n-test(\"Permalink with dates on file name regex!\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/2016-02-01-permalinkdate.liquid\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/2016/02/01/index.html\");\n-});\n-\n-test(\"Reuse permalink in directory specific data file\", async (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n- let tmpl = getNewTemplate(\n- \"./test/stubs/reuse-permalink/test1.liquid\",\n- \"./test/stubs/\",\n- \"./dist\",\n- dataObj\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/2016/01/01/index.html\");\n-});\n-\ntest(\"mapDataAsRenderedTemplates\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/default.ejs\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest_Permalink.js", "new_path": "test/TemplateTest_Permalink.js", "diff": "const test = require(\"ava\");\nconst fs = require(\"fs\");\n+const TemplateConfig = require(\"../src/TemplateConfig\");\n+const TemplateData = require(\"../src/TemplateData\");\nconst getNewTemplate = require(\"./_getNewTemplateForTests\");\n@@ -122,3 +124,69 @@ test(\"Disable dynamic permalinks\", async (t) => {\nt.is(await tmpl.getOutputLink(), \"/{{justastring}}/index.html\");\nt.is(await tmpl.getOutputHref(), \"/{{justastring}}/\");\n});\n+\n+\n+test(\"Permalink with variables!\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalinkdata.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-candidate/index.html\");\n+});\n+\n+test(\"Permalink with variables and JS front matter!\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalinkdata-jsfn.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug/index.html\");\n+});\n+\n+// This is broken right now, permalink must use the same template language as the template\n+test.skip(\"Use a JavaScript function for permalink in any template language\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalinkdata-jspermalinkfn.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug/index.html\");\n+});\n+\n+test(\"Permalink with dates!\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalinkdate.liquid\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/2016/01/01/index.html\");\n+});\n+\n+test(\"Permalink with dates on file name regex!\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/2016-02-01-permalinkdate.liquid\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/2016/02/01/index.html\");\n+});\n+\n+test(\"Reuse permalink in directory specific data file\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/reuse-permalink/test1.liquid\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/2016/01/01/index.html\");\n+});\n+\n" } ]
JavaScript
MIT License
11ty/eleventy
Move a few tests
699
01.07.2021 16:31:58
18,000
76f06cf92b942653f970a94f3bf3857b7d99ca5e
Add test for commas
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest_Permalink.js", "new_path": "test/TemplateTest_Permalink.js", "diff": "@@ -209,3 +209,13 @@ test(\"Using slugify filter with apostrophe\", async (t) => {\nt.is(await tmpl.getOutputPath(), \"./dist/subdir/hi-i-m-zach/index.html\");\n});\n+\n+test(\"Using slugify filter with comma\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/slugify-filter/comma.njk\",\n+ \"./test/slugify-filter/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/subdir/hi-i-m-zach/index.html\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/slugify-filter/comma.njk", "diff": "+---\n+title: \"Hi, I'm Zach\"\n+permalink: subdir/{{ title | slugify }}/index.html\n+---\n+Slugged.\n" } ]
JavaScript
MIT License
11ty/eleventy
Add test for commas
707
04.07.2021 19:01:57
-3,600
d5d110cba92d6abe230b014743df9f75211c4fac
Deduplicate tags when using deepDataMerge
[ { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -586,6 +586,9 @@ class TemplateData {\n} else if (data.tags === null) {\ndata.tags = [];\n}\n+\n+ // Deduplicate tags\n+ data.tags = [...new Set(data.tags)];\n}\nreturn data;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1489,6 +1489,26 @@ test(\"Data Cascade Tag Merge (Deep merge)\", async (t) => {\nt.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\", \"tagC\", \"tagD\"]);\n});\n+test(\"Data Cascade Tag Merge (Deep Merge - Deduplication)\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ // Default changed in 1.0\n+ // eleventyConfig.userConfig.setDataDeepMerge(true);\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ await dataObj.cacheData();\n+\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/data-cascade/template.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\", \"tagC\", \"tagD\"]);\n+});\n+\ntest(\"Data Cascade Tag Merge (Shallow merge)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\n// Default changed in 1.0\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/data-cascade/template.11tydata.js", "new_path": "test/stubs/data-cascade/template.11tydata.js", "diff": "module.exports = {\nparent: {\nchild: 2,\n- datafile: true\n+ datafile: true,\n},\ndatafile: true,\n- tags: [\"tagC\", \"tagD\"]\n+ tags: [\"tagC\", \"tagD\", \"tagD\"],\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Deduplicate tags when using deepDataMerge
699
06.07.2021 21:03:17
18,000
4eded235dc8505140d24a309cfb3e9792fee44bc
Resolves PR comment
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest_Permalink.js", "new_path": "test/TemplateTest_Permalink.js", "diff": "@@ -200,16 +200,6 @@ test(\"Using slugify filter!\", async (t) => {\nt.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-love-candidate-lyublyu/index.html\");\n});\n-test(\"Using slugify filter with apostrophe\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/slugify-filter/apostrophe.njk\",\n- \"./test/slugify-filter/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/hi-i-m-zach/index.html\");\n-});\n-\ntest(\"Using slugify filter with comma\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/slugify-filter/comma.njk\",\n" }, { "change_type": "DELETE", "old_path": "test/slugify-filter/apostrophe.njk", "new_path": null, "diff": "----\n-title: \"Hi I'm Zach\"\n-permalink: subdir/{{ title | slugify }}/index.html\n----\n-Slugged.\n" } ]
JavaScript
MIT License
11ty/eleventy
Resolves PR comment https://github.com/11ty/eleventy/pull/1873#discussion_r663253148
699
06.07.2021 21:24:08
18,000
6169883e442815331fd74dcceac5242e752e2ced
Add tests for passing in options to slug and slugify filters. Switch to decamelize default for slugify filter.
[ { "change_type": "MODIFY", "old_path": "src/Filters/Slugify.js", "new_path": "src/Filters/Slugify.js", "diff": "const slugify = require(\"@sindresorhus/slugify\");\nmodule.exports = function(str, options = {}) {\n- return slugify(str, options);\n+ return slugify(str, Object.assign({\n+ decamelize: false\n+ }, options));\n};\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest_Permalink.js", "new_path": "test/TemplateTest_Permalink.js", "diff": "@@ -200,7 +200,7 @@ test(\"Using slugify filter!\", async (t) => {\nt.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-love-candidate-lyublyu/index.html\");\n});\n-test(\"Using slugify filter with comma\", async (t) => {\n+test(\"Using slugify filter with comma and apostrophe\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/slugify-filter/comma.njk\",\n\"./test/slugify-filter/\",\n@@ -209,3 +209,23 @@ test(\"Using slugify filter with comma\", async (t) => {\nt.is(await tmpl.getOutputPath(), \"./dist/subdir/hi-i-m-zach/index.html\");\n});\n+\n+test(\"Using slug filter with options params\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/slugify-filter/slug-options.njk\",\n+ \"./test/slugify-filter/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/subdir/hi_i_am_zach/index.html\");\n+});\n+\n+test(\"Using slugify filter with options params\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/slugify-filter/slugify-options.njk\",\n+ \"./test/slugify-filter/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/subdir/hi-i-m-z-ach/index.html\");\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/slugify-filter/comma.njk", "new_path": "test/slugify-filter/comma.njk", "diff": "---\n-title: \"Hi, I'm Zach\"\n+title: \"Hi, I'm ZAch\"\npermalink: subdir/{{ title | slugify }}/index.html\n---\nSlugged.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/slugify-filter/slug-options.njk", "diff": "+---\n+title: \"Hi, I am ZAch\"\n+permalink: \"subdir/{{ title | slug({replacement:'_'}) }}/index.html\"\n+---\n+Slugged.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/slugify-filter/slugify-options.njk", "diff": "+---\n+title: \"Hi, I'm ZAch\"\n+permalink: \"subdir/{{ title | slugify({decamelize: true}) }}/index.html\"\n+---\n+Slugged.\n" } ]
JavaScript
MIT License
11ty/eleventy
Add tests for passing in options to slug and slugify filters. Switch to decamelize default for slugify filter.
699
11.07.2021 13:53:08
18,000
70133c03b7390810140ac6897531ab3f0a04a106
A few minor changes to facilitate
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -906,8 +906,11 @@ Arguments:\n}\ntry {\n- await this.config.events.emit(\"beforeBuild\");\n- await this.config.events.emit(\"eleventy.before\");\n+ let eventsArg = {\n+ inputDir: this.config.inputDir,\n+ };\n+ await this.config.events.emit(\"beforeBuild\", eventsArg);\n+ await this.config.events.emit(\"eleventy.before\", eventsArg);\nlet promise;\nif (to === \"fs\") {\n@@ -930,8 +933,8 @@ Arguments:\nret = this.logger.closeStream(to);\n}\n- await this.config.events.emit(\"afterBuild\");\n- await this.config.events.emit(\"eleventy.after\");\n+ await this.config.events.emit(\"afterBuild\", eventsArg);\n+ await this.config.events.emit(\"eleventy.after\", eventsArg);\n} catch (e) {\nhasError = true;\nret = {\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -616,9 +616,14 @@ class UserConfig {\n}\nsetDataDeepMerge(deepMerge) {\n+ this._dataDeepMergeModified = true;\nthis.dataDeepMerge = !!deepMerge;\n}\n+ isDataDeepMergeModified() {\n+ return this._dataDeepMergeModified;\n+ }\n+\naddWatchTarget(additionalWatchTargets) {\nthis.additionalWatchTargets.push(additionalWatchTargets);\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
A few minor changes to facilitate https://github.com/11ty/eleventy-upgrade-help
699
11.07.2021 23:18:57
18,000
2623e771b31e97ca7fec100c1d4a86439d830d80
Changes dynamicPartials default from false to true. Fixes
[ { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -48,7 +48,7 @@ class Liquid extends TemplateEngine {\nlet defaults = {\nroot: [super.getIncludesDir()], // overrides in compile with inputPath below\nextname: \".liquid\",\n- dynamicPartials: false,\n+ dynamicPartials: true,\nstrictFilters: true,\n// TODO?\n// cache: true,\n" }, { "change_type": "MODIFY", "old_path": "test/stubs-layout-cache/_includes/layout.liquid", "new_path": "test/stubs-layout-cache/_includes/layout.liquid", "diff": "-<script>{%- include include-script-2.js -%}</script>\n\\ No newline at end of file\n+<script>{%- include 'include-script-2.js' -%}</script>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/includer.liquid", "new_path": "test/stubs/includer.liquid", "diff": "-<p>{% include included %}</p>\n+<p>{% include 'included' %}</p>\n" } ]
JavaScript
MIT License
11ty/eleventy
Changes dynamicPartials default from false to true. Fixes https://github.com/11ty/eleventy/issues/240
699
12.07.2021 08:23:21
18,000
5fce0f7834a2fa49f59bd894b8b65d2cf8484bf3
Removes ViperHTML dev test via npm warn "npm WARN deprecated viperHTML is maintenance only: check ucontent or heresy-ssr instead"
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -162,19 +162,6 @@ test(\"JS Render using Vue (with a layout)\", async (t) => {\n);\n});\n-test(\"JS Render using ViperHTML\", async (t) => {\n- let fn = await getNewTemplateRender(\n- \"./test/stubs/viperhtml.11ty.js\"\n- ).getCompiledTemplate();\n- t.is(\n- await fn({ name: \"Zach\", html: \"<strong>Hi</strong>\" }),\n- `<div>\n- This is a viper template, Zach\n- <strong>Hi</strong>\n-</div>`\n- );\n-});\n-\ntest(\"JS Render with a function\", async (t) => {\nt.plan(8);\n" }, { "change_type": "DELETE", "old_path": "test/stubs/viperhtml.11ty.js", "new_path": null, "diff": "-const viperHTML = require(\"viperhtml\");\n-\n-// Returns buffer\n-module.exports = function(data) {\n- return viperHTML.wire()`<div>\n- This is a viper template, ${data.name}\n- ${[data.html]}\n-</div>`;\n-};\n" } ]
JavaScript
MIT License
11ty/eleventy
Removes ViperHTML dev test via npm warn "npm WARN deprecated viperhtml@2.17.1: viperHTML is maintenance only: check ucontent or heresy-ssr instead"
699
12.07.2021 08:29:30
18,000
a72ccbdc187d5f47be8b0e3de958844e4be342c7
Update dependencies. Includes major version bumps to luxon and fs-extra
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "]\n},\n\"devDependencies\": {\n- \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.0\",\n+ \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.1\",\n\"ava\": \"^3.15.0\",\n\"husky\": \"^7.0.1\",\n\"ink-docstrap\": \"1.3.2\",\n- \"js-yaml\": \"^4.0.0\",\n\"jsdoc\": \"3.6.7\",\n+ \"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.0.0\",\n\"markdown-it-emoji\": \"^2.0.0\",\n\"nyc\": \"^15.1.0\",\n- \"prettier\": \"^2.2.1\",\n+ \"prettier\": \"^2.3.2\",\n\"rimraf\": \"^3.0.2\",\n- \"sass\": \"^1.32.11\",\n+ \"sass\": \"^1.35.2\",\n\"toml\": \"^3.0.0\",\n- \"viperhtml\": \"^2.17.1\",\n- \"vue\": \"^2.6.12\",\n- \"vue-server-renderer\": \"^2.6.12\"\n+ \"vue\": \"^2.6.14\",\n+ \"vue-server-renderer\": \"^2.6.14\"\n},\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^2.0.0\",\n\"@iarna/toml\": \"^2.2.5\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n- \"browser-sync\": \"^2.26.14\",\n- \"chalk\": \"^4.1.0\",\n- \"chokidar\": \"^3.5.1\",\n- \"debug\": \"^4.3.1\",\n+ \"browser-sync\": \"^2.27.4\",\n+ \"chalk\": \"^4.1.1\",\n+ \"chokidar\": \"^3.5.2\",\n+ \"debug\": \"^4.3.2\",\n\"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^3.1.6\",\n- \"fast-glob\": \"^3.2.5\",\n- \"fs-extra\": \"^9.1.0\",\n- \"gray-matter\": \"^4.0.2\",\n+ \"fast-glob\": \"^3.2.7\",\n+ \"fs-extra\": \"^10.0.0\",\n+ \"gray-matter\": \"^4.0.3\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n\"is-glob\": \"^4.0.1\",\n- \"liquidjs\": \"^9.23.2\",\n+ \"liquidjs\": \"^9.25.1\",\n\"lodash\": \"^4.17.21\",\n- \"luxon\": \"^1.26.0\",\n- \"markdown-it\": \"^12.0.4\",\n+ \"luxon\": \"^2.0.1\",\n+ \"markdown-it\": \"^12.1.0\",\n\"minimist\": \"^1.2.5\",\n\"moo\": \"^0.5.1\",\n\"multimatch\": \"^5.0.0\",\n- \"mustache\": \"^4.1.0\",\n+ \"mustache\": \"^4.2.0\",\n\"normalize-path\": \"^3.0.0\",\n\"nunjucks\": \"^3.2.3\",\n\"parse-filepath\": \"^1.0.2\",\n\"please-upgrade-node\": \"^3.2.0\",\n\"pretty\": \"^2.0.0\",\n\"pug\": \"^3.0.2\",\n- \"recursive-copy\": \"^2.0.11\",\n- \"semver\": \"^7.3.4\",\n- \"slugify\": \"^1.4.7\",\n+ \"recursive-copy\": \"^2.0.13\",\n+ \"semver\": \"^7.3.5\",\n+ \"slugify\": \"^1.5.3\",\n\"split\": \"^1.0.1\",\n\"time-require\": \"^0.1.2\",\n\"url-pattern\": \"^1.0.3\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Update dependencies. Includes major version bumps to luxon and fs-extra
699
12.07.2021 08:37:17
18,000
6d3632c3a5024186a93a7e70d6c576b45eceb262
Remove a few deps, more info at
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "],\n\"scripts\": {\n\"default\": \"npm run test\",\n- \"doc\": \"jsdoc -c .jsdoc.conf.json -d ./api-docs -p ./package.json -R README.md -t ./node_modules/ink-docstrap/template -r src/\",\n\"test\": \"npx ava --verbose\",\n\"lint-staged\": \"lint-staged\",\n\"coverage\": \"npx nyc ava && npx nyc report --reporter=json-summary && cp coverage/coverage-summary.json docs-src/_data/coverage.json && node cmd.js --config=docs-src/.eleventy.docs.js\",\n\"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.1\",\n\"ava\": \"^3.15.0\",\n\"husky\": \"^7.0.1\",\n- \"ink-docstrap\": \"1.3.2\",\n- \"jsdoc\": \"3.6.7\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.0.0\",\n\"markdown-it-emoji\": \"^2.0.0\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Remove a few deps, more info at https://github.com/11ty/eleventy/issues/1885#issuecomment-878286079
699
13.07.2021 16:23:13
18,000
b8687ee27d73e5f68fa9f708b5e17fa5366795e0
Update one more dep
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"ava\": \"^3.15.0\",\n\"husky\": \"^7.0.1\",\n\"js-yaml\": \"^4.1.0\",\n- \"lint-staged\": \"^11.0.0\",\n+ \"lint-staged\": \"^11.0.1\",\n\"markdown-it-emoji\": \"^2.0.0\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.3.2\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Update one more dep
699
14.07.2021 08:09:15
18,000
31dc9b02e8ba64d1658470ba5d02880487b4bc22
Serverless fix: changing serverless paths previously required a dev server restart
[ { "change_type": "MODIFY", "old_path": "src/Serverless.js", "new_path": "src/Serverless.js", "diff": "@@ -4,6 +4,7 @@ const fs = require(\"fs\");\nconst Eleventy = require(\"./Eleventy\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst UrlPattern = require(\"url-pattern\");\n+const deleteRequireCache = require(\"./Util/DeleteRequireCache\");\nconst debug = require(\"debug\")(\"Eleventy:Serverless\");\nclass Serverless {\n@@ -75,7 +76,10 @@ class Serverless {\ndebug(\n`Including content map (maps output URLs to input files) from ${fullPath}`\n);\n- return require(fullPath);\n+ deleteRequireCache(fullPath);\n+\n+ let mapContent = require(fullPath);\n+ return mapContent;\n}\nisServerlessUrl(urlPath) {\n" } ]
JavaScript
MIT License
11ty/eleventy
Serverless fix: changing serverless paths previously required a dev server restart
706
20.07.2021 15:17:36
25,200
79b37ee69eb9953001e953078dc64dbdb8c7a92f
Adds code of conduct link to top of markdown file
[ { "change_type": "MODIFY", "old_path": "CODE_OF_CONDUCT.md", "new_path": "CODE_OF_CONDUCT.md", "diff": "# Eleventy Community Code of Conduct\n+View the [Code of Conduct](https://www.11ty.dev/docs/code-of-conduct/) on 11ty.dev\n+\n## Our Pledge\nIn the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds code of conduct link to top of markdown file
699
27.07.2021 07:30:26
18,000
f733001f1e76a38e4576b525d7506950f4370fef
Apply Prettier to src/ Pairs with
[ { "change_type": "MODIFY", "old_path": ".prettierrc.json", "new_path": ".prettierrc.json", "diff": "{\n- \"arrowParens\": \"avoid\"\n+ \"arrowParens\": \"always\"\n}\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyWatchTargets.js", "new_path": "src/EleventyWatchTargets.js", "diff": "@@ -62,7 +62,7 @@ class EleventyWatchTargets {\n}\naddAndMakeGlob(targets) {\n- targets = this._normalizeTargets(targets).map(entry =>\n+ targets = this._normalizeTargets(targets).map((entry) =>\nTemplatePath.convertToRecursiveGlobSync(entry)\n);\nthis.addRaw(targets);\n@@ -90,15 +90,15 @@ class EleventyWatchTargets {\ngetJavaScriptDependenciesFromList(files = []) {\nlet depSet = new Set();\nfiles\n- .filter(file => file.endsWith(\".js\") || file.endsWith(\".cjs\")) // TODO does this need to work with aliasing? what other JS extensions will have deps?\n- .forEach(file => {\n+ .filter((file) => file.endsWith(\".js\") || file.endsWith(\".cjs\")) // TODO does this need to work with aliasing? what other JS extensions will have deps?\n+ .forEach((file) => {\ndependencyTree(file, { allowNotFound: true })\n- .map(dependency => {\n+ .map((dependency) => {\nreturn TemplatePath.addLeadingDotSlash(\nTemplatePath.relativePath(dependency)\n);\n})\n- .forEach(dependency => {\n+ .forEach((dependency) => {\ndepSet.add(dependency);\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -946,7 +946,9 @@ class Template extends TemplateContent {\n} else {\nlet filenameRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\nif (filenameRegex !== null) {\n- let dateObj = DateTime.fromISO(filenameRegex[1], { zone: 'utc' }).toJSDate();\n+ let dateObj = DateTime.fromISO(filenameRegex[1], {\n+ zone: \"utc\",\n+ }).toJSDate();\ndebug(\n\"getMappedDate: using filename regex time for %o of %o: %o\",\nthis.inputPath,\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -226,7 +226,9 @@ class TemplateWriter {\nlet promises = [];\nfor (let path of paths) {\nif (this.extensionMap.hasEngine(path)) {\n- promises.push(this.templateMap.add(this._createTemplate(path, paths, to)));\n+ promises.push(\n+ this.templateMap.add(this._createTemplate(path, paths, to))\n+ );\n}\ndebug(`${path} begun adding to map.`);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Capitalize.js", "new_path": "src/Util/Capitalize.js", "diff": "module.exports = function (str, options) {\noptions = Object.assign(\n{\n- lowercaseRestOfWord: false\n+ lowercaseRestOfWord: false,\n},\noptions\n);\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Sortable.js", "new_path": "src/Util/Sortable.js", "diff": "@@ -11,7 +11,7 @@ class Sortable {\n\"A-Z\": \"Ascending\",\n\"Z-A\": \"Descending\",\n\"0-9\": \"NumericAscending\",\n- \"9-0\": \"NumericDescending\"\n+ \"9-0\": \"NumericDescending\",\n};\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Apply Prettier to src/ Pairs with #1560.
699
28.07.2021 08:21:49
18,000
f958cd3eec6882dd2613114d827ecbecad3d3d07
Uh, fix the syntax errors from a bad merge.
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -160,25 +160,24 @@ class TemplateConfig {\ndebug(\"rootConfig %o\", this.rootConfig);\n}\n- processPlugins(localConfig) {\n- // eleventyConfig.plugins\n- eleventyConfig.plugins.forEach(({ plugin, options }) => {\n- eleventyConfig.dir = localConfig.dir;\n+ processPlugins(userConfig, localConfig) {\n+ userConfig.plugins.forEach(({ plugin, options }) => {\n+ userConfig.dir = localConfig.dir;\n// TODO support function.name in plugin config functions\ndebug(\"Adding plugin (unknown name: check your config file).\");\nlet pluginBench = aggregateBench.get(\"Configuration addPlugin\");\nif (typeof plugin === \"function\") {\npluginBench.before();\nlet configFunction = plugin;\n- configFunction(eleventyConfig, options);\n+ configFunction(userConfig, options);\npluginBench.after();\n} else if (plugin && plugin.configFunction) {\npluginBench.before();\nif (options && typeof options.init === \"function\") {\n- options.init.call(eleventyConfig, plugin.initArguments || {});\n+ options.init.call(userConfig, plugin.initArguments || {});\n}\n- plugin.configFunction(eleventyConfig, options);\n+ plugin.configFunction(userConfig, options);\npluginBench.after();\n} else {\nthrow new UserConfigError(\n@@ -251,9 +250,10 @@ class TemplateConfig {\n// Delay processing plugins until after the result of localConfig is returned\n// But BEFORE the rest of the config options are merged\n// this way we can pass directories and other template information to plugins\n- this.processPlugins(localConfig);\n+ this.processPlugins(this.userConfig, localConfig);\n- let eleventyConfigApiMergingObject = eleventyConfig.getMergingConfigObject();\n+ let eleventyConfigApiMergingObject =\n+ this.userConfig.getMergingConfigObject();\n// remove special merge keys from object\n" } ]
JavaScript
MIT License
11ty/eleventy
Uh, fix the syntax errors from a bad merge.
699
28.07.2021 12:45:51
18,000
828ee785fea82c4c84933c53e85ea5a69a883c64
Fix regression with serverless config merge
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -110,7 +110,7 @@ class TemplateConfig {\ngetConfig() {\nif (!this.hasConfigMerged) {\ndebugDev(\"Merging via getConfig (first time)\");\n- this.config = this.mergeConfig(this.projectConfigPath);\n+ this.config = this.mergeConfig();\nthis.hasConfigMerged = true;\n}\nreturn this.config;\n@@ -129,7 +129,8 @@ class TemplateConfig {\ndebugDev(\n\"Merging in getConfig again after setting the local project config path.\"\n);\n- this.config = this.mergeConfig(path);\n+ this.hasConfigMerged = false;\n+ this.getConfig();\n}\n}\n@@ -160,24 +161,24 @@ class TemplateConfig {\ndebug(\"rootConfig %o\", this.rootConfig);\n}\n- processPlugins(userConfig, localConfig) {\n- userConfig.plugins.forEach(({ plugin, options }) => {\n- userConfig.dir = localConfig.dir;\n+ processPlugins({ dir }) {\n+ this.userConfig.plugins.forEach(({ plugin, options }) => {\n+ this.userConfig.dir = dir;\n// TODO support function.name in plugin config functions\ndebug(\"Adding plugin (unknown name: check your config file).\");\nlet pluginBench = aggregateBench.get(\"Configuration addPlugin\");\nif (typeof plugin === \"function\") {\npluginBench.before();\nlet configFunction = plugin;\n- configFunction(userConfig, options);\n+ configFunction(this.userConfig, options);\npluginBench.after();\n} else if (plugin && plugin.configFunction) {\npluginBench.before();\nif (options && typeof options.init === \"function\") {\n- options.init.call(userConfig, plugin.initArguments || {});\n+ options.init.call(this.userConfig, plugin.initArguments || {});\n}\n- plugin.configFunction(userConfig, options);\n+ plugin.configFunction(this.userConfig, options);\npluginBench.after();\n} else {\nthrow new UserConfigError(\n@@ -195,10 +196,7 @@ class TemplateConfig {\n*/\nmergeConfig() {\nlet localConfig = {};\n- let path = TemplatePath.join(\n- TemplatePath.getWorkingDir(),\n- this.projectConfigPath\n- );\n+ let path = TemplatePath.absolutePath(this.projectConfigPath);\ndebug(`Merging config with ${path}`);\n@@ -250,7 +248,7 @@ class TemplateConfig {\n// Delay processing plugins until after the result of localConfig is returned\n// But BEFORE the rest of the config options are merged\n// this way we can pass directories and other template information to plugins\n- this.processPlugins(this.userConfig, localConfig);\n+ this.processPlugins(localConfig);\nlet eleventyConfigApiMergingObject =\nthis.userConfig.getMergingConfigObject();\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix regression with serverless config merge
699
28.07.2021 12:47:18
18,000
e6a8077edc0a256daefa1e94a3c4103bb972dccc
Reuse inputDir when returned in configuration file. Thanks via
[ { "change_type": "MODIFY", "old_path": "src/Plugins/ServerlessBundlerPlugin.js", "new_path": "src/Plugins/ServerlessBundlerPlugin.js", "diff": "@@ -265,6 +265,11 @@ class BundlerHelper {\n}\nfunction EleventyPlugin(eleventyConfig, options = {}) {\n+ let inputDir = \".\";\n+ if (eleventyConfig.dir && eleventyConfig.dir.input) {\n+ inputDir = eleventyConfig.dir.input;\n+ }\n+\noptions = Object.assign(\n{\nname: \"\",\n@@ -286,7 +291,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\ncopyEnabled: true,\n// Input directory (used to generate the default serverless file)\n- inputDir: \".\",\n+ inputDir,\n},\noptions\n);\n" } ]
JavaScript
MIT License
11ty/eleventy
Reuse inputDir when returned in configuration file. Thanks @MadeByMike via https://github.com/11ty/eleventy/pull/1320
699
29.07.2021 08:28:09
18,000
598e4ca016a25bd3f87805f75e035fa57c5de8ef
Ability to re-use logger in plugins (for serverless plugin to works with verbose mode for free)
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -42,6 +42,8 @@ class Eleventy {\n}\n}\n+ this.eleventyConfig.setLogger(this.logger);\n+\nif (options.config && typeof options.config === \"function\") {\n// TODO use return object here?\noptions.config(this.eleventyConfig.userConfig);\n@@ -449,6 +451,7 @@ Verbose Output: ${this.verboseMode}`);\n/* Setter for Logger */\nset logger(logger) {\n+ this.eleventyConfig.setLogger(logger);\nthis._logger = logger;\n}\n@@ -478,6 +481,9 @@ Verbose Output: ${this.verboseMode}`);\nif (process.env.DEBUG) {\nisVerbose = false;\n}\n+ if (this.logger) {\n+ this.logger.isVerbose = isVerbose;\n+ }\nbench.setVerboseOutput(isVerbose);\nthis.verboseMode = isVerbose;\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/ServerlessBundlerPlugin.js", "new_path": "src/Plugins/ServerlessBundlerPlugin.js", "diff": "@@ -102,11 +102,12 @@ function addRedirectsWithoutDuplicates(name, config, newRedirects) {\n}\nclass BundlerHelper {\n- constructor(name, options) {\n+ constructor(name, options, eleventyConfig) {\nthis.name = name;\nthis.options = options;\nthis.dir = path.join(options.functionsDir, name);\nthis.copyCount = 0;\n+ this.eleventyConfig = eleventyConfig;\n}\nreset() {\n@@ -232,7 +233,7 @@ class BundlerHelper {\nres.write(result.body);\nres.end();\n- console.log(\n+ this.eleventyConfig.logger.forceLog(\n`Serverless (${this.name}): ${req.url} (${Date.now() - start}ms)`\n);\n};\n@@ -303,7 +304,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\nif (process.env.ELEVENTY_SOURCE === \"cli\") {\n- let helper = new BundlerHelper(options.name, options);\n+ let helper = new BundlerHelper(options.name, options, eleventyConfig);\neleventyConfig.setBrowserSyncConfig({\nmiddleware: [helper.browserSyncMiddleware()],\n@@ -340,8 +341,8 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nawait Promise.all(promises);\n}\n- console.log(\n- `Eleventy Serverless: ${helper.copyCount} file${\n+ eleventyConfig.logger.log(\n+ `Serverless: ${helper.copyCount} file${\nhelper.copyCount !== 1 ? \"s\" : \"\"\n} bundled to ${helper.getOutputPath(\"\")}.`\n);\n" }, { "change_type": "MODIFY", "old_path": "src/Util/ConsoleLogger.js", "new_path": "src/Util/ConsoleLogger.js", "diff": "@@ -69,6 +69,8 @@ class ConsoleLogger {\nif (!forceToConsole && (!this.isVerbose || process.env.DEBUG)) {\ndebug(message);\n} else if (this._logger !== false) {\n+ message = `[11ty] ${message}`;\n+\nlet logger = this._logger || console;\nif (chalkColor && this.isChalkEnabled) {\nlogger[type](chalk[chalkColor](message));\n" } ]
JavaScript
MIT License
11ty/eleventy
Ability to re-use logger in plugins (for serverless plugin to works with verbose mode for free)
699
29.07.2021 09:11:20
18,000
a11a8ba97f0d7c1447e8cf711ac861ef5e5a1e0d
Reinstate async filter test in liquid!! Fixes
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -176,17 +176,16 @@ test(\"Liquid Custom Filter\", async (t) => {\nt.is(await tr._testRender(\"{{ 'test' | prefixWithZach }}\", {}), \"Zachtest\");\n});\n-test.skip(\"Liquid Async Filter\", async (t) => {\n+test(\"Liquid Async Filter\", async (t) => {\nlet tr = getNewTemplateRender(\"liquid\", \"test/stubs\");\n- tr.engine.addFilter({\n- myAsyncFilter: function (value) {\n+ tr.engine.addFilter(\"myAsyncFilter\", async function (value) {\nreturn new Promise((resolve, reject) => {\nsetTimeout(function () {\nresolve(`HI${value}`);\n}, 100);\n});\n- },\n});\n+\nlet fn = await tr.getCompiledTemplate(\"{{ 'test' | myAsyncFilter }}\");\nt.is((await fn()).trim(), \"HItest\");\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
Reinstate async filter test in liquid!! Fixes https://github.com/11ty/eleventy/issues/831
699
29.07.2021 22:07:46
18,000
94757865113283a0993f65e926bf810d9a633e13
Fixes by removing unnecessary Capitlize utility
[ { "change_type": "DELETE", "old_path": "src/Util/Capitalize.js", "new_path": null, "diff": "-module.exports = function (str, options) {\n- options = Object.assign(\n- {\n- lowercaseRestOfWord: false,\n- },\n- options\n- );\n-\n- return str\n- .split(\" \")\n- .map(function (word) {\n- return (\n- word.substr(0, 1).toUpperCase() +\n- (options.lowercaseRestOfWord\n- ? word.substr(1).toLowerCase()\n- : word.substr(1))\n- );\n- })\n- .join(\" \");\n-};\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Sortable.js", "new_path": "src/Util/Sortable.js", "diff": "-const capitalize = require(\"./Capitalize\");\n-\nclass Sortable {\nconstructor() {\nthis.isSortAscending = true;\n@@ -8,10 +6,10 @@ class Sortable {\nthis._dirty = true;\nthis.sortFunctionStringMap = {\n- \"A-Z\": \"Ascending\",\n- \"Z-A\": \"Descending\",\n- \"0-9\": \"NumericAscending\",\n- \"9-0\": \"NumericDescending\",\n+ \"A-Z\": \"sortFunctionAscending\",\n+ \"Z-A\": \"sortFunctionDescending\",\n+ \"0-9\": \"sortFunctionNumericAscending\",\n+ \"9-0\": \"sortFunctionNumericDescending\",\n};\n}\n@@ -28,11 +26,20 @@ class Sortable {\nif (!sortFunction) {\nsortFunction = this.getSortFunction();\n} else if (typeof sortFunction === \"string\") {\n- if (sortFunction in this.sortFunctionStringMap) {\n- sortFunction = this.sortFunctionStringMap[sortFunction];\n+ let key = sortFunction;\n+ let name;\n+ if (key in this.sortFunctionStringMap) {\n+ name = this.sortFunctionStringMap[key];\n+ }\n+ if (Sortable[name]) {\n+ sortFunction = Sortable[name];\n+ } else {\n+ throw new Error(\n+ `Invalid String argument for sort(). Received \\`${key}\\`. Valid values: ${Object.keys(\n+ this.sortFunctionStringMap\n+ )}`\n+ );\n}\n-\n- sortFunction = Sortable[\"sortFunction\" + capitalize(sortFunction)];\n}\nreturn this.items.slice().sort(sortFunction);\n" }, { "change_type": "DELETE", "old_path": "test/CapitalizeTest.js", "new_path": null, "diff": "-const test = require(\"ava\");\n-const capitalize = require(\"../src/Util/Capitalize\");\n-\n-test(\"capitalize\", (t) => {\n- t.is(capitalize(\"hello\"), \"Hello\");\n- t.is(capitalize(\"hello world\"), \"Hello World\");\n- t.is(capitalize(\"Testing TESTING\"), \"Testing TESTING\");\n- t.is(\n- capitalize(\"Testing TESTING\", { lowercaseRestOfWord: true }),\n- \"Testing Testing\"\n- );\n-});\n" }, { "change_type": "MODIFY", "old_path": "test/SortableTest.js", "new_path": "test/SortableTest.js", "diff": "@@ -162,22 +162,6 @@ test(\"Date Descending\", (t) => {\nt.deepEqual(s.sort(), [date3, date2, date1]);\n});\n-test(\"Alphabetic Ascending (str sort arg)\", (t) => {\n- let s = new Sortable();\n- s.add(\"a\");\n- s.add(\"z\");\n- s.add(\"m\");\n- t.deepEqual(s.sort(\"ascending\"), [\"a\", \"m\", \"z\"]);\n-});\n-\n-test(\"Alphabetic Descending (str sort arg)\", (t) => {\n- let s = new Sortable();\n- s.add(\"a\");\n- s.add(\"z\");\n- s.add(\"m\");\n- t.deepEqual(s.sort(\"descending\"), [\"z\", \"m\", \"a\"]);\n-});\n-\ntest(\"Alphabetic Ascending (short str sort arg)\", (t) => {\nlet s = new Sortable();\ns.add(\"a\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes https://github.com/11ty/eleventy/pull/1909 by removing unnecessary Capitlize utility
699
06.08.2021 10:20:11
18,000
975816f9d53d480fc22d757b91d69a785dfd50aa
Removing ELEVENTY_EXPERIMENTAL requirement for `addExtension` in 1.0
[ { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -639,10 +639,6 @@ class UserConfig {\n}\naddExtension(fileExtension, options = {}) {\n- if (!process.env.ELEVENTY_EXPERIMENTAL) {\n- return;\n- }\n-\nthis.extensionMap.add(\nObject.assign(\n{\n" } ]
JavaScript
MIT License
11ty/eleventy
Removing ELEVENTY_EXPERIMENTAL requirement for `addExtension` in 1.0
699
06.08.2021 10:49:12
18,000
d55eb07d791f7534cb3f713c2e5827952d133893
Rename a variable for
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -946,15 +946,15 @@ class Template extends TemplateContent {\n}\n}\n} else {\n- let filenameRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\n- if (filenameRegex !== null) {\n- let dateObj = DateTime.fromISO(filenameRegex[1], {\n+ let filepathRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\n+ if (filepathRegex !== null) {\n+ let dateObj = DateTime.fromISO(filepathRegex[1], {\nzone: \"utc\",\n}).toJSDate();\ndebug(\n\"getMappedDate: using filename regex time for %o of %o: %o\",\nthis.inputPath,\n- filenameRegex[1],\n+ filepathRegex[1],\ndateObj\n);\nreturn dateObj;\n" } ]
JavaScript
MIT License
11ty/eleventy
Rename a variable for https://github.com/11ty/eleventy/issues/1742
699
06.08.2021 16:14:58
18,000
324cb26a858286d92a3c9c17c885dadcfab89982
Add limited number of tests for EleventyServerless Related to
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -364,7 +364,8 @@ class Eleventy {\n};\ndebug(`Directories:\n-Input: ${dirs.input}\n+Input (Dir): ${dirs.input}\n+Input (File?): ${this.rawInput}\nData: ${dirs.data}\nIncludes: ${dirs.includes}\nLayouts: ${dirs.layouts}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/ServerlessTest.js", "diff": "+const test = require(\"ava\");\n+const EleventyServerless = require(\"../src/Serverless\");\n+\n+test(\"Test a one-template markdown render.\", async (t) => {\n+ let elev = new EleventyServerless(\"test1\", {\n+ path: \"/\",\n+ query: {},\n+ inputDir: \"./test/serverless-stubs/\",\n+ functionsDir: \"./test/serverless-stubs/functions/\",\n+ });\n+\n+ t.is((await elev.render()).trim(), \"<h1>Hi</h1>\");\n+});\n+\n+test(\"Test a transform on serverless output.\", async (t) => {\n+ let elev = new EleventyServerless(\"test1\", {\n+ path: \"/\",\n+ query: {},\n+ inputDir: \"./test/serverless-stubs-config/\",\n+ functionsDir: \"./test/serverless-stubs-config/functions/\",\n+ });\n+\n+ t.is((await elev.render()).trim(), \"<h1>Hi</h1><p>Hi</p>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/serverless-stubs-config/functions/test1/eleventy-serverless-map.json", "diff": "+{\n+ \"/\": \"./test/serverless-stubs-config/test1.md\"\n+}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/serverless-stubs-config/functions/test1/eleventy.config.js", "diff": "+module.exports = function (eleventyConfig) {\n+ eleventyConfig.addTransform(\"transform-html\", function (content) {\n+ return `${content}`.trim() + \"<p>Hi</p>\";\n+ });\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/serverless-stubs-config/test1.md", "diff": "+---\n+permalink:\n+ test1: /\n+---\n+\n+# Hi\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/serverless-stubs/functions/test1/eleventy-serverless-map.json", "diff": "+{\n+ \"/\": \"./test/serverless-stubs/test1.md\"\n+}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/serverless-stubs/test1.md", "diff": "+---\n+permalink:\n+ test1: /\n+---\n+\n+# Hi\n" } ]
JavaScript
MIT License
11ty/eleventy
Add limited number of tests for EleventyServerless Related to #1901
699
06.08.2021 16:23:10
18,000
21630bfc292a5d42cf61b86f3b51841419c7cd67
Add Windows support for TemplatePath.absolutePath
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -134,18 +134,18 @@ TemplatePath.normalizeUrlPath = function (...urlPaths) {\nTemplatePath.absolutePath = function (...paths) {\nlet i = 0;\n// check all the paths before we short circuit from the first index\n- for (let path of paths) {\n- if (path.startsWith(\"/\") && i > 0) {\n+ for (let p of paths) {\n+ if (path.isAbsolute(p) && i > 0) {\nthrow new Error(\n- `Only the first parameter to Template.absolutePath can be an absolute path. Received: ${path} from ${paths}`\n+ `Only the first parameter to Template.absolutePath can be an absolute path. Received: ${p} from ${paths}`\n);\n}\ni++;\n}\nlet j = 0;\n- for (let path of paths) {\n- if (j === 0 && path.startsWith(\"/\")) {\n+ for (let p of paths) {\n+ if (j === 0 && path.isAbsolute(p)) {\nreturn TemplatePath.join(...paths);\n}\nj++;\n" } ]
JavaScript
MIT License
11ty/eleventy
Add Windows support for TemplatePath.absolutePath
699
09.08.2021 10:55:47
18,000
c611e7463a4a0e6dd53c322721d0a6788db22c0f
Add tests for Also fixes issue with using literal value
[ { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -245,7 +245,7 @@ class UserConfig {\nreturn this;\n}\n- addNunjucksGlobal(name, globalFn) {\n+ addNunjucksGlobal(name, globalType) {\nname = this.getNamespacedName(name);\nif (this.nunjucksGlobals[name]) {\n@@ -257,10 +257,14 @@ class UserConfig {\n);\n}\n+ if (typeof globalType === \"function\") {\nthis.nunjucksGlobals[name] = bench.add(\n`\"${name}\" Nunjucks Global`,\n- globalFn\n+ globalType\n);\n+ } else {\n+ this.nunjucksGlobals[name] = globalType;\n+ }\n}\naddTransform(name, callback) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderNunjucksTest.js", "new_path": "test/TemplateRenderNunjucksTest.js", "diff": "@@ -3,15 +3,15 @@ const TemplateRender = require(\"../src/TemplateRender\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst EleventyExtensionMap = require(\"../src/EleventyExtensionMap\");\n-function getNewTemplateRender(name, inputDir) {\n- let eleventyConfig = new TemplateConfig();\n+function getNewTemplateRender(name, inputDir, eleventyConfig) {\n+ if (!eleventyConfig) {\n+ eleventyConfig = new TemplateConfig();\n+ }\nlet tr = new TemplateRender(name, inputDir, eleventyConfig);\ntr.extensionMap = new EleventyExtensionMap([], eleventyConfig);\nreturn tr;\n}\n-class TestEleventyError extends Error {}\n-\nasync function getPromise(resolveTo) {\nreturn new Promise(function (resolve) {\nsetTimeout(function () {\n@@ -845,3 +845,25 @@ test(\"Nunjucks Parse for Symbols with custom block\", async (t) => {\nt.deepEqual(engine.parseForSymbols(\"<p>{{ name }} {% test %}</p>\"), [\"name\"]);\n});\n+\n+test(\"Use addNunjucksGlobal with function\", async (t) => {\n+ let templateConfig = new TemplateConfig();\n+ templateConfig.userConfig.addNunjucksGlobal(\"fortytwo\", function () {\n+ return 42;\n+ });\n+\n+ let tr = getNewTemplateRender(\"njk\", null, templateConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"<p>{{ fortytwo() }}</p>\");\n+ t.is(await fn(), \"<p>42</p>\");\n+});\n+\n+test(\"Use addNunjucksGlobal with literal\", async (t) => {\n+ let templateConfig = new TemplateConfig();\n+ templateConfig.userConfig.addNunjucksGlobal(\"fortytwo\", 42);\n+\n+ let tr = getNewTemplateRender(\"njk\", null, templateConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"<p>{{ fortytwo }}</p>\");\n+ t.is(await fn(), \"<p>42</p>\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Add tests for #1060. Also fixes issue with using literal value https://github.com/11ty/eleventy/pull/1060#issuecomment-881936530
699
09.08.2021 10:58:48
18,000
ad8a020a5d95bafe1ef0bb8ab5a52cddf6209922
Add skipped test for async
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderNunjucksTest.js", "new_path": "test/TemplateRenderNunjucksTest.js", "diff": "@@ -867,3 +867,14 @@ test(\"Use addNunjucksGlobal with literal\", async (t) => {\nlet fn = await tr.getCompiledTemplate(\"<p>{{ fortytwo }}</p>\");\nt.is(await fn(), \"<p>42</p>\");\n});\n+\n+// Async not supported here\n+test.skip(\"Use addNunjucksGlobal with async function\", async (t) => {\n+ let templateConfig = new TemplateConfig();\n+ templateConfig.userConfig.addNunjucksGlobal(\"fortytwo\", getPromise(42));\n+\n+ let tr = getNewTemplateRender(\"njk\", null, templateConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"<p>{{ fortytwo() }}</p>\");\n+ t.is(await fn(), \"<p>42</p>\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Add skipped test for async
699
10.08.2021 17:28:00
18,000
bbe9dd8f6adbbce495519299ee278d497628fefc
Regression with Nested addPlugin calls. Fixes
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -8,7 +8,6 @@ const UserConfig = require(\"./UserConfig\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateConfig\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateConfig\");\nconst deleteRequireCache = require(\"./Util/DeleteRequireCache\");\n-const aggregateBench = require(\"./BenchmarkManager\").get(\"Aggregate\");\n/**\n* @module 11ty/eleventy/TemplateConfig\n@@ -178,28 +177,10 @@ class TemplateConfig {\nthis.userConfig.logger = this.logger;\n}\n- this.userConfig.plugins.forEach(({ plugin, options }) => {\n- // TODO support function.name in plugin config functions\n- debug(\"Adding plugin (unknown name: check your config file).\");\n- let pluginBench = aggregateBench.get(\"Configuration addPlugin\");\n- if (typeof plugin === \"function\") {\n- pluginBench.before();\n- let configFunction = plugin;\n- configFunction(this.userConfig, options);\n- pluginBench.after();\n- } else if (plugin && plugin.configFunction) {\n- pluginBench.before();\n- if (options && typeof options.init === \"function\") {\n- options.init.call(this.userConfig, plugin.initArguments || {});\n- }\n+ this.userConfig._enablePluginExecution();\n- plugin.configFunction(this.userConfig, options);\n- pluginBench.after();\n- } else {\n- throw new UserConfigError(\n- \"Invalid EleventyConfig.addPlugin signature. Should be a function or a valid Eleventy plugin object.\"\n- );\n- }\n+ this.userConfig.plugins.forEach(({ plugin, options }) => {\n+ this.userConfig._executePlugin(plugin, options);\n});\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Regression with Nested addPlugin calls. Fixes https://github.com/11ty/eleventy/issues/1925
699
10.08.2021 17:30:22
18,000
ecd813be1a8153f4e290d4ba309e6ac21177f4da
Adds a comment about nested calls
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -177,6 +177,7 @@ class TemplateConfig {\nthis.userConfig.logger = this.logger;\n}\n+ // for Nested addPlugin calls, Issue #1925\nthis.userConfig._enablePluginExecution();\nthis.userConfig.plugins.forEach(({ plugin, options }) => {\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds a comment about nested calls
699
13.08.2021 20:18:07
18,000
292ec3083ebce80ce733a4ef4c72d17d11204b16
We now write a metadata file to the bundler output for configuration data, this will prevent mismatched data when making changes to the input directory after the serverless index.js file has already been generated. Fixes
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -365,7 +365,7 @@ class Eleventy {\ndebug(`Directories:\nInput (Dir): ${dirs.input}\n-Input (File?): ${this.rawInput}\n+Input (File): ${this.rawInput}\nData: ${dirs.data}\nIncludes: ${dirs.includes}\nLayouts: ${dirs.layouts}\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/DefaultServerlessFunctionContent.js", "new_path": "src/Plugins/DefaultServerlessFunctionContent.js", "diff": "@@ -8,7 +8,6 @@ async function handler(event) {\nlet elev = new EleventyServerless(\"%%NAME%%\", {\npath: event.path,\nquery: event.queryStringParameters,\n- inputDir: \"%%INPUT_DIR%%\",\nfunctionsDir: \"%%FUNCTIONS_DIR%%\",\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
We now write a metadata file to the bundler output for configuration data, this will prevent mismatched data when making changes to the input directory after the serverless index.js file has already been generated. Fixes #1929
699
14.08.2021 14:58:14
18,000
0eee96d7a6bcf4ad68c7a381501cb0a529c8fcbe
Fixes Adds process.env.ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTOUT as an escape hatch to bypass the monkey patch if ever needed.
[ { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "@@ -9,105 +9,116 @@ const eventBus = require(\"../EventBus\");\n* The IFFE below apply a monkey-patch to Nunjucks internals to cache\n* compiled templates and re-use them where possible.\n*/\n-// (function () {\n-// let templateCache = new Map();\n-\n-// let getKey = (obj) => {\n-// return [\n-// obj.path || obj.tmplStr,\n-// obj.tmplStr.length,\n-// obj.env.asyncFilters.length,\n-// obj.env.extensionsList\n-// .map((e) => {\n-// return e.__id || \"\";\n-// })\n-// .join(\":\"),\n-// ].join(\" :: \");\n-// };\n-\n-// let evictByPath = (path) => {\n-// let keys = templateCache.keys();\n-// // Likely to be slow; do we care?\n-// for (let k of keys) {\n-// if (k.indexOf(path) >= 0) {\n-// templateCache.delete(k);\n-// }\n-// }\n-// };\n-// eventBus.on(\"eleventy.resourceModified\", evictByPath);\n-\n-// let _compile = NunjucksLib.Template.prototype._compile;\n-// NunjucksLib.Template.prototype._compile = function _wrap_compile(...args) {\n-// if (!this.compiled && !this.tmplProps && templateCache.has(getKey(this))) {\n-// let pathProps = templateCache.get(getKey(this));\n-// this.blocks = pathProps.blocks;\n-// this.rootRenderFunc = pathProps.rootRenderFunc;\n-// this.compiled = true;\n-// } else {\n-// _compile.call(this, ...args);\n-// templateCache.set(getKey(this), {\n-// blocks: this.blocks,\n-// rootRenderFunc: this.rootRenderFunc,\n-// });\n-// }\n-// };\n-\n-// let extensionIdCounter = 0;\n-// let addExtension = NunjucksLib.Environment.prototype.addExtension;\n-// NunjucksLib.Environment.prototype.addExtension = function _wrap_addExtension(\n-// name,\n-// ext\n-// ) {\n-// if (!(\"__id\" in ext)) {\n-// ext.__id = extensionIdCounter++;\n-// }\n-// return addExtension.call(this, name, ext);\n-// };\n-\n-// // NunjucksLib.runtime.Frame.prototype.set is the hotest in-template method.\n-// // We replace it with a version that doesn't allocate a `parts` array on\n-// // repeat key use.\n-// let partsCache = new Map();\n-// let partsFromCache = (name) => {\n-// if (partsCache.has(name)) {\n-// return partsCache.get(name);\n-// }\n+(function () {\n+ if (process.env.ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTOUT) {\n+ return;\n+ }\n-// let parts = name.split(\".\");\n-// partsCache.set(name, parts);\n-// return parts;\n-// };\n-\n-// let frameSet = NunjucksLib.runtime.Frame.prototype.set;\n-// NunjucksLib.runtime.Frame.prototype.set = function _replacement_set(\n-// name,\n-// val,\n-// resolveUp\n-// ) {\n-// let parts = partsFromCache(name);\n-// let frame = this;\n-// let obj = frame.variables;\n-\n-// if (resolveUp) {\n-// if ((frame = this.resolve(parts[0], true))) {\n-// frame.set(name, val);\n-// return;\n-// }\n-// }\n+ let templateCache = new Map();\n-// // A slightly faster version of the intermediate object allocation loop\n-// let count = parts.length - 1;\n-// let i = 0;\n-// let id = parts[0];\n-// while (i < count) {\n-// if (!obj.hasOwnProperty(id)) {\n-// obj = obj[id] = {};\n-// }\n-// id = parts[++i];\n-// }\n-// obj[id] = val;\n-// };\n-// })();\n+ let getKey = (obj) => {\n+ return [\n+ obj.path || obj.tmplStr,\n+ obj.tmplStr.length,\n+ obj.env.asyncFilters.length,\n+ obj.env.extensionsList\n+ .map((e) => {\n+ return e.__id || \"\";\n+ })\n+ .join(\":\"),\n+ ].join(\" :: \");\n+ };\n+\n+ let evictByPath = (path) => {\n+ let keys = templateCache.keys();\n+ // Likely to be slow; do we care?\n+ for (let k of keys) {\n+ if (k.indexOf(path) >= 0) {\n+ templateCache.delete(k);\n+ }\n+ }\n+ };\n+ eventBus.on(\"eleventy.resourceModified\", evictByPath);\n+\n+ let _compile = NunjucksLib.Template.prototype._compile;\n+ NunjucksLib.Template.prototype._compile = function _wrap_compile(...args) {\n+ if (!this.compiled && !this.tmplProps && templateCache.has(getKey(this))) {\n+ let pathProps = templateCache.get(getKey(this));\n+ this.blocks = pathProps.blocks;\n+ this.rootRenderFunc = pathProps.rootRenderFunc;\n+ this.compiled = true;\n+ } else {\n+ _compile.call(this, ...args);\n+ templateCache.set(getKey(this), {\n+ blocks: this.blocks,\n+ rootRenderFunc: this.rootRenderFunc,\n+ });\n+ }\n+ };\n+\n+ let extensionIdCounter = 0;\n+ let addExtension = NunjucksLib.Environment.prototype.addExtension;\n+ NunjucksLib.Environment.prototype.addExtension = function _wrap_addExtension(\n+ name,\n+ ext\n+ ) {\n+ if (!(\"__id\" in ext)) {\n+ ext.__id = extensionIdCounter++;\n+ }\n+ return addExtension.call(this, name, ext);\n+ };\n+\n+ // NunjucksLib.runtime.Frame.prototype.set is the hotest in-template method.\n+ // We replace it with a version that doesn't allocate a `parts` array on\n+ // repeat key use.\n+ let partsCache = new Map();\n+ let partsFromCache = (name) => {\n+ if (partsCache.has(name)) {\n+ return partsCache.get(name);\n+ }\n+\n+ let parts = name.split(\".\");\n+ partsCache.set(name, parts);\n+ return parts;\n+ };\n+\n+ let frameSet = NunjucksLib.runtime.Frame.prototype.set;\n+ NunjucksLib.runtime.Frame.prototype.set = function _replacement_set(\n+ name,\n+ val,\n+ resolveUp\n+ ) {\n+ let parts = partsFromCache(name);\n+ let frame = this;\n+ let obj = frame.variables;\n+\n+ if (resolveUp) {\n+ if ((frame = this.resolve(parts[0], true))) {\n+ frame.set(name, val);\n+ return;\n+ }\n+ }\n+\n+ // A slightly faster version of the intermediate object allocation loop\n+ let count = parts.length - 1;\n+ let i = 0;\n+ let id = parts[0];\n+ while (i < count) {\n+ // TODO(zachleat) use Object.hasOwn when supported\n+ if (\"hasOwnProperty\" in obj) {\n+ if (!obj.hasOwnProperty(id)) {\n+ obj = obj[id] = {};\n+ }\n+ } else if (!(id in obj)) {\n+ // Handle Objects with null prototypes (Nunjucks looping stuff)\n+ obj = obj[id] = {};\n+ }\n+\n+ id = parts[++i];\n+ }\n+ obj[id] = val;\n+ };\n+})();\nclass EleventyShortcodeError extends EleventyBaseError {}\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes #1678. Adds process.env.ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTOUT as an escape hatch to bypass the monkey patch if ever needed.
713
14.08.2021 19:42:10
18,000
c404506c53eaeccb2049145bd2e9e867385fa2b0
refactor: rename defaultCompiler to defaultRenderer
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -76,9 +76,9 @@ class CustomEngine extends TemplateEngine {\nasync compile(str, inputPath, ...args) {\nawait this._runningInit();\n- let defaultCompiler;\n+ let defaultRenderer;\nif (this._defaultEngine) {\n- defaultCompiler = async (data) => {\n+ defaultRenderer = async (data) => {\nconst render = await this._defaultEngine.compile(\nstr,\ninputPath,\n@@ -89,16 +89,17 @@ class CustomEngine extends TemplateEngine {\n}\n// Fall back to default compiler if the user does not provide their own\n- if (!this.entry.compile && defaultCompiler) {\n- return defaultCompiler;\n+ if (!this.entry.compile && defaultRenderer) {\n+ return defaultRenderer;\n}\n// TODO generalize this (look at JavaScript.js)\n- return this.entry.compile\n- // give the user access to this engine's default compiler, if any\n- .bind({ config: this.config, defaultCompiler })(str, inputPath)\n- // bind again for access inside function (data) {...}\n- .bind({ defaultCompiler });\n+ return (\n+ this.entry.compile\n+ .bind({ config: this.config })(str, inputPath)\n+ // give the user access to this engine's default renderer, if any\n+ .bind({ defaultRenderer })\n+ );\n}\nget defaultTemplateFileExtension() {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderCustomTest.js", "new_path": "test/TemplateRenderCustomTest.js", "diff": "@@ -82,7 +82,7 @@ test(\"Custom Markdown Render with `compile` override + call to default compiler\"\nkey: \"md\",\ncompile: function (str, inputPath) {\nreturn async function (data) {\n- const result = await this.defaultCompiler(data);\n+ const result = await this.defaultRenderer(data);\nreturn `<custom-wrapper>${result.trim()}</custom-wrapper>`;\n};\n},\n@@ -116,8 +116,8 @@ test(\"Custom Vue Render\", async (t) => {\n},\n});\n- let fn = await tr.getCompiledTemplate(`<p v-html=\"test\">Paragraph</p>`);\n- t.is(await fn({ test: \"Hello\" }), `<p data-server-rendered=\"true\">Hello</p>`);\n+ let fn = await tr.getCompiledTemplate('<p v-html=\"test\">Paragraph</p>');\n+ t.is(await fn({ test: \"Hello\" }), '<p data-server-rendered=\"true\">Hello</p>');\n});\nconst sass = require(\"sass\");\n@@ -154,7 +154,7 @@ test(\"Custom Sass Render\", async (t) => {\n},\n});\n- let fn = await tr.getCompiledTemplate(`$color: blue; p { color: $color; }`);\n+ let fn = await tr.getCompiledTemplate(\"$color: blue; p { color: $color; }\");\nt.is(\n(await fn({})).trim(),\n`p {\n" } ]
JavaScript
MIT License
11ty/eleventy
refactor: rename defaultCompiler to defaultRenderer
713
14.08.2021 19:42:49
18,000
c4c5455c058106eca50d0d2cfb387d0faf03e5cf
refactor: use this.getEngineClassByExtension() for custom engine require
[ { "change_type": "MODIFY", "old_path": "src/TemplateEngineManager.js", "new_path": "src/TemplateEngineManager.js", "diff": "@@ -97,7 +97,7 @@ class TemplateEngineManager {\nthis.getClassNameFromTemplateKey(name) === \"Custom\" &&\ninstance.constructor.name !== \"CustomEngine\"\n) {\n- const CustomEngine = require(\"./Engines/Custom\");\n+ const CustomEngine = this.getEngineClassByExtension();\nconst overrideCustomEngine = new CustomEngine(\nname,\nincludesDir,\n" } ]
JavaScript
MIT License
11ty/eleventy
refactor: use this.getEngineClassByExtension() for custom engine require
699
15.08.2021 15:10:49
18,000
9f8bed319b2923a1755d415c3b2a3ab9e72c4c01
Adds `.setNunjucksEnvironmentOptions` configuration API method. Options documented here: Cleans up the Liquid/Pug options code a bit, was unnecessarily complex for testing Fixes
[ { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -8,10 +8,9 @@ class Liquid extends TemplateEngine {\nconstructor(name, includesDir, config) {\nsuper(name, includesDir, config);\n- this.liquidOptions = {};\n+ this.liquidOptions = this.config.liquidOptions || {};\nthis.setLibrary(this.config.libraryOverrides.liquid);\n- this.setLiquidOptions(this.config.liquidOptions);\nthis.argLexer = moo.compile({\nnumber: /[0-9]+\\.*[0-9]*/,\n@@ -23,11 +22,9 @@ class Liquid extends TemplateEngine {\nthis.cacheable = true;\n}\n- setLibrary(lib) {\n- this.liquidLibOverride = lib;\n-\n+ setLibrary(override) {\n// warning, the include syntax supported here does not exactly match what Jekyll uses.\n- this.liquidLib = lib || new liquidLib.Liquid(this.getLiquidOptions());\n+ this.liquidLib = override || new liquidLib.Liquid(this.getLiquidOptions());\nthis.setEngineLib(this.liquidLib);\nthis.addFilters(this.config.liquidFilters);\n@@ -38,12 +35,6 @@ class Liquid extends TemplateEngine {\nthis.addAllPairedShortcodes(this.config.liquidPairedShortcodes);\n}\n- setLiquidOptions(options) {\n- this.liquidOptions = options;\n-\n- this.setLibrary(this.liquidLibOverride);\n- }\n-\ngetLiquidOptions() {\nlet defaults = {\nroot: [super.getIncludesDir()], // overrides in compile with inputPath below\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "@@ -125,18 +125,24 @@ class EleventyShortcodeError extends EleventyBaseError {}\nclass Nunjucks extends TemplateEngine {\nconstructor(name, includesDir, config) {\nsuper(name, includesDir, config);\n+ this.nunjucksEnvironmentOptions =\n+ this.config.nunjucksEnvironmentOptions || {};\nthis.setLibrary(this.config.libraryOverrides.njk);\nthis.cacheable = true;\n}\n- setLibrary(env) {\n+ setLibrary(override) {\nlet fsLoader = new NunjucksLib.FileSystemLoader([\nsuper.getIncludesDir(),\nTemplatePath.getWorkingDir(),\n]);\n- this.njkEnv = env || new NunjucksLib.Environment(fsLoader);\n+\n+ this.njkEnv =\n+ override ||\n+ new NunjucksLib.Environment(fsLoader, this.nunjucksEnvironmentOptions);\n+\n// Correct, but overbroad. Better would be to evict more granularly, but\n// resolution from paths isn't straightforward.\neventBus.on(\"eleventy.resourceModified\", (path) => {\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Pug.js", "new_path": "src/Engines/Pug.js", "diff": "@@ -5,21 +5,16 @@ class Pug extends TemplateEngine {\nconstructor(name, includesDir, config) {\nsuper(name, includesDir, config);\n- this.pugOptions = {};\n+ this.pugOptions = this.config.pugOptions || {};\nthis.setLibrary(this.config.libraryOverrides.pug);\n- this.setPugOptions(this.config.pugOptions);\n}\n- setLibrary(lib) {\n- this.pugLib = lib || PugLib;\n+ setLibrary(override) {\n+ this.pugLib = override || PugLib;\nthis.setEngineLib(this.pugLib);\n}\n- setPugOptions(options) {\n- this.pugOptions = options;\n- }\n-\ngetPugOptions() {\nlet includesDir = super.getIncludesDir();\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -3,8 +3,12 @@ const TemplateRender = require(\"../src/TemplateRender\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst EleventyExtensionMap = require(\"../src/EleventyExtensionMap\");\n-function getNewTemplateRender(name, inputDir) {\n+function getNewTemplateRender(name, inputDir, userConfig = {}) {\nlet eleventyConfig = new TemplateConfig();\n+ for (let key in userConfig) {\n+ eleventyConfig.userConfig[key] = userConfig[key];\n+ }\n+\nlet tr = new TemplateRender(name, inputDir, eleventyConfig);\ntr.extensionMap = new EleventyExtensionMap([], eleventyConfig);\nreturn tr;\n@@ -64,10 +68,12 @@ test(\"Liquid Render Include\", async (t) => {\n\"liquid\"\n);\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\"<p>{% include included %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n@@ -78,10 +84,12 @@ test(\"Liquid Render Relative Include\", async (t) => {\n\"liquid\"\n);\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\"<p>{% include ./included %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n@@ -89,11 +97,14 @@ test(\"Liquid Render Relative Include\", async (t) => {\ntest(\"Liquid Render Relative (current dir) Include\", async (t) => {\nlet tr = await getNewTemplateRender(\n\"./test/stubs/relative-liquid/does_not_exist_and_thats_ok.liquid\",\n- \"./test/stubs/\"\n- );\n- tr.engine.setLiquidOptions({\n+ \"./test/stubs/\",\n+ {\n+ liquidOptions: {\ndynamicPartials: false,\n- });\n+ },\n+ }\n+ );\n+\nlet fn = await tr.getCompiledTemplate(\"<p>{% include ./dir/included %}</p>\");\nt.is(await fn(), \"<p>TIME IS RELATIVE.</p>\");\n});\n@@ -101,11 +112,14 @@ test(\"Liquid Render Relative (current dir) Include\", async (t) => {\ntest(\"Liquid Render Relative (parent dir) Include\", async (t) => {\nlet tr = await getNewTemplateRender(\n\"./test/stubs/relative-liquid/dir/does_not_exist_and_thats_ok.liquid\",\n- \"./test/stubs/\"\n- );\n- tr.engine.setLiquidOptions({\n+ \"./test/stubs/\",\n+ {\n+ liquidOptions: {\ndynamicPartials: false,\n- });\n+ },\n+ }\n+ );\n+\nlet fn = await tr.getCompiledTemplate(\"<p>{% include ../dir/included %}</p>\");\nt.is(await fn(), \"<p>TIME IS RELATIVE.</p>\");\n});\n@@ -129,10 +143,12 @@ test(\"Liquid Render Include with Liquid Suffix\", async (t) => {\n\"liquid\"\n);\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\"<p>{% include included.liquid %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n@@ -143,10 +159,12 @@ test(\"Liquid Render Include with HTML Suffix\", async (t) => {\n\"liquid\"\n);\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\"<p>{% include included.html %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n@@ -157,10 +175,12 @@ test(\"Liquid Render Include with HTML Suffix and Data Pass in\", async (t) => {\n\"liquid\"\n);\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\n\"{% include included-data.html, myVariable: 'myValue' %}\"\n);\n@@ -444,10 +464,12 @@ test(\"Liquid Async Paired Shortcode\", async (t) => {\n});\ntest(\"Liquid Render Include Subfolder\", async (t) => {\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\n`<p>{% include subfolder/included.liquid %}</p>`\n);\n@@ -455,10 +477,12 @@ test(\"Liquid Render Include Subfolder\", async (t) => {\n});\ntest(\"Liquid Render Include Subfolder HTML\", async (t) => {\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\n`<p>{% include subfolder/included.html %}</p>`\n);\n@@ -466,10 +490,12 @@ test(\"Liquid Render Include Subfolder HTML\", async (t) => {\n});\ntest(\"Liquid Render Include Subfolder No file extension\", async (t) => {\n- let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\ndynamicPartials: false,\n+ },\n});\n+\nlet fn = await tr.getCompiledTemplate(\n`<p>{% include subfolder/included %}</p>`\n);\n@@ -528,8 +554,11 @@ test(\"Liquid Render Include Subfolder Double quotes No file extension\", async (t\n/* End tests related to dynamicPartials */\ntest(\"Liquid Options Overrides\", async (t) => {\n- let tr = getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({ dynamicPartials: false });\n+ let tr = getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\n+ dynamicPartials: false,\n+ },\n+ });\nlet options = tr.engine.getLiquidOptions();\nt.is(options.dynamicPartials, false);\n@@ -691,8 +720,11 @@ test.skip(\"Liquid Include Scope Leak\", async (t) => {\n// Note: this strictFilters default changed in 1.0 from false to true\ntest(\"Liquid Missing Filter Issue #183 (no strictFilters)\", async (t) => {\n- let tr = getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.setLiquidOptions({ strictFilters: false });\n+ let tr = getNewTemplateRender(\"liquid\", \"./test/stubs/\", {\n+ liquidOptions: {\n+ strictFilters: false,\n+ },\n+ });\ntry {\nawait tr._testRender(\"{{ 'test' | prefixWithZach }}\", {});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderNunjucksTest.js", "new_path": "test/TemplateRenderNunjucksTest.js", "diff": "@@ -7,6 +7,7 @@ function getNewTemplateRender(name, inputDir, eleventyConfig) {\nif (!eleventyConfig) {\neleventyConfig = new TemplateConfig();\n}\n+\nlet tr = new TemplateRender(name, inputDir, eleventyConfig);\ntr.extensionMap = new EleventyExtensionMap([], eleventyConfig);\nreturn tr;\n@@ -878,3 +879,34 @@ test.skip(\"Use addNunjucksGlobal with async function\", async (t) => {\nlet fn = await tr.getCompiledTemplate(\"<p>{{ fortytwo() }}</p>\");\nt.is(await fn(), \"<p>42</p>\");\n});\n+\n+test(\"Use config driven Nunjucks Environment Options (throws on undefined variable)\", async (t) => {\n+ let templateConfig = new TemplateConfig();\n+ templateConfig.userConfig.setNunjucksEnvironmentOptions({\n+ throwOnUndefined: true,\n+ });\n+\n+ let tr = getNewTemplateRender(\"njk\", null, templateConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"<p> {{ test }}</p>\");\n+ await t.throwsAsync(async () => {\n+ await fn({});\n+ });\n+});\n+\n+test(\"Use config driven Nunjucks Environment Options (autoescape)\", async (t) => {\n+ let templateConfig = new TemplateConfig();\n+ templateConfig.userConfig.setNunjucksEnvironmentOptions({\n+ autoescape: false,\n+ });\n+\n+ let tr = getNewTemplateRender(\"njk\", null, templateConfig);\n+\n+ let fn = await tr.getCompiledTemplate(\"<p>{{ test }}</p>\");\n+ t.is(\n+ await fn({\n+ test: \"<b>Hi</b>\",\n+ }),\n+ \"<p><b>Hi</b></p>\"\n+ );\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderPugTest.js", "new_path": "test/TemplateRenderPugTest.js", "diff": "@@ -3,8 +3,12 @@ const TemplateRender = require(\"../src/TemplateRender\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst EleventyExtensionMap = require(\"../src/EleventyExtensionMap\");\n-function getNewTemplateRender(name, inputDir) {\n- let eleventyConfig = new TemplateConfig();\n+function getNewTemplateRender(name, inputDir, config) {\n+ let eleventyConfig = config;\n+ if (!eleventyConfig) {\n+ eleventyConfig = new TemplateConfig();\n+ }\n+\nlet tr = new TemplateRender(name, inputDir, eleventyConfig);\ntr.extensionMap = new EleventyExtensionMap([], eleventyConfig);\nreturn tr;\n@@ -105,8 +109,11 @@ test(\"Pug Render Include (Relative, dot dot slash)\", async (t) => {\n});\ntest(\"Pug Options Overrides\", async (t) => {\n- let tr = getNewTemplateRender(\"pug\", \"./test/stubs/\");\n- tr.engine.setPugOptions({ testoption: \"testoverride\" });\n+ let cfg = new TemplateConfig();\n+ cfg.userConfig.setPugOptions({\n+ testoption: \"testoverride\",\n+ });\n+ let tr = getNewTemplateRender(\"pug\", \"./test/stubs/\", cfg);\nlet options = tr.engine.getPugOptions();\nt.is(options.testoption, \"testoverride\");\n@@ -128,8 +135,8 @@ test(\"Pug Render: with Library Override\", async (t) => {\n});\ntest(\"Pug Filter\", async (t) => {\n- let tr = getNewTemplateRender(\"pug\", \"./test/stubs/\");\n- tr.engine.setPugOptions({\n+ let cfg = new TemplateConfig();\n+ cfg.userConfig.setPugOptions({\nfilters: {\nmakeUppercase: function (text, options) {\nreturn text.toUpperCase();\n@@ -137,6 +144,8 @@ test(\"Pug Filter\", async (t) => {\n},\n});\n+ let tr = getNewTemplateRender(\"pug\", \"./test/stubs/\", cfg);\n+\nlet fn = await tr.getCompiledTemplate(`p\n:makeUppercase()\nZach\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `.setNunjucksEnvironmentOptions` configuration API method. Options documented here: https://mozilla.github.io/nunjucks/api.html#configure Cleans up the Liquid/Pug options code a bit, was unnecessarily complex for testing Fixes #895.
685
03.09.2021 16:35:20
-18,000
6fc8eb1282707890b5124ecc35e9a1d2a7d0b31e
Check `permalink` field before set extra output subdirectory for pagination
[ { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -310,7 +310,9 @@ class Pagination {\nlet cloned = tmpl.clone();\n// TODO maybe also move this permalink additions up into the pagination class\n- if (pageNumber > 0 && !this.data[this.config.keys.permalink]) {\n+ let hasPermalinkField = Boolean(this.data[this.config.keys.permalink]);\n+ let hasComputedPermalinkField = Boolean(this.data.eleventyComputed && this.data.eleventyComputed[this.config.keys.permalink]);\n+ if (pageNumber > 0 && !(hasPermalinkField || hasComputedPermalinkField)) {\ncloned.setExtraOutputSubdirectory(pageNumber);\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Check `permalink` field before set extra output subdirectory for pagination
699
03.09.2021 11:16:58
18,000
be3db7882c4b9cd0452ec58f9c385364aed671e0
Removes valid-url dependency and relies on core url package.
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"slugify\": \"^1.6.0\",\n\"split\": \"^1.0.1\",\n\"time-require\": \"^0.1.2\",\n- \"url-pattern\": \"^1.0.3\",\n- \"valid-url\": \"^1.0.9\"\n+ \"url-pattern\": \"^1.0.3\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -407,7 +407,8 @@ Verbose Output: ${this.verboseMode}`);\nprocess.env.ELEVENTY_SOURCE = this.source;\n- // careful here, setting to false will cast to string \"false\" which is truthy\n+ // TODO @zachleat this needs to be extensible. https://github.com/11ty/eleventy/issues/1957\n+ // Careful here, setting to false will cast to string \"false\" which is truthy.\nif (process.env.AWS_LAMBDA_FUNCTION_NAME) {\nprocess.env.ELEVENTY_SERVERLESS = true;\ndebug(\"Setting process.env.ELEVENTY_SERVERLESS: %o\", true);\n" }, { "change_type": "MODIFY", "old_path": "src/Filters/Url.js", "new_path": "src/Filters/Url.js", "diff": "-const validUrl = require(\"valid-url\");\nconst TemplatePath = require(\"../TemplatePath\");\n+function isValidUrl(url) {\n+ try {\n+ new URL(url);\n+ return true;\n+ } catch (e) {\n+ // invalid url OR local path\n+ return false;\n+ }\n+}\n+\n// This is also used in the Eleventy Navigation plugin\nmodule.exports = function (url, pathPrefix) {\n// work with undefined\nurl = url || \"\";\n- if (\n- validUrl.isUri(url) ||\n- url.indexOf(\"http://\") === 0 ||\n- url.indexOf(\"https://\") === 0 ||\n- (url.indexOf(\"//\") === 0 && url !== \"//\")\n- ) {\n+ if (isValidUrl(url) || (url.indexOf(\"//\") === 0 && url !== \"//\")) {\nreturn url;\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Removes valid-url dependency and relies on core url package.
699
06.09.2021 15:17:48
18,000
f83fc0bcc0eb5d6403c6aa5f5f89587dec77cf29
Swap to ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTIN. Fixes Related to
[ { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "@@ -10,7 +10,7 @@ const eventBus = require(\"../EventBus\");\n* compiled templates and re-use them where possible.\n*/\n(function () {\n- if (process.env.ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTOUT) {\n+ if (!process.env.ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTIN) {\nreturn;\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Swap to ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTIN. Fixes #1960. Related to #1678.
699
08.09.2021 12:38:12
18,000
229f3801d506d30beb745ef907cf86fe69df623e
Make process.env.ELEVENTY_SERVERLESS work correctly when using --serve.
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -407,7 +407,9 @@ Verbose Output: ${this.verboseMode}`);\nprocess.env.ELEVENTY_SOURCE = this.source;\n- // TODO @zachleat this needs to be extensible. https://github.com/11ty/eleventy/issues/1957\n+ // TODO (@zachleat) this needs to be extensible. https://github.com/11ty/eleventy/issues/1957\n+ // Note: when using --serve, ELEVENTY_SERVERLESS is set manually in Serverless.js\n+\n// Careful here, setting to false will cast to string \"false\" which is truthy.\nif (process.env.AWS_LAMBDA_FUNCTION_NAME) {\nprocess.env.ELEVENTY_SERVERLESS = true;\n" } ]
JavaScript
MIT License
11ty/eleventy
Make process.env.ELEVENTY_SERVERLESS work correctly when using --serve.
699
27.09.2021 09:57:02
18,000
508114a6743fac1741d581cbf19d54b7d96d974a
Refactor to get rid of _test method caused by changes to
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -527,9 +527,11 @@ test(\"Posts inherits local JSON, layouts\", async (t) => {\n\"./test/stubs/posts/post1.11tydata.js\",\n]);\n- let localData = await dataObj._testGetLocalData(tmpl.getInputPath());\n+ let localData = await dataObj.getTemplateDirectoryData(tmpl.getInputPath());\nt.is(localData.layout, \"mylocallayout.njk\");\n- t.truthy(localData.pkg);\n+\n+ let globalData = await dataObj.getGlobalData();\n+ t.truthy(globalData.pkg);\nlet data = await tmpl.getData();\nt.is(localData.layout, \"mylocallayout.njk\");\n@@ -565,9 +567,11 @@ test(\"Template and folder name are the same, make sure data imports work ok\", as\n\"./test/stubs/posts/posts.11tydata.js\",\n]);\n- let localData = await dataObj._testGetLocalData(tmpl.getInputPath());\n+ let localData = await dataObj.getTemplateDirectoryData(tmpl.getInputPath());\nt.is(localData.layout, \"mylocallayout.njk\");\n- t.truthy(localData.pkg);\n+\n+ let globalData = await dataObj.getGlobalData();\n+ t.truthy(globalData.pkg);\nlet data = await tmpl.getData();\nt.is(localData.layout, \"mylocallayout.njk\");\n" }, { "change_type": "MODIFY", "old_path": "test/UserDataExtensionsTest.js", "new_path": "test/UserDataExtensionsTest.js", "diff": "@@ -26,7 +26,7 @@ test(\"Local data\", async (t) => {\nt.is(data.globalData4.datakey1, \"datavalue4\");\nt.is(data.globalData4.datakey2, \"@11ty/eleventy--nosj\");\n- let withLocalData = await dataObj._testGetLocalData(\n+ let withLocalData = await dataObj.getTemplateDirectoryData(\n\"./test/stubs-630/component-yaml/component.njk\"\n);\n" } ]
JavaScript
MIT License
11ty/eleventy
Refactor to get rid of _test method caused by changes to #915
699
03.10.2021 14:06:53
18,000
2824db33bab6ef5e8790f2f15a651d331c146f30
Update deps. Lock to liquidjs 9.25 for
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"devDependencies\": {\n\"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.2\",\n\"ava\": \"^3.15.0\",\n- \"husky\": \"^7.0.1\",\n+ \"husky\": \"^7.0.2\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.1.2\",\n\"markdown-it-emoji\": \"^2.0.0\",\n\"nyc\": \"^15.1.0\",\n- \"prettier\": \"^2.3.2\",\n+ \"prettier\": \"^2.4.1\",\n\"rimraf\": \"^3.0.2\",\n- \"sass\": \"^1.37.5\",\n+ \"sass\": \"^1.42.1\",\n\"toml\": \"^3.0.0\",\n\"vue\": \"^2.6.14\",\n\"vue-server-renderer\": \"^2.6.14\"\n\"gray-matter\": \"^4.0.3\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n- \"is-glob\": \"^4.0.1\",\n- \"liquidjs\": \"^9.25.1\",\n+ \"is-glob\": \"^4.0.3\",\n+ \"liquidjs\": \"9.25.1\",\n\"lodash\": \"^4.17.21\",\n\"luxon\": \"^2.0.2\",\n\"markdown-it\": \"^12.2.0\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Update deps. Lock to liquidjs 9.25 for https://github.com/harttle/liquidjs/issues/395
718
07.10.2021 17:20:03
-3,600
d48cf041d46f6e0e8c4befde12e18e08fc06e9f1
Fix being unable to namespace when using addPlugin
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -180,9 +180,14 @@ class TemplateConfig {\n// for Nested addPlugin calls, Issue #1925\nthis.userConfig._enablePluginExecution();\n- this.userConfig.plugins.forEach(({ plugin, options }) => {\n+ let storedActiveNamespace = this.userConfig.activeNamespace;\n+\n+ this.userConfig.plugins.forEach(({ plugin, options, pluginNamespace }) => {\n+ this.userConfig.activeNamespace = pluginNamespace;\nthis.userConfig._executePlugin(plugin, options);\n});\n+\n+ this.userConfig.activeNamespace = storedActiveNamespace;\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -316,7 +316,11 @@ class UserConfig {\nif (this._pluginExecution) {\nthis._executePlugin(plugin, options);\n} else {\n- this.plugins.push({ plugin, options });\n+ this.plugins.push({\n+ plugin,\n+ options,\n+ pluginNamespace: this.activeNamespace,\n+ });\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "@@ -115,6 +115,7 @@ test(\"Add universal filter\", (t) => {\nt.not(Object.keys(cfg.handlebarsHelpers).indexOf(\"myFilterName\"), -1);\nt.not(Object.keys(cfg.nunjucksFilters).indexOf(\"myFilterName\"), -1);\n});\n+\ntest(\"Add namespaced universal filter\", (t) => {\nlet templateCfg = new TemplateConfig(\nrequire(\"../src/defaultConfig.js\"),\n@@ -163,6 +164,56 @@ test(\"Add namespaced universal filter using underscore\", (t) => {\n);\n});\n+test(\"Add namespaced plugin\", (t) => {\n+ let templateCfg = new TemplateConfig();\n+\n+ templateCfg.userConfig.namespace(\"testNamespace\", function () {\n+ templateCfg.userConfig.addPlugin(function (eleventyConfig) {\n+ eleventyConfig.addFilter(\"MyFilterName\", function () {});\n+ });\n+ });\n+\n+ let cfg = templateCfg.getConfig();\n+ t.not(\n+ Object.keys(cfg.liquidFilters).indexOf(\"testNamespaceMyFilterName\"),\n+ -1\n+ );\n+ t.not(\n+ Object.keys(cfg.handlebarsHelpers).indexOf(\"testNamespaceMyFilterName\"),\n+ -1\n+ );\n+ t.not(\n+ Object.keys(cfg.nunjucksFilters).indexOf(\"testNamespaceMyFilterName\"),\n+ -1\n+ );\n+});\n+\n+test(\"Add namespaced plugin using underscore\", (t) => {\n+ let templateCfg = new TemplateConfig(\n+ require(\"../src/defaultConfig.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ templateCfg.userConfig.namespace(\"testNamespace_\", function () {\n+ templateCfg.userConfig.addPlugin(function (config) {\n+ config.addFilter(\"myFilterName\", function () {});\n+ });\n+ });\n+\n+ let cfg = templateCfg.getConfig();\n+ t.not(\n+ Object.keys(cfg.liquidFilters).indexOf(\"testNamespace_myFilterName\"),\n+ -1\n+ );\n+ t.not(\n+ Object.keys(cfg.handlebarsHelpers).indexOf(\"testNamespace_myFilterName\"),\n+ -1\n+ );\n+ t.not(\n+ Object.keys(cfg.nunjucksFilters).indexOf(\"testNamespace_myFilterName\"),\n+ -1\n+ );\n+});\n+\ntest(\"Empty namespace\", (t) => {\nlet templateCfg = new TemplateConfig(\nrequire(\"../src/defaultConfig.js\"),\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix being unable to namespace when using addPlugin
699
16.10.2021 15:45:06
18,000
f63d5fecd85231738cdc1e99b98a054fd1c2126a
The unskipped test went fine, removing the comment.
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest-ComputedData.js", "new_path": "test/TemplateTest-ComputedData.js", "diff": "@@ -187,7 +187,6 @@ test(\"eleventyComputed using symbol parsing on template strings (nunjucks)\", asy\nt.is(data.c, \"ab\");\n});\n-// TODO why is this skipped? https://github.com/11ty/eleventy/commit/79245d85bcfba3ce8e8b75d84315c6c5bd81bbd3\ntest(\"eleventyComputed using symbol parsing on template strings (liquid)\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs-computed-symbolparse/test.liquid\",\n" } ]
JavaScript
MIT License
11ty/eleventy
The unskipped test went fine, removing the comment.
680
19.10.2021 11:56:48
14,400
43db0ea5ce7fcd4725b920efdf774f4f3c2b04da
Add --port to CLI --help
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -539,6 +539,9 @@ Arguments:\n--serve\nRun web server on --port (default 8080) and watch them too\n+ --port\n+ Run the --serve web server on this port (default 8080)\n+\n--watch\nWait for files to change and automatically rewrite (no web server)\n" } ]
JavaScript
MIT License
11ty/eleventy
[#1938]: Add --port to CLI --help
709
26.10.2021 13:33:45
0
3e34fbb09b35420e82275c4c936c2a3893df25d1
Update browser-sync to 2.27.6
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"@11ty/dependency-tree\": \"^2.0.0\",\n\"@iarna/toml\": \"^2.2.5\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n- \"browser-sync\": \"^2.27.5\",\n+ \"browser-sync\": \"^2.27.6\",\n\"chalk\": \"^4.1.2\",\n\"chokidar\": \"^3.5.2\",\n\"debug\": \"^4.3.2\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Update browser-sync to 2.27.6
699
03.11.2021 17:59:59
18,000
ccf9c89b94bbed1c3162fbff2c94891267e7f1cb
Add configuration callback to serverless class. Run your own config code in the serverless function. Fixes
[ { "change_type": "MODIFY", "old_path": "src/Serverless.js", "new_path": "src/Serverless.js", "diff": "@@ -47,6 +47,8 @@ class Serverless {\nquery: {},\n// Inject shared collections\nprecompiledCollections: {},\n+ // Configuration callback\n+ config: function (eleventyConfig) {},\n},\noptions\n);\n@@ -204,6 +206,10 @@ class Serverless {\n};\neleventyConfig.addGlobalData(\"eleventy.serverless\", globalData);\n+\n+ if (this.options.config && typeof this.options.config === \"function\") {\n+ this.options.config(eleventyConfig);\n+ }\n},\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
Add configuration callback to serverless class. Run your own config code in the serverless function. Fixes #2066
699
04.11.2021 18:10:07
18,000
a9c29f40f8685737ddef2ac79349152acd35c524
Adds getOutput method to serverless to return all of the raw entries that match the path (for advanced serverless usage). Adds `dataFilterSelectors` to configuration file to allow some data to pass through to the JSON object returned by Eleventy.prototype.toJSON. These are lodash selectors.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -3,6 +3,8 @@ const os = require(\"os\");\nconst path = require(\"path\");\nconst normalize = require(\"normalize-path\");\nconst isPlainObject = require(\"lodash/isPlainObject\");\n+const lodashGet = require(\"lodash/get\");\n+const lodashSet = require(\"lodash/set\");\nconst { DateTime } = require(\"luxon\");\nconst TemplateData = require(\"./TemplateData\");\n@@ -805,6 +807,15 @@ class Template extends TemplateContent {\nreturn content;\n}\n+ retrieveDataForJsonOutput(data, selectors) {\n+ let filtered = {};\n+ for (let selector of selectors) {\n+ let value = lodashGet(data, selector);\n+ lodashSet(filtered, selector, value);\n+ }\n+ return filtered;\n+ }\n+\nasync generateMapEntry(mapEntry, to) {\nreturn Promise.all(\nmapEntry._pages.map(async (page) => {\n@@ -824,6 +835,16 @@ class Template extends TemplateContent {\ncontent: content,\n};\n+ if (\n+ this.config.dataFilterSelectors &&\n+ this.config.dataFilterSelectors.size > 0\n+ ) {\n+ obj.data = this.retrieveDataForJsonOutput(\n+ page.data,\n+ this.config.dataFilterSelectors\n+ );\n+ }\n+\nif (to === \"ndjson\") {\nlet jsonString = JSON.stringify(obj);\nthis.logger.toStream(jsonString + os.EOL);\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -77,6 +77,7 @@ class UserConfig {\nthis._pluginExecution = false;\nthis.useTemplateCache = true;\n+ this.dataFilterSelectors = new Set();\n}\nversionCheck(expected) {\n@@ -770,6 +771,7 @@ class UserConfig {\nplugins: this.plugins,\nuseTemplateCache: this.useTemplateCache,\nprecompiledCollections: this.precompiledCollections,\n+ dataFilterSelectors: this.dataFilterSelectors,\n};\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds getOutput method to serverless to return all of the raw entries that match the path (for advanced serverless usage). Adds `dataFilterSelectors` to configuration file to allow some data to pass through to the JSON object returned by Eleventy.prototype.toJSON. These are lodash selectors.
699
05.11.2021 12:31:30
18,000
17cb0cb356b4533000a5f3ff309d9e4b18d087b1
Change default serverless function to use new getOutput method.
[ { "change_type": "MODIFY", "old_path": "src/Plugins/DefaultServerlessFunctionContent.js", "new_path": "src/Plugins/DefaultServerlessFunctionContent.js", "diff": "@@ -12,12 +12,17 @@ async function handler(event) {\n});\ntry {\n+ let [page] = await elev.getOutput();\n+\n+ // If you want some of the data cascade available in `page.data`, use `eleventyConfig.dataFilterSelectors`.\n+ // Read more: https://www.11ty.dev/docs/config/#data-filter-selectors\n+\nreturn {\nstatusCode: 200,\nheaders: {\n\"Content-Type\": \"text/html; charset=UTF-8\",\n},\n- body: await elev.render(),\n+ body: page.content,\n};\n} catch (error) {\n// Only console log for matching serverless paths\n" } ]
JavaScript
MIT License
11ty/eleventy
Change default serverless function to use new getOutput method.
667
06.11.2021 03:23:10
-28,800
f8a2137a73214defde850228d8c4e9e759b953f0
feat: upgrade liquidjs to ^9.28.4, fixes
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.2.6\",\n+ \"liquidjs\": \"^9.28.4\",\n\"markdown-it-emoji\": \"^2.0.0\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.4.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n\"is-glob\": \"^4.0.3\",\n- \"liquidjs\": \"9.25.1\",\n\"lodash\": \"^4.17.21\",\n\"luxon\": \"^2.0.2\",\n\"markdown-it\": \"^12.2.0\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -2,9 +2,10 @@ const test = require(\"ava\");\nconst TemplateRender = require(\"../src/TemplateRender\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst EleventyExtensionMap = require(\"../src/EleventyExtensionMap\");\n+const { Drop } = require(\"liquidjs\");\n-function getNewTemplateRender(name, inputDir, userConfig = {}) {\n- let eleventyConfig = new TemplateConfig();\n+function getNewTemplateRender(name, inputDir, userConfig = {}, templateConfig) {\n+ let eleventyConfig = new TemplateConfig(templateConfig);\nfor (let key in userConfig) {\neleventyConfig.userConfig[key] = userConfig[key];\n}\n@@ -102,6 +103,11 @@ test(\"Liquid Render Relative (current dir) Include\", async (t) => {\nliquidOptions: {\ndynamicPartials: false,\n},\n+ },\n+ {\n+ dir: {\n+ includes: \"relative-liquid\",\n+ },\n}\n);\n@@ -117,6 +123,11 @@ test(\"Liquid Render Relative (parent dir) Include\", async (t) => {\nliquidOptions: {\ndynamicPartials: false,\n},\n+ },\n+ {\n+ dir: {\n+ includes: \"relative-liquid\",\n+ },\n}\n);\n@@ -124,10 +135,16 @@ test(\"Liquid Render Relative (parent dir) Include\", async (t) => {\nt.is(await fn(), \"<p>TIME IS RELATIVE.</p>\");\n});\n-test.skip(\"Liquid Render Relative (relative include should ignore _includes dir) Include\", async (t) => {\n+test(\"Liquid Render Relative (relative include should ignore _includes dir) Include\", async (t) => {\nlet tr = getNewTemplateRender(\n\"./test/stubs/does_not_exist_and_thats_ok.liquid\",\n- \"./test/stubs/\"\n+ \"./test/stubs/\",\n+ {},\n+ {\n+ dir: {\n+ includes: \".\",\n+ },\n+ }\n);\nlet fn = await tr.getCompiledTemplate(`<p>{% include './included' %}</p>`);\n@@ -575,7 +592,13 @@ test(\"Liquid Render Include Subfolder Single quotes no extension dynamicPartials\ntest(\"Liquid Render Include Subfolder Single quotes (relative include current dir) dynamicPartials true\", async (t) => {\nlet tr = getNewTemplateRender(\n\"./test/stubs/does_not_exist_and_thats_ok.liquid\",\n- \"./test/stubs/\"\n+ \"./test/stubs/\",\n+ {},\n+ {\n+ dir: {\n+ includes: \"relative-liquid\",\n+ },\n+ }\n);\nlet fn = await tr.getCompiledTemplate(\n`<p>{% include './relative-liquid/dir/included' %}</p>`\n@@ -586,7 +609,13 @@ test(\"Liquid Render Include Subfolder Single quotes (relative include current di\ntest(\"Liquid Render Include Subfolder Single quotes (relative include parent dir) dynamicPartials true\", async (t) => {\nlet tr = getNewTemplateRender(\n\"./test/stubs/subfolder/does_not_exist_and_thats_ok.liquid\",\n- \"./test/stubs/\"\n+ \"./test/stubs/\",\n+ {},\n+ {\n+ dir: {\n+ includes: \"relative-liquid\",\n+ },\n+ }\n);\nlet fn = await tr.getCompiledTemplate(\n`<p>{% include '../relative-liquid/dir/included' %}</p>`\n@@ -704,17 +733,32 @@ test(\"Liquid Shortcode Multiple Args\", async (t) => {\n);\n});\n-test.skip(\"Liquid Include Scope Leak\", async (t) => {\n+test(\"Liquid Include Scope Leak\", async (t) => {\n+ t.is(\n+ getNewTemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(),\n+ \"liquid\"\n+ );\n+\n+ // This is by design, `include` assigns value to its parent scope,\n+ // use `{% render %}` for separated, clean scope\n+ // see: https://github.com/harttle/liquidjs/issues/404#issuecomment-955660149\n+ let fn = await getNewTemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{% include 'scopeleak' %}{{ test }}</p>\");\n+ t.is(await fn({ test: 1 }), \"<p>22</p>\");\n+});\n+\n+test(\"Liquid Render Scope Leak\", async (t) => {\nt.is(\ngetNewTemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(),\n\"liquid\"\n);\n- // This might be by design?\nlet fn = await getNewTemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(\"<p>{% include scopeleak %}{{ test }}</p>\");\n+ ).getCompiledTemplate(\"<p>{% render 'scopeleak' %}{{ test }}</p>\");\nt.is(await fn({ test: 1 }), \"<p>21</p>\");\n});\n@@ -957,15 +1001,17 @@ test(\"Issue 600: Liquid Shortcode argument with underscores\", async (t) => {\n);\n});\n-test.skip(\"Issue 611: Run a function\", async (t) => {\n- // This works in Nunjucks\n+test(\"Issue 611: Run a function\", async (t) => {\n+ // function calls in Nunjucks can be replaced by custom Drops\nlet tr = getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n-\n- t.is(\n- await tr._testRender(\"{{ test() }}\", {\n- test: function () {\n+ class CustomDrop extends Drop {\n+ valueOf() {\nreturn \"alkdsjfksljaZach\";\n- },\n+ }\n+ }\n+ t.is(\n+ await tr._testRender(\"{{ test }}\", {\n+ test: new CustomDrop(),\n}),\n\"alkdsjfksljaZach\"\n);\n" } ]
JavaScript
MIT License
11ty/eleventy
feat: upgrade liquidjs to ^9.28.4, fixes #1995
667
06.11.2021 03:42:27
-28,800
9fce1684cb68dc236c4e6683787d558b90544991
fix: upgrade liquidjs to 9.28.5 to allow './' recognized as relative on Windows,
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.2.6\",\n- \"liquidjs\": \"^9.28.4\",\n+ \"liquidjs\": \"^9.28.5\",\n\"markdown-it-emoji\": \"^2.0.0\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.4.1\",\n" } ]
JavaScript
MIT License
11ty/eleventy
fix: upgrade liquidjs to 9.28.5 to allow './' recognized as relative on Windows, #1995
699
08.11.2021 14:13:30
21,600
35e694356b7250848b1e8bddf7d5b0d1314ca3f2
Move back to deps not devDeps
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.2.6\",\n- \"liquidjs\": \"^9.28.5\",\n\"markdown-it-emoji\": \"^2.0.0\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.4.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n\"is-glob\": \"^4.0.3\",\n+ \"liquidjs\": \"^9.28.5\",\n\"lodash\": \"^4.17.21\",\n\"luxon\": \"^2.0.2\",\n\"markdown-it\": \"^12.2.0\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Move back to deps not devDeps https://github.com/11ty/eleventy/pull/2071/files#r744329650
699
08.11.2021 16:05:35
21,600
bdeba62314eabd25390d87aa4a7ef7bcdbfc9c8e
Changes to fix without needing additional changes to template config.
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -2,8 +2,8 @@ const TemplateEngine = require(\"./TemplateEngine\");\nconst getJavaScriptData = require(\"../Util/GetJavaScriptData\");\nclass CustomEngine extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.entry = this.getExtensionMapEntry();\nthis.needsInit =\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Ejs.js", "new_path": "src/Engines/Ejs.js", "diff": "@@ -2,8 +2,8 @@ const ejsLib = require(\"ejs\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Ejs extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.ejsOptions = {};\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Haml.js", "new_path": "src/Engines/Haml.js", "diff": "@@ -2,8 +2,8 @@ const HamlLib = require(\"hamljs\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Haml extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.setLibrary(this.config.libraryOverrides.haml);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Handlebars.js", "new_path": "src/Engines/Handlebars.js", "diff": "@@ -2,8 +2,8 @@ const HandlebarsLib = require(\"handlebars\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Handlebars extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.setLibrary(this.config.libraryOverrides.hbs);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Html.js", "new_path": "src/Engines/Html.js", "diff": "const TemplateEngine = require(\"./TemplateEngine\");\nclass Html extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.cacheable = true;\n}\n@@ -10,7 +10,7 @@ class Html extends TemplateEngine {\nif (preTemplateEngine) {\nlet engine = this.engineManager.getEngine(\npreTemplateEngine,\n- super.getIncludesDir(),\n+ this.dirs,\nthis.extensionMap\n);\nlet fnReady = engine.compile(str, inputPath);\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -7,8 +7,8 @@ const getJavaScriptData = require(\"../Util/GetJavaScriptData\");\nclass JavaScriptTemplateNotDefined extends EleventyBaseError {}\nclass JavaScript extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.instances = {};\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -5,8 +5,8 @@ const TemplatePath = require(\"../TemplatePath\");\n// const debug = require(\"debug\")(\"Eleventy:Liquid\");\nclass Liquid extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.liquidOptions = this.config.liquidOptions || {};\n@@ -37,7 +37,7 @@ class Liquid extends TemplateEngine {\ngetLiquidOptions() {\nlet defaults = {\n- root: [super.getIncludesDir()], // overrides in compile with inputPath below\n+ root: [this.dirs.includes, this.dirs.input], // supplemented in compile with inputPath below\nextname: \".liquid\",\nstrictFilters: true,\n// TODO?\n@@ -229,10 +229,7 @@ class Liquid extends TemplateEngine {\nif (!inputPath || inputPath === \"njk\" || inputPath === \"md\") {\n// do nothing\n} else {\n- options.root = [\n- super.getIncludesDir(),\n- TemplatePath.getDirFromFilePath(inputPath),\n- ];\n+ options.root = [TemplatePath.getDirFromFilePath(inputPath)];\n}\nreturn async function (data) {\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Markdown.js", "new_path": "src/Engines/Markdown.js", "diff": "@@ -3,8 +3,8 @@ const TemplateEngine = require(\"./TemplateEngine\");\n// const debug = require(\"debug\")(\"Eleventy:Markdown\");\nclass Markdown extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.markdownOptions = {};\n@@ -53,7 +53,7 @@ class Markdown extends TemplateEngine {\nif (typeof preTemplateEngine === \"string\") {\nengine = this.engineManager.getEngine(\npreTemplateEngine,\n- super.getIncludesDir(),\n+ this.dirs,\nthis.extensionMap\n);\n} else {\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Mustache.js", "new_path": "src/Engines/Mustache.js", "diff": "@@ -2,8 +2,8 @@ const MustacheLib = require(\"mustache\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Mustache extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.setLibrary(this.config.libraryOverrides.mustache);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "@@ -123,8 +123,8 @@ const eventBus = require(\"../EventBus\");\nclass EleventyShortcodeError extends EleventyBaseError {}\nclass Nunjucks extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.nunjucksEnvironmentOptions =\nthis.config.nunjucksEnvironmentOptions || {};\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Pug.js", "new_path": "src/Engines/Pug.js", "diff": "@@ -2,8 +2,8 @@ const PugLib = require(\"pug\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Pug extends TemplateEngine {\n- constructor(name, includesDir, config) {\n- super(name, includesDir, config);\n+ constructor(name, dirs, config) {\n+ super(name, dirs, config);\nthis.pugOptions = this.config.pugOptions || {};\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -10,9 +10,17 @@ const aggregateBench = require(\"../BenchmarkManager\").get(\"Aggregate\");\nclass TemplateEngineConfigError extends EleventyBaseError {}\nclass TemplateEngine {\n- constructor(name, includesDir, config) {\n+ constructor(name, dirs, config) {\nthis.name = name;\n- this.includesDir = includesDir;\n+\n+ if (!dirs) {\n+ dirs = {};\n+ }\n+\n+ this.dirs = dirs;\n+ this.inputDir = dirs.input;\n+ this.includesDir = dirs.includes;\n+\nthis.partialsHaveBeenCached = false;\nthis.partials = [];\nthis.engineLib = null;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateEngineManager.js", "new_path": "src/TemplateEngineManager.js", "diff": "@@ -76,10 +76,10 @@ class TemplateEngineManager {\n}\n}\n- getEngine(name, includesDir, extensionMap) {\n+ getEngine(name, dirs, extensionMap) {\nif (!this.hasEngine(name)) {\nthrow new Error(\n- `Template Engine ${name} does not exist in getEngine (includes dir: ${includesDir})`\n+ `Template Engine ${name} does not exist in getEngine (dirs: ${dirs})`\n);\n}\n@@ -89,7 +89,7 @@ class TemplateEngineManager {\nlet cls = this.getEngineClassByExtension(name);\n- let instance = new cls(name, includesDir, this.config);\n+ let instance = new cls(name, dirs, this.config);\ninstance.extensionMap = extensionMap;\ninstance.engineManager = this;\n@@ -102,11 +102,7 @@ class TemplateEngineManager {\ninstance.constructor.name !== \"CustomEngine\"\n) {\nconst CustomEngine = this.getEngineClassByExtension();\n- const overrideCustomEngine = new CustomEngine(\n- name,\n- includesDir,\n- this.config\n- );\n+ const overrideCustomEngine = new CustomEngine(name, dirs, this.config);\n// Keep track of the \"default\" engine 11ty would normally use\n// This allows the user to access the default engine in their override\noverrideCustomEngine.setDefaultEngine(instance);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateRender.js", "new_path": "src/TemplateRender.js", "diff": "@@ -24,10 +24,12 @@ class TemplateRender {\nthis.config = config;\nthis.engineNameOrPath = tmplPath;\n- this.inputDir = inputDir;\n- // optional\n- this.includesDir = this._normalizeIncludesDir(inputDir);\n+ this.inputDir = inputDir ? inputDir : this.config.dir.input;\n+ this.includesDir = TemplatePath.join(\n+ this.inputDir,\n+ this.config.dir.includes\n+ );\nthis.parseMarkdownWith = this.config.markdownTemplateEngine;\nthis.parseHtmlWith = this.config.htmlTemplateEngine;\n@@ -67,7 +69,7 @@ class TemplateRender {\nthis._engine = this.extensionMap.engineManager.getEngine(\nthis._engineName,\n- this.includesDir,\n+ this.getDirs(),\nthis.extensionMap\n);\nthis._engine.config = this.config;\n@@ -190,15 +192,15 @@ class TemplateRender {\nreturn this.engineName;\n}\n- getIncludesDir() {\n- return this.includesDir;\n+ getDirs() {\n+ return {\n+ input: this.inputDir,\n+ includes: this.includesDir,\n+ };\n}\n- _normalizeIncludesDir(dir) {\n- return TemplatePath.join(\n- dir ? dir : this.config.dir.input,\n- this.config.dir.includes\n- );\n+ getIncludesDir() {\n+ return this.includesDir;\n}\nisEngine(engine) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -4,8 +4,8 @@ const TemplateConfig = require(\"../src/TemplateConfig\");\nconst EleventyExtensionMap = require(\"../src/EleventyExtensionMap\");\nconst { Drop } = require(\"liquidjs\");\n-function getNewTemplateRender(name, inputDir, userConfig = {}, templateConfig) {\n- let eleventyConfig = new TemplateConfig(templateConfig);\n+function getNewTemplateRender(name, inputDir, userConfig = {}) {\n+ let eleventyConfig = new TemplateConfig();\nfor (let key in userConfig) {\neleventyConfig.userConfig[key] = userConfig[key];\n}\n@@ -103,11 +103,6 @@ test(\"Liquid Render Relative (current dir) Include\", async (t) => {\nliquidOptions: {\ndynamicPartials: false,\n},\n- },\n- {\n- dir: {\n- includes: \"relative-liquid\",\n- },\n}\n);\n@@ -123,11 +118,6 @@ test(\"Liquid Render Relative (parent dir) Include\", async (t) => {\nliquidOptions: {\ndynamicPartials: false,\n},\n- },\n- {\n- dir: {\n- includes: \"relative-liquid\",\n- },\n}\n);\n@@ -139,12 +129,7 @@ test(\"Liquid Render Relative (relative include should ignore _includes dir) Incl\nlet tr = getNewTemplateRender(\n\"./test/stubs/does_not_exist_and_thats_ok.liquid\",\n\"./test/stubs/\",\n- {},\n- {\n- dir: {\n- includes: \".\",\n- },\n- }\n+ {}\n);\nlet fn = await tr.getCompiledTemplate(`<p>{% include './included' %}</p>`);\n@@ -590,12 +575,7 @@ test(\"Liquid Render Include Subfolder Single quotes (relative include current di\nlet tr = getNewTemplateRender(\n\"./test/stubs/does_not_exist_and_thats_ok.liquid\",\n\"./test/stubs/\",\n- {},\n- {\n- dir: {\n- includes: \"relative-liquid\",\n- },\n- }\n+ {}\n);\nlet fn = await tr.getCompiledTemplate(\n`<p>{% include './relative-liquid/dir/included' %}</p>`\n@@ -607,12 +587,7 @@ test(\"Liquid Render Include Subfolder Single quotes (relative include parent dir\nlet tr = getNewTemplateRender(\n\"./test/stubs/subfolder/does_not_exist_and_thats_ok.liquid\",\n\"./test/stubs/\",\n- {},\n- {\n- dir: {\n- includes: \"relative-liquid\",\n- },\n- }\n+ {}\n);\nlet fn = await tr.getCompiledTemplate(\n`<p>{% include '../relative-liquid/dir/included' %}</p>`\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderMarkdownTest.js", "new_path": "test/TemplateRenderMarkdownTest.js", "diff": "@@ -256,7 +256,8 @@ test(\"Markdown Render: use Markdown inside of a Liquid shortcode (Issue #536)\",\nlet tr = getNewTemplateRender(\"md\");\nlet eleventyConfig = new TemplateConfig();\nlet cls = require(\"../src/Engines/Liquid\");\n- let liquidEngine = new cls(\"liquid\", tr.getIncludesDir(), eleventyConfig);\n+\n+ let liquidEngine = new cls(\"liquid\", tr.getDirs(), eleventyConfig);\nliquidEngine.addShortcode(\"testShortcode\", function () {\nreturn \"## My Other Title\";\n});\n@@ -280,7 +281,7 @@ test(\"Markdown Render: use Markdown inside of a Nunjucks shortcode (Issue #536)\"\nlet tr = getNewTemplateRender(\"md\");\nlet eleventyConfig = new TemplateConfig();\nlet cls = require(\"../src/Engines/Nunjucks\");\n- let nunjucksEngine = new cls(\"njk\", tr.getIncludesDir(), eleventyConfig);\n+ let nunjucksEngine = new cls(\"njk\", tr.getDirs(), eleventyConfig);\nnunjucksEngine.addShortcode(\"testShortcode\", function () {\nreturn \"## My Other Title\";\n});\n@@ -329,7 +330,7 @@ test(\"Markdown Render: use Markdown inside of a Nunjucks paired shortcode (Issue\nlet eleventyConfig = new TemplateConfig();\nlet cls = require(\"../src/Engines/Nunjucks\");\n- let nunjucksEngine = new cls(\"njk\", tr.getIncludesDir(), eleventyConfig);\n+ let nunjucksEngine = new cls(\"njk\", tr.getDirs(), eleventyConfig);\nnunjucksEngine.addPairedShortcode(\"testShortcode\", function (content) {\nreturn content;\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
Changes to fix #2071 without needing additional changes to template config.
699
12.11.2021 21:55:57
21,600
2c1000afeb800a9814d87c01c6ccf4ee7c8455bf
Expose config and ignores via eventbus
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -316,6 +316,8 @@ class Eleventy {\n* @returns {} - tbd.\n*/\nasync init() {\n+ await this.config.events.emit(\"eleventy.config\", this.eleventyConfig);\n+\nif (this.env) {\nawait this.config.events.emit(\"eleventy.env\", this.env);\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Expose config and ignores via eventbus
699
12.11.2021 21:56:31
21,600
e0047392b3326e6449f3d99563cdf91c44ee5827
Performance boost: Cache get front matter data calls
[ { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -189,13 +189,18 @@ class TemplateContent {\n}\nasync getFrontMatterData() {\n+ if (this._frontMatterDataCache) {\n+ return this._frontMatterDataCache;\n+ }\n+\nif (!this.frontMatter) {\nawait this.read();\n}\n-\nlet extraData = await this.engine.getExtraDataFromFile(this.inputPath);\nlet data = TemplateData.mergeDeep({}, this.frontMatter.data, extraData);\n- return TemplateData.cleanupData(data);\n+ let cleanedData = TemplateData.cleanupData(data);\n+ this._frontMatterDataCache = cleanedData;\n+ return cleanedData;\n}\nasync getEngineOverride() {\n" } ]
JavaScript
MIT License
11ty/eleventy
Performance boost: Cache get front matter data calls
699
12.11.2021 21:57:49
21,600
87b7717b3bfab42535bf0b34c433d68c6eabb272
Option to retrieve data from multiple sources in custom template types (pass in an array to `getData`) Also now expose mixins (usually the config javascriptFunctions) to get data calls
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -58,7 +58,7 @@ class CustomEngine extends TemplateEngine {\nif (\"getData\" in this.entry) {\nif (typeof this.entry.getData === \"function\") {\n- return await this.entry.getData(inputPath);\n+ return this.entry.getData(inputPath);\n} else {\nif (!(\"getInstanceFromInputPath\" in this.entry)) {\nreturn Promise.reject(\n@@ -67,8 +67,46 @@ class CustomEngine extends TemplateEngine {\n)\n);\n}\n+\n+ let keys = new Set();\n+ if (this.entry.getData === true) {\n+ keys.add(\"data\");\n+ } else if (Array.isArray(this.entry.getData)) {\n+ for (let key of this.entry.getData) {\n+ keys.add(key);\n+ }\n+ }\n+ if (keys.size === 0) {\n+ return Promise.reject(\n+ new Error(\n+ `getData must be an array of keys or \\`true\\` in your addExtension configuration.`\n+ )\n+ );\n+ }\n+\nlet inst = await this.entry.getInstanceFromInputPath(inputPath);\n- return await getJavaScriptData(inst, inputPath);\n+ let mixins;\n+ if (this.config) {\n+ mixins = this.config.javascriptFunctions;\n+ }\n+\n+ // override keys set at the plugin level in the individual template\n+ if (inst.eleventyDataKey) {\n+ keys = new Set(inst.eleventyDataKey);\n+ }\n+\n+ let promises = [];\n+ for (let key of keys) {\n+ promises.push(getJavaScriptData(inst, inputPath, key, mixins));\n+ }\n+\n+ let results = await Promise.all(promises);\n+ let data = {};\n+ for (let result of results) {\n+ Object.assign(data, result);\n+ }\n+\n+ return data;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Util/GetJavaScriptData.js", "new_path": "src/Util/GetJavaScriptData.js", "diff": "@@ -2,12 +2,14 @@ const EleventyBaseError = require(\"../EleventyBaseError\");\nclass JavaScriptInvalidDataFormatError extends EleventyBaseError {}\n-module.exports = async function (inst, inputPath, key = \"data\") {\n+module.exports = async function (inst, inputPath, key = \"data\", mixins = {}) {\nif (inst && key in inst) {\n// get extra data from `data` method,\n// either as a function or getter or object literal\nlet result = await (typeof inst[key] === \"function\"\n- ? inst[key]()\n+ ? Object.keys(mixins).length > 0\n+ ? inst[key].call(mixins)\n+ : inst[key]()\n: inst[key]);\nif (typeof result !== \"object\") {\nthrow new JavaScriptInvalidDataFormatError(\n" } ]
JavaScript
MIT License
11ty/eleventy
Option to retrieve data from multiple sources in custom template types (pass in an array to `getData`) Also now expose mixins (usually the config javascriptFunctions) to get data calls
699
12.11.2021 21:58:33
21,600
7c82736e52823b2eddf062490e3f58c7cf72fa7a
Ability to reuse the default lexer in parseAguments
[ { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -5,6 +5,14 @@ const TemplatePath = require(\"../TemplatePath\");\n// const debug = require(\"debug\")(\"Eleventy:Liquid\");\nclass Liquid extends TemplateEngine {\n+ static argumentLexerOptions = {\n+ number: /[0-9]+\\.*[0-9]*/,\n+ doubleQuoteString: /\"(?:\\\\[\"\\\\]|[^\\n\"\\\\])*\"/,\n+ singleQuoteString: /'(?:\\\\['\\\\]|[^\\n'\\\\])*'/,\n+ keyword: /[a-zA-Z0-9.\\-_]+/,\n+ \"ignore:whitespace\": /[, \\t]+/, // includes comma separator\n+ };\n+\nconstructor(name, dirs, config) {\nsuper(name, dirs, config);\n@@ -12,13 +20,7 @@ class Liquid extends TemplateEngine {\nthis.setLibrary(this.config.libraryOverrides.liquid);\n- this.argLexer = moo.compile({\n- number: /[0-9]+\\.*[0-9]*/,\n- doubleQuoteString: /\"(?:\\\\[\"\\\\]|[^\\n\"\\\\])*\"/,\n- singleQuoteString: /'(?:\\\\['\\\\]|[^\\n'\\\\])*'/,\n- keyword: /[a-zA-Z0-9.\\-_]+/,\n- \"ignore:whitespace\": /[, \\t]+/, // includes comma separator\n- });\n+ this.argLexer = moo.compile(Liquid.argumentLexerOptions);\nthis.cacheable = true;\n}\n@@ -93,6 +95,10 @@ class Liquid extends TemplateEngine {\nstatic async parseArguments(lexer, str, scope, engine) {\nlet argArray = [];\n+ if (!lexer) {\n+ lexer = moo.compile(Liquid.argumentLexerOptions);\n+ }\n+\nif (typeof str === \"string\") {\n// TODO key=value key2=value\n// TODO JSON?\n" } ]
JavaScript
MIT License
11ty/eleventy
Ability to reuse the default lexer in parseAguments
699
13.11.2021 15:52:59
21,600
e8f794182fb0a5b5cf431e32cda860bd9acc87fb
Update Vue tests to Vue3 APIs
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "},\n\"devDependencies\": {\n\"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.3\",\n+ \"@vue/server-renderer\": \"^3.2.21\",\n\"ava\": \"^3.15.0\",\n\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n\"rimraf\": \"^3.0.2\",\n\"sass\": \"^1.43.4\",\n\"toml\": \"^3.0.0\",\n- \"vue\": \"^2.6.14\",\n- \"vue-server-renderer\": \"^2.6.14\"\n+ \"vue\": \"^3.2.1\"\n},\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^2.0.0\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderCustomTest.js", "new_path": "test/TemplateRenderCustomTest.js", "diff": "@@ -2,8 +2,9 @@ const test = require(\"ava\");\nconst TemplateRender = require(\"../src/TemplateRender\");\nconst EleventyExtensionMap = require(\"../src/EleventyExtensionMap\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\n-const Vue = require(\"vue\");\n-const renderer = require(\"vue-server-renderer\").createRenderer();\n+\n+const { createSSRApp } = require(\"vue\");\n+const { renderToString } = require(\"@vue/server-renderer\");\nfunction getNewTemplateRender(name, inputDir, eleventyConfig) {\nif (!eleventyConfig) {\n@@ -104,20 +105,22 @@ test(\"Custom Vue Render\", async (t) => {\ntr.eleventyConfig.userConfig.extensionMap.add({\nextension: \"vue\",\nkey: \"vue\",\n- compile: function (str, inputPath) {\n+ compile: function (str) {\nreturn async function (data) {\n- const app = new Vue({\n+ const app = createSSRApp({\ntemplate: str,\n- data: data,\n+ data: function () {\n+ return data;\n+ },\n});\n- return renderer.renderToString(app);\n+ return renderToString(app);\n};\n},\n});\nlet fn = await tr.getCompiledTemplate('<p v-html=\"test\">Paragraph</p>');\n- t.is(await fn({ test: \"Hello\" }), '<p data-server-rendered=\"true\">Hello</p>');\n+ t.is(await fn({ test: \"Hello\" }), \"<p>Hello</p>\");\n});\nconst sass = require(\"sass\");\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -142,11 +142,11 @@ test(\"JS Render using Vue\", async (t) => {\n).getCompiledTemplate();\nt.is(\nawait fn({ name: \"Zach\" }),\n- '<p data-server-rendered=\"true\">Hello Zach, this is a Vue template.</p>'\n+ \"<p>Hello Zach, this is a Vue template.</p>\"\n);\nt.is(\nawait fn({ name: \"Bill\" }),\n- '<p data-server-rendered=\"true\">Hello Bill, this is a Vue template.</p>'\n+ \"<p>Hello Bill, this is a Vue template.</p>\"\n);\n});\n@@ -158,7 +158,7 @@ test(\"JS Render using Vue (with a layout)\", async (t) => {\nawait fn({ name: \"Zach\" }),\n`<!doctype html>\n<title>Test</title>\n-<p data-server-rendered=\"true\">Hello Zach, this is a Vue template.</p>`\n+<p>Hello Zach, this is a Vue template.</p>`\n);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/vue-layout.11ty.js", "new_path": "test/stubs/vue-layout.11ty.js", "diff": "-const Vue = require(\"vue\");\n-const renderer = require(\"vue-server-renderer\").createRenderer({\n- template: `<!doctype html>\n-<title>{{ title }}</title>\n-<!--vue-ssr-outlet-->`\n-});\n+const { createSSRApp } = require(\"vue\");\n+const { renderToString } = require(\"@vue/server-renderer\");\nmodule.exports = async function (data) {\n- var app = new Vue({\n+ var app = createSSRApp({\ntemplate: \"<p>Hello {{ data.name }}, this is a Vue template.</p>\",\ndata: function () {\nreturn { data };\n- }\n+ },\n// components: {\n// 'test': ComponentA\n// }\n});\n- return renderer.renderToString(app, { title: \"Test\" });\n+ let content = await renderToString(app, { title: \"Test\" });\n+ return `<!doctype html>\n+<title>Test</title>\n+${content}`;\n};\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/vue.11ty.js", "new_path": "test/stubs/vue.11ty.js", "diff": "-const Vue = require(\"vue\");\n-const renderer = require(\"vue-server-renderer\").createRenderer();\n+const { createSSRApp } = require(\"vue\");\n+const { renderToString } = require(\"@vue/server-renderer\");\nmodule.exports = async function (templateData) {\n- var app = new Vue({\n+ var app = createSSRApp({\ntemplate: \"<p>Hello {{ data.name }}, this is a Vue template.</p>\",\n- data: {\n- data: templateData\n- }\n+ data: function () {\n+ return {\n+ data: templateData,\n+ };\n+ },\n// components: {\n// 'test': ComponentA\n// }\n});\n- return renderer.renderToString(app);\n+ return renderToString(app);\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Update Vue tests to Vue3 APIs
699
14.11.2021 13:28:56
21,600
3ce5bc4301cdd5856ddae4c56d6646294c424858
Normalize the input path to the OS
[ { "change_type": "MODIFY", "old_path": "src/Plugins/RenderPlugin.js", "new_path": "src/Plugins/RenderPlugin.js", "diff": "@@ -4,6 +4,7 @@ const fsp = fs.promises;\n// TODO first-class Markdown container/component (will need to be synchronous for markdown-it)\n+const TemplatePath = require(\"../TemplatePath\");\nconst TemplateRender = require(\"../TemplateRender\");\nconst TemplateConfig = require(\"../TemplateConfig\");\nconst Liquid = require(\"../Engines/Liquid\");\n@@ -41,6 +42,8 @@ async function renderFile(inputPath, templateLang, dir = {}, templateConfig) {\n);\n}\n+ inputPath = TemplatePath.normalizeOperatingSystemFilePath(inputPath);\n+\nif (!fs.existsSync(inputPath)) {\nthrow new Error(\n\"Could not find render plugin file for renderFile, looking for: \" +\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -341,4 +341,16 @@ TemplatePath.removeExtension = function (path, extension = undefined) {\nreturn path;\n};\n+/**\n+ * Accepts a relative file path that is using a standard directory separator and\n+ * normalizes it using the local operating system separator.\n+ * e.g. `./my/dir/` stays `./my/dir/` on *nix and becomes `.\\\\my\\\\dir\\\\` on Windows\n+ *\n+ * @param {String} filePath\n+ * @returns {String} a file path with the correct local directory separator.\n+ */\n+TemplatePath.normalizeOperatingSystemFilePath = function (filePath, sep = \"/\") {\n+ return filePath.split(sep).join(path.sep);\n+};\n+\nmodule.exports = TemplatePath;\n" } ]
JavaScript
MIT License
11ty/eleventy
Normalize the input path to the OS
699
14.11.2021 15:04:21
21,600
ec3b3492475949c7c2dfc9da1ce10081647a63d1
Trying to fix a Windows issue.
[ { "change_type": "MODIFY", "old_path": ".github/workflows/ci.yml", "new_path": ".github/workflows/ci.yml", "diff": "@@ -17,6 +17,8 @@ jobs:\nwith:\nnode-version: ${{ matrix.node }}\n- run: npm install\n- - run: npm test\n+ - run: npm run testci\n+ env:\n+ DEBUG: EleventyVue*\nenv:\nYARN_GPG: no\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"default\": \"npm run test\",\n\"format\": \"prettier src/ --write\",\n\"test\": \"npx ava --verbose\",\n+ \"testci\": \"npx ava --verbose --serial\",\n\"lint-staged\": \"lint-staged\",\n\"coverage\": \"npx nyc ava && npx nyc report --reporter=json-summary && cp coverage/coverage-summary.json docs-src/_data/coverage.json && node cmd.js --config=docs-src/.eleventy.docs.js\",\n\"prepare\": \"husky install\"\n" } ]
JavaScript
MIT License
11ty/eleventy
Trying to fix a Windows issue.
699
14.11.2021 15:08:02
21,600
f8c4f743c3677560baa297a965f8fa55b0cef8d6
Restore previous CI setup
[ { "change_type": "MODIFY", "old_path": ".github/workflows/ci.yml", "new_path": ".github/workflows/ci.yml", "diff": "@@ -17,7 +17,7 @@ jobs:\nwith:\nnode-version: ${{ matrix.node }}\n- run: npm install\n- - run: npm run testci\n+ - run: npm test\nenv:\nDEBUG: EleventyVue*\nenv:\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"default\": \"npm run test\",\n\"format\": \"prettier src/ --write\",\n\"test\": \"npx ava --verbose\",\n- \"testci\": \"npx ava --verbose --serial\",\n\"lint-staged\": \"lint-staged\",\n\"coverage\": \"npx nyc ava && npx nyc report --reporter=json-summary && cp coverage/coverage-summary.json docs-src/_data/coverage.json && node cmd.js --config=docs-src/.eleventy.docs.js\",\n\"prepare\": \"husky install\"\n" } ]
JavaScript
MIT License
11ty/eleventy
Restore previous CI setup
699
14.11.2021 20:37:30
21,600
659ccb52bc0496e354dcf93c18fb68399deb8be3
Opting-back into the test
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "},\n\"devDependencies\": {\n\"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.3\",\n- \"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.6\",\n+ \"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.7\",\n\"@vue/server-renderer\": \"^3.2.21\",\n\"ava\": \"^3.15.0\",\n\"husky\": \"^7.0.4\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Opting-back into the test
699
14.11.2021 20:47:06
21,600
6efae4e242d975aca4836cea030b2c1edd89834d
The elusive Windows fix.
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "},\n\"devDependencies\": {\n\"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.3\",\n- \"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.7\",\n+ \"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.8\",\n\"@vue/server-renderer\": \"^3.2.21\",\n\"ava\": \"^3.15.0\",\n\"husky\": \"^7.0.4\",\n" } ]
JavaScript
MIT License
11ty/eleventy
The elusive Windows fix.
699
15.11.2021 09:10:06
21,600
823243966ca7ca4ec8434904e6b17bc75800aaef
Add more tests. Add renderFile shortcodes for nunjucks and JS.
[ { "change_type": "MODIFY", "old_path": "src/Plugins/RenderPlugin.js", "new_path": "src/Plugins/RenderPlugin.js", "diff": "@@ -61,7 +61,7 @@ async function renderFile(inputPath, templateLang, dir = {}, templateConfig) {\ntr.setEngineOverride(templateLang);\n}\n- if (tr.engine.entry && tr.engine.entry.read === false) {\n+ if (!tr.engine.needsToReadFileContents()) {\nreturn tr.getCompiledTemplate(null);\n}\n@@ -105,7 +105,11 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nlet end = this.tokens[this.tokens.length - 1].token.end;\nlet body = this.tokens[0].token.input.substring(start, end);\n- return shortcodeFn.call(normalizedContext, body, ...argArray);\n+ return renderStringShortcodeFn.call(\n+ normalizedContext,\n+ body,\n+ ...argArray\n+ );\n},\n};\n}\n@@ -176,7 +180,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nnormalizedContext.page = context.ctx.page;\n}\n- shortcodeFn\n+ renderStringShortcodeFn\n.call(normalizedContext, body(), ...argArray)\n.then(function (returnValue) {\nresolve(null, new NunjucksLib.runtime.SafeString(returnValue));\n@@ -208,7 +212,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\ntemplateConfig = cfg;\n});\n- async function shortcodeFn(content, templateLang, data = {}) {\n+ async function renderStringShortcodeFn(content, templateLang, data = {}) {\nlet fn = await render.call(\nthis,\ncontent,\n@@ -228,21 +232,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nreturn output;\n}\n- // Render strings\n- eleventyConfig.addJavaScriptFunction(opts.tagName, shortcodeFn);\n-\n- eleventyConfig.addLiquidTag(opts.tagName, function (liquidEngine) {\n- return liquidTemplateTag(liquidEngine, opts.tagName);\n- });\n-\n- eleventyConfig.addNunjucksTag(opts.tagName, function (nunjucksLib) {\n- return nunjucksTemplateTag(nunjucksLib, opts.tagName);\n- });\n-\n- // Render File\n- eleventyConfig.addLiquidShortcode(\n- opts.tagNameFile,\n- async function (inputPath, templateLang, data = {}) {\n+ async function renderFileShortcodeFn(inputPath, data = {}, templateLang) {\nlet fn = await renderFile.call(\nthis,\ninputPath,\n@@ -260,6 +250,24 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n// console.log( { output } );\nreturn output;\n}\n+\n+ // Render strings\n+ eleventyConfig.addJavaScriptFunction(opts.tagName, renderStringShortcodeFn);\n+\n+ eleventyConfig.addLiquidTag(opts.tagName, function (liquidEngine) {\n+ return liquidTemplateTag(liquidEngine, opts.tagName);\n+ });\n+\n+ eleventyConfig.addNunjucksTag(opts.tagName, function (nunjucksLib) {\n+ return nunjucksTemplateTag(nunjucksLib, opts.tagName);\n+ });\n+\n+ // Render File\n+ eleventyConfig.addJavaScriptFunction(opts.tagNameFile, renderFileShortcodeFn);\n+ eleventyConfig.addLiquidShortcode(opts.tagNameFile, renderFileShortcodeFn);\n+ eleventyConfig.addNunjucksAsyncShortcode(\n+ opts.tagNameFile,\n+ renderFileShortcodeFn\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs-render-plugin-vue/vue-sfc.liquid", "new_path": "test/stubs-render-plugin-vue/vue-sfc.liquid", "diff": "@@ -4,4 +4,4 @@ argData:\nhi: liquidHi\nbye: liquidBye\n---\n-{% renderFile \"./test/stubs-render-plugin-vue/_includes/include.vue\" \"vue\" argData %}\n\\ No newline at end of file\n+{% renderFile \"./test/stubs-render-plugin-vue/_includes/include.vue\" argData %}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/11tyjs-file.njk", "diff": "+---\n+hi: value\n+argData:\n+ hi: liquidHi\n+ bye: liquidBye\n+---\n+{% renderFile \"./test/stubs-render-plugin/_includes/include.11ty.js\", argData %}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/_includes/include.11ty.js", "diff": "+module.exports = \"TESTING\";\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/_includes/include.liquid", "diff": "+TESTING\n+{% renderTemplate \"liquid\" %}\n+TESTING IN LIQUID\n+{% assign liquidassign = 999 %}\n+* {{ liquidassign }}\n+{% endrenderTemplate %}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "test/stubs-render-plugin/njk-file-no-syntax.liquid", "new_path": null, "diff": "-{% renderFile \"./test/stubs-render-plugin/_includes/include.njk\" %}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs-render-plugin/njk-file.liquid", "new_path": "test/stubs-render-plugin/njk-file.liquid", "diff": "@@ -4,4 +4,4 @@ argData:\nhi: liquidHi\nbye: liquidBye\n---\n-{% renderFile \"./test/stubs-render-plugin/_includes/include.njk\" \"njk\" argData %}\n+{% renderFile \"./test/stubs-render-plugin/_includes/include.njk\" argData %}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/njk-file.njk", "diff": "+---\n+hi: value\n+argData:\n+ hi: liquidHi\n+ bye: liquidBye\n+---\n+{% renderFile \"./test/stubs-render-plugin/_includes/include.liquid\", argData %}\n" } ]
JavaScript
MIT License
11ty/eleventy
Add more tests. Add renderFile shortcodes for nunjucks and JS.
699
15.11.2021 09:16:37
21,600
b8414d19460fc025b7178dc2d4f5dfd04942077e
Better error messaging when trying to use 11ty.js string render
[ { "change_type": "MODIFY", "old_path": "src/Plugins/RenderPlugin.js", "new_path": "src/Plugins/RenderPlugin.js", "diff": "@@ -32,6 +32,12 @@ async function render(content, templateLang, dir = {}, templateConfig) {\nlet tr = new TemplateRender(templateLang, includesDir, templateConfig);\ntr.setEngineOverride(templateLang);\n+ if (tr.engine.name === \"11ty.js\") {\n+ throw new Error(\n+ \"11ty.js is not yet supported as a template engine for `renderTemplate`. Use `renderFile` instead!\"\n+ );\n+ }\n+\nreturn tr.getCompiledTemplate(content);\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/11tyjs.liquid", "diff": "+---\n+hi: value\n+argData:\n+ hi: liquidHi\n+ bye: liquidBye\n+---\n+{% renderTemplate \"11ty.js\" argData %}\n+module.exports = \"TESTING\";\n+{% endrenderTemplate %}\n" } ]
JavaScript
MIT License
11ty/eleventy
Better error messaging when trying to use 11ty.js string render
699
15.11.2021 09:50:13
21,600
1b2d64cc46c4ab2ae02251c427faf258136dea8d
Falsy template language passed to renderTemplate should be an alias for raw tag and just use plaintext
[ { "change_type": "MODIFY", "old_path": "src/Plugins/RenderPlugin.js", "new_path": "src/Plugins/RenderPlugin.js", "diff": "@@ -17,13 +17,12 @@ function getFullIncludesDirectory(dir = {}) {\nreturn fullIncludesDir;\n}\n-async function render(content, templateLang, dir = {}, templateConfig) {\n- if (!templateLang) {\n- throw new Error(\n- \"Missing template syntax argument passed to the `template` shortcode.\"\n- );\n- }\n-\n+async function render(\n+ content,\n+ templateLang = \"html\",\n+ dir = {},\n+ templateConfig\n+) {\nif (!templateConfig) {\ntemplateConfig = new TemplateConfig();\n}\n@@ -41,6 +40,7 @@ async function render(content, templateLang, dir = {}, templateConfig) {\nreturn tr.getCompiledTemplate(content);\n}\n+// No templateLang default, it should infer from the inputPath.\nasync function renderFile(inputPath, templateLang, dir = {}, templateConfig) {\nif (!inputPath) {\nthrow new Error(\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/false.liquid", "diff": "+{% renderTemplate %}\n+# Hello {{ hi }}\n+* Testing\n+{% endrenderTemplate %}\n" } ]
JavaScript
MIT License
11ty/eleventy
Falsy template language passed to renderTemplate should be an alias for raw tag and just use plaintext
699
15.11.2021 13:48:13
21,600
ff1153c682bd335be6227b7055df715852899202
Add a few more tests for the Render Plugin
[ { "change_type": "MODIFY", "old_path": "src/Plugins/RenderPlugin.js", "new_path": "src/Plugins/RenderPlugin.js", "diff": "@@ -44,7 +44,7 @@ async function render(\nasync function renderFile(inputPath, templateLang, dir = {}, templateConfig) {\nif (!inputPath) {\nthrow new Error(\n- \"Missing file path argument passed to the `templatefile` shortcode.\"\n+ \"Missing file path argument passed to the `renderFile` shortcode.\"\n);\n}\n@@ -52,7 +52,7 @@ async function renderFile(inputPath, templateLang, dir = {}, templateConfig) {\n!fs.existsSync(TemplatePath.normalizeOperatingSystemFilePath(inputPath))\n) {\nthrow new Error(\n- \"Could not find render plugin file for renderFile, looking for: \" +\n+ \"Could not find render plugin file for the `renderFile` shortcode, looking for: \" +\ninputPath\n);\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/11tyjs-file-override.njk", "diff": "+---\n+hi: value\n+argData:\n+ hi: liquidHi\n+ bye: liquidBye\n+---\n+{% renderFile \"./test/stubs-render-plugin/_includes/include-js.txt\", argData, \"11ty.js\" %}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/_includes/frontmatter.liquid", "diff": "+---\n+test: frontmatterString\n+---\n+{{ test }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/_includes/include-js.txt", "diff": "+module.exports = \"TESTING\";\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin/using-frontmatter.liquid", "diff": "+{% renderFile \"./test/stubs-render-plugin/_includes/frontmatter.liquid\" %}\n" } ]
JavaScript
MIT License
11ty/eleventy
Add a few more tests for the Render Plugin
699
15.11.2021 13:49:47
21,600
55539ad7ffebe7978b68b2054e75f5a14dec9e68
For non-data keys, (e.g. serverPrefetch in vue), we can make the object check optional.
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -97,7 +97,12 @@ class CustomEngine extends TemplateEngine {\nlet promises = [];\nfor (let key of keys) {\n- promises.push(getJavaScriptData(inst, inputPath, key, mixins));\n+ promises.push(\n+ getJavaScriptData(inst, inputPath, key, {\n+ mixins,\n+ isObjectRequired: key === \"data\",\n+ })\n+ );\n}\nlet results = await Promise.all(promises);\n" }, { "change_type": "MODIFY", "old_path": "src/Util/GetJavaScriptData.js", "new_path": "src/Util/GetJavaScriptData.js", "diff": "@@ -2,7 +2,15 @@ const EleventyBaseError = require(\"../EleventyBaseError\");\nclass JavaScriptInvalidDataFormatError extends EleventyBaseError {}\n-module.exports = async function (inst, inputPath, key = \"data\", mixins = {}) {\n+module.exports = async function (inst, inputPath, key = \"data\", options = {}) {\n+ let { mixins, isObjectRequired } = Object.assign(\n+ {\n+ mixins: {},\n+ isObjectRequired: true,\n+ },\n+ options\n+ );\n+\nif (inst && key in inst) {\n// get extra data from `data` method,\n// either as a function or getter or object literal\n@@ -11,7 +19,8 @@ module.exports = async function (inst, inputPath, key = \"data\", mixins = {}) {\n? inst[key].call(mixins)\n: inst[key]()\n: inst[key]);\n- if (typeof result !== \"object\") {\n+\n+ if (isObjectRequired && typeof result !== \"object\") {\nthrow new JavaScriptInvalidDataFormatError(\n`Invalid data format returned from ${inputPath}: typeof ${typeof result}`\n);\n" } ]
JavaScript
MIT License
11ty/eleventy
For non-data keys, (e.g. serverPrefetch in vue), we can make the object check optional.
699
18.11.2021 09:46:44
21,600
22fee95b15be43c45992ad0bd07730d14517fa14
Show plugin name if one exists (via function.name)
[ { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -326,8 +326,7 @@ class UserConfig {\n}\n_executePlugin(plugin, options) {\n- // TODO support function.name in plugin config functions\n- debug(\"Adding plugin (unknown name: check your config file).\");\n+ debug(`Adding ${plugin.name || \"anonymous\"} plugin`);\nlet pluginBench = aggregateBench.get(\"Configuration addPlugin\");\nif (typeof plugin === \"function\") {\npluginBench.before();\n" } ]
JavaScript
MIT License
11ty/eleventy
Show plugin name if one exists (via function.name) https://github.com/11ty/eleventy/issues/2075#issuecomment-962530456
699
19.11.2021 13:39:26
21,600
35d53bfeb19b3436b3b426f50047411794f9f2d2
Was very incorrectly passing includesDir instead of inputDir into TemplateRender. Found via
[ { "change_type": "MODIFY", "old_path": "src/Plugins/RenderPlugin.js", "new_path": "src/Plugins/RenderPlugin.js", "diff": "@@ -9,26 +9,30 @@ const TemplateRender = require(\"../TemplateRender\");\nconst TemplateConfig = require(\"../TemplateConfig\");\nconst Liquid = require(\"../Engines/Liquid\");\n-function getFullIncludesDirectory(dir = {}) {\n- let inputDir = dir.input || \".\";\n- let includesDir = dir.includes || \"_includes\";\n- let fullIncludesDir = path.join(inputDir, includesDir);\n-\n- return fullIncludesDir;\n+function normalizeDirectories(dir = {}) {\n+ return Object.assign(\n+ {\n+ input: \".\",\n+ },\n+ dir\n+ );\n}\nasync function render(\ncontent,\ntemplateLang = \"html\",\n- dir = {},\n+ normalizedDirs = {},\ntemplateConfig\n) {\nif (!templateConfig) {\ntemplateConfig = new TemplateConfig();\n}\n- let includesDir = getFullIncludesDirectory(dir);\n- let tr = new TemplateRender(templateLang, includesDir, templateConfig);\n+ let tr = new TemplateRender(\n+ templateLang,\n+ normalizedDirs.input,\n+ templateConfig\n+ );\ntr.setEngineOverride(templateLang);\n// TODO tie this to the class, not the extension\n@@ -42,7 +46,12 @@ async function render(\n}\n// No templateLang default, it should infer from the inputPath.\n-async function renderFile(inputPath, templateLang, dir = {}, templateConfig) {\n+async function renderFile(\n+ inputPath,\n+ templateLang,\n+ normalizedDirs = {},\n+ templateConfig\n+) {\nif (!inputPath) {\nthrow new Error(\n\"Missing file path argument passed to the `renderFile` shortcode.\"\n@@ -62,8 +71,7 @@ async function renderFile(inputPath, templateLang, dir = {}, templateConfig) {\ntemplateConfig = new TemplateConfig();\n}\n- let includesDir = getFullIncludesDirectory(dir);\n- let tr = new TemplateRender(inputPath, includesDir, templateConfig);\n+ let tr = new TemplateRender(inputPath, normalizedDirs.input, templateConfig);\nif (templateLang) {\ntr.setEngineOverride(templateLang);\n}\n@@ -225,19 +233,14 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nthis,\ncontent,\ntemplateLang,\n- eleventyConfig.dir,\n+ normalizeDirectories(eleventyConfig.dir),\ntemplateConfig\n);\n// save `page` for reuse\ndata.page = this.page;\n- let output = await fn(data);\n- // console.log( \"--->\", this.page.inputPath, \"using\", templateLang );\n- // console.log( { data } );\n- // console.log( { content } );\n- // console.log( { output } );\n- return output;\n+ return fn(data);\n}\nasync function renderFileShortcodeFn(inputPath, data = {}, templateLang) {\n@@ -245,18 +248,14 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nthis,\ninputPath,\ntemplateLang,\n- eleventyConfig.dir,\n+ normalizeDirectories(eleventyConfig.dir),\ntemplateConfig\n);\n// save `page` for re-use\ndata.page = this.page;\n- let output = await fn(data);\n- // console.log( \"--->\", this.page.inputPath, \"using\", inputPath, \"using\", templateLang );\n- // console.log( { data } );\n- // console.log( { output } );\n- return output;\n+ return fn(data);\n}\n// Render strings\n" } ]
JavaScript
MIT License
11ty/eleventy
Was very incorrectly passing includesDir instead of inputDir into TemplateRender. Found via #2100 https://github.com/11ty/eleventy/issues/2100#issuecomment-973623359
699
19.11.2021 22:12:48
21,600
9da0d581d1cad58e793825a63d7f638567bf04a4
Apply the fix from to RenderPlugin too.
[ { "change_type": "MODIFY", "old_path": "src/Plugins/RenderPlugin.js", "new_path": "src/Plugins/RenderPlugin.js", "diff": "@@ -196,19 +196,38 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nnormalizedContext.page = context.ctx.page;\n}\n- renderStringShortcodeFn\n- .call(normalizedContext, body(), ...argArray)\n+ body(function (e, bodyContent) {\n+ if (e) {\n+ resolve(\n+ new EleventyShortcodeError(\n+ `Error with Nunjucks paired shortcode \\`${shortcodeName}\\`${EleventyErrorUtil.convertErrorToString(\n+ e\n+ )}`\n+ )\n+ );\n+ }\n+\n+ Promise.resolve(\n+ renderStringShortcodeFn.call(\n+ normalizedContext,\n+ bodyContent,\n+ ...argArray\n+ )\n+ )\n.then(function (returnValue) {\nresolve(null, new NunjucksLib.runtime.SafeString(returnValue));\n})\n.catch(function (e) {\nresolve(\n- new Error(\n- `Error with Nunjucks paired shortcode \\`${tagName}\\`${e.message}`\n+ new EleventyShortcodeError(\n+ `Error with Nunjucks paired shortcode \\`${shortcodeName}\\`${EleventyErrorUtil.convertErrorToString(\n+ e\n+ )}`\n),\nnull\n);\n});\n+ });\n};\n})();\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Apply the fix from #1749 to RenderPlugin too.
658
20.11.2021 08:32:38
18,000
2488ab1bf94e69d3fab8b4e26a3cba929e73f819
fix: strip date from directory slugs per
[ { "change_type": "MODIFY", "old_path": "src/TemplateFileSlug.js", "new_path": "src/TemplateFileSlug.js", "diff": "@@ -23,7 +23,12 @@ class TemplateFileSlug {\n}\n_getRawSlug() {\n- let slug = this.filenameNoExt;\n+ const slug = this.filenameNoExt;\n+ return this._stripDateFromSlug(slug);\n+ }\n+\n+ /** Removes dates in the format of YYYY-MM-DD from a given slug string candidate. */\n+ _stripDateFromSlug(slug) {\nlet reg = slug.match(/\\d{4}-\\d{2}-\\d{2}-(.*)/);\nif (reg) {\nreturn reg[1];\n@@ -35,7 +40,11 @@ class TemplateFileSlug {\nlet rawSlug = this._getRawSlug();\nif (rawSlug === \"index\") {\n- return this.dirs.length ? this.dirs[this.dirs.length - 1] : \"\";\n+ if (!this.dirs.length) {\n+ return \"\";\n+ }\n+ const lastDir = this.dirs[this.dirs.length - 1];\n+ return this._stripDateFromSlug(lastDir);\n}\nreturn rawSlug;\n" } ]
JavaScript
MIT License
11ty/eleventy
fix: strip date from directory slugs per #1947
710
20.11.2021 23:17:26
-3,600
7a64e3f48e5a62cbdc17255fda3a8a1d0c09aa29
My Signed Commit
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"@iarna/toml\": \"^2.2.5\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n\"browser-sync\": \"^2.27.7\",\n- \"chalk\": \"^4.1.2\",\n\"chokidar\": \"^3.5.2\",\n\"debug\": \"^4.3.2\",\n\"dependency-graph\": \"^0.11.0\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n\"is-glob\": \"^4.0.3\",\n+ \"kleur\": \"^4.1.4 \",\n\"liquidjs\": \"^9.28.5\",\n\"lodash\": \"^4.17.21\",\n\"luxon\": \"^2.1.1\",\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "const fs = require(\"fs\");\n-const chalk = require(\"chalk\");\n+const chalk = require(\"kleur\");\nconst lodashUniq = require(\"lodash/uniq\");\nconst lodashMerge = require(\"lodash/merge\");\nconst TemplatePath = require(\"./TemplatePath\");\n@@ -238,7 +238,7 @@ class TemplateConfig {\nthrow new EleventyConfigError(\n`Error in your Eleventy config file '${path}'.` +\n(err.message && err.message.includes(\"Cannot find module\")\n- ? chalk.blueBright(\" You may need to run `npm install`.\")\n+ ? chalk.cyan(\" You may need to run `npm install`.\")\n: \"\"),\nerr\n);\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "-const chalk = require(\"chalk\");\n+const chalk = require(\"kleur\");\nconst semver = require(\"semver\");\nconst { DateTime } = require(\"luxon\");\nconst EventEmitter = require(\"./Util/AsyncEventEmitter\");\n" }, { "change_type": "MODIFY", "old_path": "src/Util/ConsoleLogger.js", "new_path": "src/Util/ConsoleLogger.js", "diff": "-const chalk = require(\"chalk\");\n+const chalk = require(\"kleur\");\nconst debug = require(\"debug\")(\"Eleventy:Logger\");\nconst Readable = require(\"stream\").Readable;\n" } ]
JavaScript
MIT License
11ty/eleventy
My Signed Commit Signed-off-by: dgrammatiko <d.grammatiko@gmail.com>
699
22.11.2021 10:35:10
21,600
d4a7d67b6b82ccf0e5a77c1a3530f09a9b5fef65
One more test from
[ { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -232,7 +232,7 @@ class Liquid extends TemplateEngine {\n// Required for relative includes\nlet options = {};\n- if (!inputPath || inputPath === \"njk\" || inputPath === \"md\") {\n+ if (!inputPath || inputPath === \"liquid\" || inputPath === \"md\") {\n// do nothing\n} else {\noptions.root = [TemplatePath.getDirFromFilePath(inputPath)];\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -79,7 +79,7 @@ test(\"Liquid Render Include\", async (t) => {\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test(\"Liquid Render Relative Include\", async (t) => {\n+test(\"Liquid Render Relative Include (dynamicPartials off)\", async (t) => {\nt.is(\ngetNewTemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(),\n\"liquid\"\n@@ -91,10 +91,24 @@ test(\"Liquid Render Relative Include\", async (t) => {\n},\n});\n+ // Important note: when inputPath is set to `liquid`, this *only* uses _includes relative paths in Liquid->compile\nlet fn = await tr.getCompiledTemplate(\"<p>{% include ./included %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n+test(\"Liquid Render Relative Include (dynamicPartials on)\", async (t) => {\n+ t.is(\n+ getNewTemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(),\n+ \"liquid\"\n+ );\n+\n+ let tr = await getNewTemplateRender(\"liquid\", \"./test/stubs/\");\n+\n+ // Important note: when inputPath is set to `liquid`, this *only* uses _includes relative paths in Liquid->compile\n+ let fn = await tr.getCompiledTemplate(\"<p>{% include './included' %}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\ntest(\"Liquid Render Relative (current dir) Include\", async (t) => {\nlet tr = await getNewTemplateRender(\n\"./test/stubs/relative-liquid/does_not_exist_and_thats_ok.liquid\",\n" } ]
JavaScript
MIT License
11ty/eleventy
One more test from #2090
699
06.12.2021 09:57:02
21,600
f6a1def0dca70a52bad80b9dfefc289bc8aa981d
Using a Vue renderFile inside of serverPrefetch caused a missing `page.url` error when it tried to add the component to the CSS.
[ { "change_type": "ADD", "old_path": null, "new_path": "test/Util/removeNewLines.js", "diff": "+function removeNewLines(str) {\n+ return str.replace(/[\\r\\n]*/g, \"\");\n+}\n+\n+module.exports = removeNewLines;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-render-plugin-vue-nested/_includes/include.vue", "diff": "+<template>\n+ <span v-html=\"hi\"></span>\n+</template>\n+<style>\n+body {\n+ color: rebeccapurple;\n+}\n+</style>\n+<script>\n+export default {\n+ created: function() {\n+ // console.log( this.page );\n+ },\n+ props: {},\n+ components: {}\n+}\n+</script>\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Using a Vue renderFile inside of serverPrefetch caused a missing `page.url` error when it tried to add the component to the CSS.
699
10.12.2021 14:02:42
21,600
8cd56801d3f4c86b60936eee493267f33f90c282
Report from about getData functions being able to mutate config javascriptFunctions (no thank you) Manifested in Vue plugin when `data` function `this.X` assignment polluted global Vue methods.
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -87,7 +87,8 @@ class CustomEngine extends TemplateEngine {\nlet inst = await this.entry.getInstanceFromInputPath(inputPath);\nlet mixins;\nif (this.config) {\n- mixins = this.config.javascriptFunctions;\n+ // Object.assign usage: see TemplateRenderCustomTest.js: `JavaScript functions should not be mutable but not *that* mutable`\n+ mixins = Object.assign({}, this.config.javascriptFunctions);\n}\n// override keys set at the plugin level in the individual template\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -91,7 +91,7 @@ class JavaScript extends TemplateEngine {\nasync getExtraDataFromFile(inputPath) {\nlet inst = this.getInstanceFromInputPath(inputPath);\n- return await getJavaScriptData(inst, inputPath);\n+ return getJavaScriptData(inst, inputPath);\n}\ngetJavaScriptFunctions(inst) {\n@@ -103,6 +103,7 @@ class JavaScript extends TemplateEngine {\nif (key === \"page\") {\n// do nothing\n} else {\n+ // note: bind creates a new function\nfns[key] = configFns[key].bind(inst);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderCustomTest.js", "new_path": "test/TemplateRenderCustomTest.js", "diff": "const test = require(\"ava\");\n+const TemplateData = require(\"../src/TemplateData\");\nconst TemplateRender = require(\"../src/TemplateRender\");\nconst EleventyExtensionMap = require(\"../src/EleventyExtensionMap\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\n+const getNewTemplate = require(\"./_getNewTemplateForTests\");\nconst { createSSRApp } = require(\"vue\");\nconst { renderToString } = require(\"@vue/server-renderer\");\n@@ -165,3 +167,51 @@ test(\"Custom Sass Render\", async (t) => {\n}`\n);\n});\n+\n+/*\n+serverPrefetch: function() {\n+ return this.getBlogAuthors().then(response => this.glossary = response)\n+ },\n+*/\n+test(\"JavaScript functions should not be mutable but not *that* mutable\", async (t) => {\n+ t.plan(3);\n+\n+ let eleventyConfig = new TemplateConfig();\n+\n+ let instance = {\n+ dataForCascade: function () {\n+ // was mutating this.config.javascriptFunctions!\n+ this.shouldnotmutatethething = 1;\n+ return {};\n+ },\n+ };\n+\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"js1\",\n+ key: \"js1\",\n+ getData: [\"dataForCascade\"],\n+ getInstanceFromInputPath: function (inputPath) {\n+ t.truthy(true);\n+ return instance;\n+ },\n+ compile: function (str, inputPath) {\n+ t.falsy(this.config.javascriptFunctions.shouldnotmutatethething);\n+\n+ // plaintext\n+ return (data) => {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs-custom-extension/test.js1\",\n+ \"./test/stubs-custom-extension/\",\n+ \"dist\",\n+ null,\n+ null,\n+ eleventyConfig\n+ );\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"<p>Paragraph</p>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-custom-extension/test.js1", "diff": "+<p>Paragraph</p>\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Report from @akardet about getData functions being able to mutate config javascriptFunctions (no thank you) Manifested in Vue plugin when `data` function `this.X` assignment polluted global Vue methods.
699
10.12.2021 17:01:23
21,600
3537bfe93edcd9e76037da8c44a4d271beb4b4d7
Clearn code for init
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -8,8 +8,6 @@ class CustomEngine extends TemplateEngine {\nthis.entry = this.getExtensionMapEntry();\nthis.needsInit =\n\"init\" in this.entry && typeof this.entry.init === \"function\";\n- this.initStarted = false;\n- this.initFinished = false;\nthis._defaultEngine = undefined;\n}\n@@ -43,13 +41,10 @@ class CustomEngine extends TemplateEngine {\n// before continuing on.\nasync _runningInit() {\nif (this.needsInit) {\n- if (this.initStarted) {\n- await this.initStarted;\n- } else if (!this.initFinished) {\n- this.initStarted = this.entry.init.bind({ config: this.config })();\n- await this.initStarted;\n- this.initFinished = true;\n+ if (!this._initing) {\n+ this._initing = this.entry.init.bind({ config: this.config })();\n}\n+ await this._initing;\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Clearn code for init
699
17.12.2021 20:31:51
21,600
05906505268c4c3bbba73dced229db8010b67114
Better aggregate benchmark output. renderPermalink should never have markdown. Faster/simpler template agnostic permalink as a function
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "const TemplateEngine = require(\"./TemplateEngine\");\nconst getJavaScriptData = require(\"../Util/GetJavaScriptData\");\n+const bench = require(\"../BenchmarkManager\").get(\"Aggregate\");\nclass CustomEngine extends TemplateEngine {\nconstructor(name, dirs, config) {\n@@ -41,10 +42,17 @@ class CustomEngine extends TemplateEngine {\n// before continuing on.\nasync _runningInit() {\nif (this.needsInit) {\n+ let initBench = bench.get(`Engine (${this.name}) Init`);\n+ initBench.before();\nif (!this._initing) {\n- this._initing = this.entry.init.bind({ config: this.config })();\n+ this._initing = this.entry.init.bind({\n+ config: this.config,\n+ bench,\n+ })();\n}\nawait this._initing;\n+ this.needsInit = false;\n+ initBench.after();\n}\n}\n@@ -52,10 +60,16 @@ class CustomEngine extends TemplateEngine {\nawait this._runningInit();\nif (\"getData\" in this.entry) {\n+ let dataBench = bench.get(`Engine (${this.name}) Get Data From File`);\n+ dataBench.before();\n+\nif (typeof this.entry.getData === \"function\") {\n- return this.entry.getData(inputPath);\n+ let data = this.entry.getData(inputPath);\n+ dataBench.after();\n+ return data;\n} else {\nif (!(\"getInstanceFromInputPath\" in this.entry)) {\n+ dataBench.after();\nreturn Promise.reject(\nnew Error(\n`getInstanceFromInputPath callback missing from ${this.name} template engine plugin.`\n@@ -71,7 +85,9 @@ class CustomEngine extends TemplateEngine {\nkeys.add(key);\n}\n}\n+\nif (keys.size === 0) {\n+ dataBench.after();\nreturn Promise.reject(\nnew Error(\n`getData must be an array of keys or \\`true\\` in your addExtension configuration.`\n@@ -106,6 +122,7 @@ class CustomEngine extends TemplateEngine {\nfor (let result of results) {\nObject.assign(data, result);\n}\n+ dataBench.after();\nreturn data;\n}\n@@ -123,7 +140,7 @@ class CustomEngine extends TemplateEngine {\ninputPath,\n...args\n);\n- return await render(data);\n+ return render(data);\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -266,8 +266,13 @@ class TemplateContent {\n}\nlet templateBenchmark = bench.get(\"Template Compile\");\n+ let inputPathBenchmark = bench.get(\n+ `> Template Compile > ${this.inputPath}`\n+ );\ntemplateBenchmark.before();\n+ inputPathBenchmark.before();\nlet fn = await this.templateRender.getCompiledTemplate(str);\n+ inputPathBenchmark.after();\ntemplateBenchmark.after();\ndebugDev(\"%o getCompiledTemplate function created\", this.inputPath);\nif (this.config.useTemplateCache && res) {\n@@ -295,12 +300,33 @@ class TemplateContent {\n}\n}\n+ // used by computed data or for permalink functions\n+ async _renderFunction(fn, data) {\n+ let mixins = Object.assign({}, this.config.javascriptFunctions);\n+ let result = await fn.call(mixins, data);\n+\n+ // normalize Buffer away if returned from permalink\n+ if (Buffer.isBuffer(result)) {\n+ return result.toString();\n+ }\n+\n+ return result;\n+ }\n+\nasync renderComputedData(str, data) {\n+ if (typeof str === \"function\") {\n+ return this._renderFunction(str, data);\n+ }\n+\nreturn this._render(str, data, true);\n}\n- async renderPermalink(permalink, data, bypassMarkdown) {\n- return this._render(permalink, data, bypassMarkdown);\n+ async renderPermalink(permalink, data) {\n+ if (typeof permalink === \"function\") {\n+ return this._renderFunction(permalink, data);\n+ }\n+\n+ return this._render(permalink, data, true);\n}\nasync render(str, data, bypassMarkdown) {\n@@ -310,9 +336,32 @@ class TemplateContent {\nasync _render(str, data, bypassMarkdown) {\ntry {\nlet fn = await this.compile(str, bypassMarkdown);\n- let templateBenchmark = bench.get(\"Template Render\");\n+ let templateBenchmark = bench.get(\"Render\");\n+ let inputPathBenchmark = bench.get(\n+ `> Render > ${this.inputPath}${\n+ \"pagination\" in data ? \" (Paginated Aggregate)\" : \"\"\n+ }`\n+ );\n+ let outputUrlBenchmark;\n+ if (\"pagination\" in data) {\n+ outputUrlBenchmark = bench.get(\n+ `> Render > ${this.inputPath} (Pagination) to ${data.page.url}`\n+ );\n+ }\ntemplateBenchmark.before();\n+ if (inputPathBenchmark) {\n+ inputPathBenchmark.before();\n+ }\n+ if (outputUrlBenchmark) {\n+ outputUrlBenchmark.before();\n+ }\nlet rendered = await fn(data);\n+ if (outputUrlBenchmark) {\n+ outputUrlBenchmark.after();\n+ }\n+ if (inputPathBenchmark) {\n+ inputPathBenchmark.after();\n+ }\ntemplateBenchmark.after();\ndebugDev(\n\"%o getCompiledTemplate called, rendered content created\",\n@@ -347,7 +396,6 @@ class TemplateContent {\nreturn true;\n}\n- let incrementalFileIsFullTemplate = metadata.incrementalFileIsFullTemplate;\nlet extensionEntries = this.getExtensionEntries().filter(\n(entry) => !!entry.isIncrementalMatch\n);\n@@ -364,10 +412,14 @@ class TemplateContent {\nreturn true;\n}\n}\n+\n+ return false;\n} else {\n+ // This is the fallback way of determining if something is incremental (no isIncrementalMatch available)\n+\n// Not great way of building all templates if this is a layout, include, JS dependency.\n// TODO improve this for default langs\n- if (!incrementalFileIsFullTemplate) {\n+ if (!metadata.isFullTemplate) {\nreturn true;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -204,7 +204,7 @@ class TemplateWriter {\n// Passthrough copy check is above this (order is important)\n} else if (\ntmpl.isFileRelevantToThisTemplate(this.incrementalFile, {\n- incrementalFileIsFullTemplate: this.eleventyFiles.isFullTemplateFile(\n+ isFullTemplate: this.eleventyFiles.isFullTemplateFile(\nallPaths,\nthis.incrementalFile\n),\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -2048,6 +2048,22 @@ test(\"Add Extension via Configuration (txt file)\", async (t) => {\nt.truthy(tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default.txt\"));\nt.falsy(tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default2.txt\"));\nt.falsy(tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default.njk\"));\n+\n+ t.truthy(\n+ tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default.txt\", {\n+ isFullTemplate: true,\n+ })\n+ );\n+ t.falsy(\n+ tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default2.txt\", {\n+ isFullTemplate: true,\n+ })\n+ );\n+ t.falsy(\n+ tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default.njk\", {\n+ isFullTemplate: true,\n+ })\n+ );\n});\ntest(\"permalink object with build\", async (t) => {\n" } ]
JavaScript
MIT License
11ty/eleventy
Better aggregate benchmark output. renderPermalink should never have markdown. Faster/simpler template agnostic permalink as a function
699
17.12.2021 21:27:17
21,600
3feff6dedca97a188c2b4ce383895ea23107ca5f
Improvements to per-template benchmarks
[ { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -337,28 +337,30 @@ class TemplateContent {\ntry {\nlet fn = await this.compile(str, bypassMarkdown);\nlet templateBenchmark = bench.get(\"Render\");\n- let inputPathBenchmark = bench.get(\n- `> Render > ${this.inputPath}${\n- \"pagination\" in data ? \" (Paginated Aggregate)\" : \"\"\n- }`\n- );\n- let outputUrlBenchmark;\n+ let paginationSuffix = [];\nif (\"pagination\" in data) {\n- outputUrlBenchmark = bench.get(\n- `> Render > ${this.inputPath} (Pagination) to ${data.page.url}`\n+ paginationSuffix.push(\" (Pagination\");\n+ if (data.pagination.pages) {\n+ paginationSuffix.push(\n+ `: ${data.pagination.pages.length} page${\n+ data.pagination.pages.length !== 1 ? \"s\" : \"\"\n+ }`\n);\n}\n+ paginationSuffix.push(\")\");\n+ }\n+\n+ let inputPathBenchmark = bench.get(\n+ `> Render > ${this.inputPath}${paginationSuffix.join(\"\")}`\n+ );\n+\ntemplateBenchmark.before();\nif (inputPathBenchmark) {\ninputPathBenchmark.before();\n}\n- if (outputUrlBenchmark) {\n- outputUrlBenchmark.before();\n- }\n+\nlet rendered = await fn(data);\n- if (outputUrlBenchmark) {\n- outputUrlBenchmark.after();\n- }\n+\nif (inputPathBenchmark) {\ninputPathBenchmark.after();\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Improvements to per-template benchmarks
699
17.12.2021 21:29:22
21,600
ee08fe6181b23ddb1e1f1141b7a0e48231944522
Adds compileOptions support to addExtension API for better control of internal caching. compileOptions: { cache: true permalink: false, getCacheKey: function(str, inputPath) { return str; } }
[ { "change_type": "MODIFY", "old_path": "src/Engines/Custom.js", "new_path": "src/Engines/Custom.js", "diff": "@@ -11,6 +11,11 @@ class CustomEngine extends TemplateEngine {\n\"init\" in this.entry && typeof this.entry.init === \"function\";\nthis._defaultEngine = undefined;\n+\n+ // Enable cacheability for this template\n+ if (this.entry.compileOptions && \"cache\" in this.entry.compileOptions) {\n+ this.cacheable = this.entry.compileOptions.cache;\n+ }\n}\ngetExtensionMapEntry() {\n@@ -161,6 +166,30 @@ class CustomEngine extends TemplateEngine {\nget defaultTemplateFileExtension() {\nreturn this.entry.outputFileExtension;\n}\n+\n+ getCompileCacheKey(str, inputPath) {\n+ if (\n+ this.entry.compileOptions &&\n+ \"getCacheKey\" in this.entry.compileOptions\n+ ) {\n+ if (typeof this.entry.compileOptions.getCacheKey !== \"function\") {\n+ throw new Error(\n+ `\\`compileOptions.getCacheKey\\` must be a function in addExtension for the ${this.name} type`\n+ );\n+ }\n+\n+ return this.entry.compileOptions.getCacheKey(str, inputPath);\n+ }\n+ return super.getCompileCacheKey(str, inputPath);\n+ }\n+\n+ permalinkNeedsCompilation(str) {\n+ if (this.entry.compileOptions && \"permalink\" in this.entry.compileOptions) {\n+ return this.entry.compileOptions.permalink;\n+ }\n+\n+ return true;\n+ }\n}\nmodule.exports = CustomEngine;\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -10,6 +10,8 @@ class JavaScript extends TemplateEngine {\nconstructor(name, dirs, config) {\nsuper(name, dirs, config);\nthis.instances = {};\n+\n+ this.cacheable = false;\n}\nnormalize(result) {\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -211,6 +211,10 @@ class Liquid extends TemplateEngine {\nreturn symbols;\n}\n+ permalinkNeedsCompilation(str) {\n+ return this.needsCompilation(str);\n+ }\n+\nneedsCompilation(str) {\nlet options = this.liquidLib.options;\n@@ -221,12 +225,6 @@ class Liquid extends TemplateEngine {\n}\nasync compile(str, inputPath) {\n- if (!this.needsCompilation(str)) {\n- return async function (data) {\n- return str;\n- };\n- }\n-\nlet engine = this.liquidLib;\nlet tmplReady = engine.parse(str, inputPath);\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "@@ -338,6 +338,10 @@ class Nunjucks extends TemplateEngine {\nthis.njkEnv.addExtension(shortcodeName, new fn());\n}\n+ permalinkNeedsCompilation(str) {\n+ return this.needsCompilation(str);\n+ }\n+\nneedsCompilation(str) {\n// Defend against syntax customisations:\n// https://mozilla.github.io/nunjucks/api.html#customizing-syntax\n@@ -409,12 +413,6 @@ class Nunjucks extends TemplateEngine {\n}\nasync compile(str, inputPath) {\n- if (!this.needsCompilation(str)) {\n- return async function () {\n- return str;\n- };\n- }\n-\n// for(let loader of this.njkEnv.loaders) {\n// loader.cache = {};\n// }\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -173,10 +173,18 @@ class TemplateEngine {\n// do nothing\n}\n+ getCompileCacheKey(str, inputPath) {\n+ return str;\n+ }\n+\nget defaultTemplateFileExtension() {\nreturn \"html\";\n}\n+ permalinkNeedsCompilation(str) {\n+ return this.needsCompilation(str);\n+ }\n+\n// whether or not compile is needed or can we return the plaintext?\nneedsCompilation(str) {\nreturn true;\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -886,6 +886,10 @@ class Template extends TemplateContent {\nthis.extensionMap,\nthis.eleventyConfig\n);\n+\n+ // Avoid re-reads, especially for pagination\n+ tmpl.setInputContent(this.inputContent);\n+\ntmpl.logger = this.logger;\nfor (let transform of this.transforms) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -97,7 +97,11 @@ class TemplateContent {\n}\nasync read() {\n+ if (this.inputContent) {\n+ await this.inputContent;\n+ } else {\nthis.inputContent = await this.getInputContent();\n+ }\nif (this.inputContent) {\nlet options = this.config.frontMatterParsingOptions || {};\n@@ -149,11 +153,15 @@ class TemplateContent {\nthis._inputCache.delete(TemplatePath.absolutePath(path));\n}\n+ // Used via clone\n+ setInputContent(content) {\n+ this.inputContent = content;\n+ }\n+\nasync getInputContent() {\nif (!this.engine.needsToReadFileContents()) {\nreturn \"\";\n}\n-\nlet templateBenchmark = bench.get(\"Template Read\");\ntemplateBenchmark.before();\nlet content;\n@@ -232,12 +240,20 @@ class TemplateContent {\n}\nlet cacheable = this.engine.cacheable;\n- return [cacheable, str, engineMap];\n+ let key = this.engine.getCompileCacheKey(str, this.inputPath);\n+\n+ return [cacheable, key, engineMap];\n}\nasync compile(str, bypassMarkdown) {\nawait this.setupTemplateRender(bypassMarkdown);\n+ if (bypassMarkdown && !this.engine.needsCompilation(str)) {\n+ return async function () {\n+ return str;\n+ };\n+ }\n+\ndebugDev(\n\"%o compile() using engine: %o\",\nthis.inputPath,\n@@ -322,6 +338,12 @@ class TemplateContent {\n}\nasync renderPermalink(permalink, data) {\n+ if (\n+ typeof permalink === \"string\" &&\n+ !this.engine.permalinkNeedsCompilation(permalink)\n+ ) {\n+ return permalink;\n+ }\nif (typeof permalink === \"function\") {\nreturn this._renderFunction(permalink, data);\n}\n@@ -335,6 +357,10 @@ class TemplateContent {\nasync _render(str, data, bypassMarkdown) {\ntry {\n+ if (bypassMarkdown && !this.engine.needsCompilation(str)) {\n+ return str;\n+ }\n+\nlet fn = await this.compile(str, bypassMarkdown);\nlet templateBenchmark = bench.get(\"Render\");\nlet paginationSuffix = [];\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -452,8 +452,10 @@ class TemplateMap {\nthrow new Error(`Content pages not found for ${map.inputPath}`);\n}\nif (!map.template.behavior.isRenderable()) {\n+ // Note that empty pagination templates will be skipped here as not renderable\ncontinue;\n}\n+\ntry {\nfor (let pageEntry of map._pages) {\npageEntry.templateContent = await map.template.getTemplateMapContent(\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds compileOptions support to addExtension API for better control of internal caching. compileOptions: { cache: true permalink: false, getCacheKey: function(str, inputPath) { return str; } }
699
18.12.2021 14:48:22
21,600
e88bbe38cdfc751d2677679b22f8a74856cb449f
Fixes Also noticed there were a bunch of "utf-8" fs options that needed to be "utf8"
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^3.1.6\",\n\"fast-glob\": \"^3.2.7\",\n+ \"graceful-fs\": \"^4.2.8\",\n\"gray-matter\": \"^4.0.3\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyFiles.js", "new_path": "src/EleventyFiles.js", "diff": "@@ -223,7 +223,7 @@ class EleventyFiles {\nlet dir = TemplatePath.getDirFromFilePath(ignorePath);\nif (fs.existsSync(ignorePath) && fs.statSync(ignorePath).size > 0) {\n- let ignoreContent = fs.readFileSync(ignorePath, \"utf-8\");\n+ let ignoreContent = fs.readFileSync(ignorePath, \"utf8\");\nignores = ignores.concat(\nEleventyFiles.normalizeIgnoreContent(dir, ignoreContent)\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyServe.js", "new_path": "src/EleventyServe.js", "diff": "@@ -101,7 +101,7 @@ class EleventyServe {\nreturn;\n}\n- let savedPathContent = fs.readFileSync(savedPathFilename, \"utf-8\");\n+ let savedPathContent = fs.readFileSync(savedPathFilename, \"utf8\");\nif (\nsavedPathContent.indexOf(\"Browsersync pathPrefix Redirect\") === -1\n) {\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -131,7 +131,7 @@ class TemplateEngine {\n\".\" + extension\n);\n});\n- partials[partialPathNoExt] = fs.readFileSync(partialFiles[j], \"utf-8\");\n+ partials[partialPathNoExt] = fs.readFileSync(partialFiles[j], \"utf8\");\n}\ndebug(\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/ServerlessBundlerPlugin.js", "new_path": "src/Plugins/ServerlessBundlerPlugin.js", "diff": "@@ -272,7 +272,7 @@ class BundlerHelper {\n\"./DefaultServerlessFunctionContent.js\"\n);\n- let contents = await fsp.readFile(defaultContentPath, \"utf-8\");\n+ let contents = await fsp.readFile(defaultContentPath, \"utf8\");\ncontents = contents.replace(/\\%\\%NAME\\%\\%/g, this.name);\ncontents = contents.replace(\n/\\%\\%FUNCTIONS_DIR\\%\\%/g,\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "-const fs = require(\"fs\");\n+const fs = require(\"graceful-fs\");\n+const util = require(\"util\");\n+const writeFile = util.promisify(fs.writeFile);\n+const mkdir = util.promisify(fs.mkdir);\n+\nconst os = require(\"os\");\nconst path = require(\"path\");\nconst normalize = require(\"normalize-path\");\n@@ -774,10 +778,10 @@ class Template extends TemplateContent {\n// TODO add a cache to check if this was already created\nlet templateOutputDir = path.parse(outputPath).dir;\nif (templateOutputDir) {\n- await fs.promises.mkdir(templateOutputDir, { recursive: true });\n+ await mkdir(templateOutputDir, { recursive: true });\n}\n- return fs.promises.writeFile(outputPath, finalContent).then(() => {\n+ return writeFile(outputPath, finalContent).then(() => {\ntemplateBenchmark.after();\nthis.writeCount++;\ndebug(`${outputPath} ${lang.finished}.`);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "const os = require(\"os\");\n-const fs = require(\"fs\");\n+const fs = require(\"graceful-fs\");\n+const util = require(\"util\");\n+const readFile = util.promisify(fs.readFile);\nconst normalize = require(\"normalize-path\");\nconst matter = require(\"gray-matter\");\nconst lodashSet = require(\"lodash/set\");\n@@ -169,7 +171,7 @@ class TemplateContent {\ncontent = TemplateContent.getCached(this.inputPath);\n}\nif (!content) {\n- content = await fs.promises.readFile(this.inputPath, \"utf-8\");\n+ content = await readFile(this.inputPath, \"utf8\");\nif (this.config.useTemplateCache) {\nTemplateContent.cache(this.inputPath, content);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -405,7 +405,7 @@ class TemplateData {\nasync _loadFileContents(path) {\nlet rawInput;\ntry {\n- rawInput = await fs.promises.readFile(path, \"utf-8\");\n+ rawInput = await fs.promises.readFile(path, \"utf8\");\n} catch (e) {\n// if file does not exist, return nothing\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -447,7 +447,7 @@ test(\"Pagination and TemplateContent\", async (t) => {\nlet content = fs.readFileSync(\n\"./test/stubs/pagination-templatecontent/_site/index.html\",\n- \"utf-8\"\n+ \"utf8\"\n);\nt.is(\ncontent.trim(),\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes #2139. Also noticed there were a bunch of "utf-8" fs options that needed to be "utf8"
699
18.12.2021 19:44:31
21,600
b2e50a859a83e41b49c7db99c63f4823e72abb6b
Two skipped tests: one should throw an error, one is irrelevant
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1740,15 +1740,22 @@ test(\"Throws a Premature Template Content Error (haml)\", async (t) => {\nt.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n});\n-test.skip(\"Issue 413 weird date format\", async (t) => {\n+test(\"Issue 413 weird date format\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs-413/date-frontmatter.md\",\n\"./test/stubs-413/\",\n\"./dist\"\n);\n- let data = await tmpl.getData();\n- t.is(data.page.date, \"\");\n+ let error = await t.throwsAsync(async function () {\n+ await tmpl.getData();\n+ });\n+\n+ t.truthy(\n+ error.message.indexOf(\n+ \"date front matter value (2019-03-13 20:18:42 +0000) is invalid\"\n+ ) > -1\n+ );\n});\ntest(\"Custom Front Matter Parsing Options\", async (t) => {\n" }, { "change_type": "DELETE", "old_path": "test/stubs/function-filter-arrow.11ty.js", "new_path": null, "diff": "-module.exports = ({ name }) => {\n- return `<p>${this.upper(name)}</p>`;\n-};\n" } ]
JavaScript
MIT License
11ty/eleventy
Two skipped tests: one should throw an error, one is irrelevant
699
19.12.2021 00:03:45
21,600
d68dcbf603be8e0285605edafe2d64b3a80b8e6b
Removes `time-require` for reasons stated in
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -11,10 +11,6 @@ require(\"please-upgrade-node\")(pkg, {\n});\nconst debug = require(\"debug\")(\"Eleventy:cmd\");\n-if (process.env.DEBUG) {\n- require(\"time-require\");\n-}\n-\nconst EleventyErrorHandler = require(\"./src/EleventyErrorHandler\");\ntry {\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"pug\": \"^3.0.2\",\n\"recursive-copy\": \"^2.0.13\",\n\"semver\": \"^7.3.5\",\n- \"slugify\": \"^1.6.4\",\n- \"time-require\": \"^0.1.2\"\n+ \"slugify\": \"^1.6.4\"\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Removes `time-require` for reasons stated in #2129