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
19.12.2017 17:57:33
21,600
68a24a07d40ebf4072100288678e11bacbba084d
Adds minimum node version
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"name\": \"eleventy\",\n\"version\": \"0.1.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n- \"license\": \"MIT\",\n\"main\": \"cmd.js\",\n+ \"license\": \"MIT\",\n+ \"engines\": {\n+ \"node\": \">=8.0.0\"\n+ },\n+ \"bin\": {\n+ \"eleventy\": \"./cmd.js\"\n+ },\n\"scripts\": {\n\"default\": \"node cmd.js\",\n\"watch\": \"node cmd.js --watch\",\n\"email\": \"[email protected]\",\n\"url\": \"https://zachleat.com/\"\n},\n- \"bin\": {\n- \"eleventy\": \"./cmd.js\"\n- },\n\"repository\": {\n\"type\": \"git\",\n\"url\": \"git://github.com/zachleat/eleventy.git\"\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds minimum node version
699
19.12.2017 17:58:16
21,600
d30139b8551e09061886d581b126c82556f3033b
Another index index-output test
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -81,6 +81,15 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\nt.is(await tmpl.getOutputPath(), \"./test/stubs/index-output.html\");\n});\n+test(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index).\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/subfolder/index.html\",\n+ \"./test/stubs\",\n+ \"./test/stubs\"\n+ );\n+ t.is(await tmpl.getOutputPath(), \"./test/stubs/subfolder/index-output.html\");\n+});\n+\ntest(\"Test raw front matter from template\", t => {\nlet tmpl = new Template(\n\"./test/stubs/templateFrontMatter.ejs\",\n" }, { "change_type": "ADD", "old_path": "test/stubs/subfolder/index.html", "new_path": "test/stubs/subfolder/index.html", "diff": "" } ]
JavaScript
MIT License
11ty/eleventy
Another index index-output test
699
19.12.2017 17:58:37
21,600
6c77d1e3175136e72365360b89373f4f7c962a05
Fixes start/end times on command line when using pagination (ended too early)
[ { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -114,9 +114,9 @@ Pagination.prototype.getTemplates = async function() {\nPagination.prototype.write = async function() {\nlet pages = await this.getTemplates();\n- pages.forEach(async function(pageTmpl) {\n- await pageTmpl.write();\n- });\n+ for (var j = 0, k = pages.length; j < k; j++) {\n+ await pages[j].write();\n+ }\n};\nmodule.exports = Pagination;\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes start/end times on command line when using pagination (ended too early)
699
19.12.2017 20:40:40
21,600
d2ab1ebfd71339921b80d7219834534082eb6676
Eleventy top level object tests
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -7,23 +7,17 @@ let eleven = new Eleventy(argv.input, argv.output);\neleven.setFormats(argv.formats);\n(async function() {\n- let start = new Date();\n-\nawait eleven.init();\nif (argv.version) {\n- eleven.printVersion();\n+ console.log(eleven.getVersion());\n} else if (argv.help) {\n- eleven.printHelp();\n+ console.log(eleven.getHelp());\n} else if (argv.watch) {\neleven.watch();\n} else {\nawait eleven.write();\n- console.log(\n- \"Finished in\",\n- ((new Date() - start) / 1000).toFixed(2),\n- \"seconds\"\n- );\n+ console.log(eleven.getElapsedTime());\n}\n})();\n" }, { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -10,10 +10,20 @@ let cfg = templateCfg.getConfig();\nfunction Eleventy(input, output) {\nthis.input = input || cfg.dir.input;\nthis.output = output || cfg.dir.output;\n- this.formats = null;\n+ this.formats = cfg.templateFormats;\nthis.data = null;\n+ this.start = new Date();\n}\n+Eleventy.prototype.restart = function() {\n+ this.start = new Date();\n+};\n+\n+Eleventy.prototype.getElapsedTime = function() {\n+ let time = ((new Date() - this.start) / 1000).toFixed(2);\n+ return `Finished in ${time} second` + (time !== 1 ? \"s\" : \"\");\n+};\n+\nEleventy.prototype.init = async function() {\nthis.data = new TemplateData(this.input);\n@@ -28,18 +38,16 @@ Eleventy.prototype.init = async function() {\n};\nEleventy.prototype.setFormats = function(formats) {\n- this.formats = cfg.templateFormats;\n-\nif (formats && formats !== \"*\") {\nthis.formats = formats.split(\",\");\n}\n};\n-Eleventy.prototype.printVersion = function() {\n- console.log(pkg.version);\n+Eleventy.prototype.getVersion = function() {\n+ return pkg.version;\n};\n-Eleventy.prototype.printHelp = function() {\n+Eleventy.prototype.getHelp = function() {\nlet out = [];\nout.push(\"usage: eleventy\");\nout.push(\" eleventy --watch\");\n@@ -61,7 +69,7 @@ Eleventy.prototype.printHelp = function() {\n// out.push( \" Set your own local configuration file (default: `.eleventy.js`)\" );\nout.push(\" --help\");\nout.push(\" Show this message.\");\n- console.log(out.join(\"\\n\"));\n+ return out.join(\"\\n\");\n};\nEleventy.prototype.watch = function() {\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -114,8 +114,8 @@ Pagination.prototype.getTemplates = async function() {\nPagination.prototype.write = async function() {\nlet pages = await this.getTemplates();\n- for (var j = 0, k = pages.length; j < k; j++) {\n- await pages[j].write();\n+ for (let page of pages) {\n+ await page.write();\n}\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/EleventyTest.js", "diff": "+import test from \"ava\";\n+import Eleventy from \"../src/Eleventy\";\n+import TemplateConfig from \"../src/TemplateConfig\";\n+\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\n+\n+test(\"Eleventy, defaults inherit from config\", async t => {\n+ let elev = new Eleventy();\n+\n+ t.truthy(elev.input);\n+ t.truthy(elev.output);\n+ t.is(elev.input, cfg.dir.input);\n+ t.is(elev.output, cfg.dir.output);\n+});\n+\n+test(\"Eleventy, get version\", t => {\n+ let elev = new Eleventy();\n+\n+ t.truthy(elev.getVersion());\n+});\n+\n+test(\"Eleventy, get help\", t => {\n+ let elev = new Eleventy();\n+\n+ t.truthy(elev.getHelp());\n+});\n+\n+test(\"Eleventy set input/output\", async t => {\n+ let elev = new Eleventy(\"./test/stubs\", \"./test/stubs/_site\");\n+\n+ t.is(elev.input, \"./test/stubs\");\n+ t.is(elev.output, \"./test/stubs/_site\");\n+\n+ await elev.init();\n+ t.truthy(elev.data);\n+ t.truthy(elev.writer);\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Eleventy top level object tests
699
19.12.2017 21:25:09
21,600
0733746fed4ff90d7fddb89008f24abdb220f5ff
Permalink object
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -7,6 +7,7 @@ const normalize = require(\"normalize-path\");\nconst clone = require(\"lodash.clone\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\n+const TemplatePermalink = require(\"./TemplatePermalink\");\nconst Layout = require(\"./Layout\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n@@ -57,19 +58,17 @@ Template.prototype.setExtraOutputSubdirectory = function(dir) {\n};\nTemplate.prototype.getOutputLink = async function() {\n- // TODO move permalink logic into TemplateUri\nlet permalink = this.getFrontMatterData()[cfg.keys.permalink];\nif (permalink) {\nlet data = await this.getData();\n- let permalinkParsed = parsePath(await this.renderContent(permalink, data));\n- return TemplatePath.normalize(\n- permalinkParsed.dir +\n- \"/\" +\n- this.extraOutputSubdirectory +\n- permalinkParsed.base // name with extension\n+ let perm = new TemplatePermalink(\n+ await this.renderContent(permalink, data),\n+ this.extraOutputSubdirectory\n);\n+ return perm.toString();\n}\n+ // TODO move this into permalink (or new obj?)\nlet dir = this.getTemplateSubfolder();\nlet path =\n(dir ? dir + \"/\" : \"\") +\n@@ -78,7 +77,7 @@ Template.prototype.getOutputLink = async function() {\n\"index\" +\n(this.isHtmlIOException ? cfg.htmlOutputSuffix : \"\") +\n\".html\";\n- // console.log( this.inputPath,\"|\", this.inputDir, \"|\", dir );\n+\nreturn normalize(path);\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/TemplatePermalink.js", "diff": "+const parsePath = require(\"parse-filepath\");\n+const normalize = require(\"normalize-path\");\n+const TemplatePath = require(\"./TemplatePath\");\n+\n+function TemplatePermalink(link, extraSubdir) {\n+ this.link = this._cleanLink(link);\n+ this.extraSubdir = extraSubdir || \"\";\n+ this.parsed = parsePath(this.link);\n+}\n+\n+TemplatePermalink.prototype._cleanLink = function(link) {\n+ return link + (link.substr(-1) === \"/\" ? \"index.html\" : \"\");\n+};\n+\n+TemplatePermalink.prototype.resolve = function() {\n+ return TemplatePath.normalize(\n+ this.parsed.dir + \"/\" + this.extraSubdir + this.parsed.base // name with extension\n+ );\n+};\n+\n+TemplatePermalink.prototype.toString = function() {\n+ return this.resolve();\n+};\n+\n+module.exports = TemplatePermalink;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplatePermalinkTest.js", "diff": "+import test from \"ava\";\n+import parsePath from \"parse-filepath\";\n+import TemplatePermalink from \"../src/TemplatePermalink\";\n+\n+test(\"Simple\", t => {\n+ t.is(\n+ new TemplatePermalink(\"permalinksubfolder/\").toString(),\n+ \"permalinksubfolder/index.html\"\n+ );\n+ t.is(\n+ new TemplatePermalink(\"./permalinksubfolder/\").toString(),\n+ \"permalinksubfolder/index.html\"\n+ );\n+\n+ t.is(\n+ new TemplatePermalink(\"permalinksubfolder/test.html\").toString(),\n+ \"permalinksubfolder/test.html\"\n+ );\n+ t.is(\n+ new TemplatePermalink(\"./permalinksubfolder/test.html\").toString(),\n+ \"permalinksubfolder/test.html\"\n+ );\n+\n+ t.is(\n+ new TemplatePermalink(\"permalinksubfolder/test.html\", \"0/\").toString(),\n+ \"permalinksubfolder/0/test.html\"\n+ );\n+ t.is(\n+ new TemplatePermalink(\"permalinksubfolder/test.html\", \"1/\").toString(),\n+ \"permalinksubfolder/1/test.html\"\n+ );\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Permalink object
699
19.12.2017 22:26:46
21,600
6ccacc82c3f9973febcc540a396e4f3d01615238
URL simplification if directory and filename match.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -68,17 +68,12 @@ Template.prototype.getOutputLink = async function() {\nreturn perm.toString();\n}\n- // TODO move this into permalink (or new obj?)\n- let dir = this.getTemplateSubfolder();\n- let path =\n- (dir ? dir + \"/\" : \"\") +\n- (this.parsed.name !== \"index\" ? this.parsed.name + \"/\" : \"\") +\n- this.extraOutputSubdirectory +\n- \"index\" +\n- (this.isHtmlIOException ? cfg.htmlOutputSuffix : \"\") +\n- \".html\";\n-\n- return normalize(path);\n+ return TemplatePermalink.generate(\n+ this.getTemplateSubfolder(),\n+ this.parsed.name,\n+ this.extraOutputSubdirectory,\n+ this.isHtmlIOException ? cfg.htmlOutputSuffix : \"\"\n+ ).toString();\n};\n// TODO check for conflicts, see if file already exists?\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePermalink.js", "new_path": "src/TemplatePermalink.js", "diff": "@@ -5,7 +5,6 @@ const TemplatePath = require(\"./TemplatePath\");\nfunction TemplatePermalink(link, extraSubdir) {\nthis.link = this._cleanLink(link);\nthis.extraSubdir = extraSubdir || \"\";\n- this.parsed = parsePath(this.link);\n}\nTemplatePermalink.prototype._cleanLink = function(link) {\n@@ -13,8 +12,10 @@ TemplatePermalink.prototype._cleanLink = function(link) {\n};\nTemplatePermalink.prototype.resolve = function() {\n+ let parsed = parsePath(this.link);\n+\nreturn TemplatePath.normalize(\n- this.parsed.dir + \"/\" + this.extraSubdir + this.parsed.base // name with extension\n+ parsed.dir + \"/\" + this.extraSubdir + parsed.base // name with extension\n);\n};\n@@ -22,4 +23,24 @@ TemplatePermalink.prototype.toString = function() {\nreturn this.resolve();\n};\n+TemplatePermalink._hasDuplicateFolder = function(dir, base) {\n+ let folders = dir.split(\"/\");\n+ if (!folders[folders.length - 1]) {\n+ folders.pop();\n+ }\n+ return folders[folders.length - 1] === base;\n+};\n+\n+TemplatePermalink.generate = function(dir, filenameNoExt, extraSubdir, suffix) {\n+ let hasDupeFolder = TemplatePermalink._hasDuplicateFolder(dir, filenameNoExt);\n+ let path =\n+ (dir ? dir + \"/\" : \"\") +\n+ (filenameNoExt !== \"index\" && !hasDupeFolder ? filenameNoExt + \"/\" : \"\") +\n+ \"index\" +\n+ (suffix || \"\") +\n+ \".html\";\n+\n+ return new TemplatePermalink(path, extraSubdir);\n+};\n+\nmodule.exports = TemplatePermalink;\n" }, { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -118,13 +118,13 @@ test(\"Paginate external data file\", async t => {\nlet pages = await paging.getTemplates();\nt.is(pages.length, 2);\n- t.is(await pages[0].getOutputPath(), \"./dist/paged/paged/index.html\");\n+ t.is(await pages[0].getOutputPath(), \"./dist/paged/index.html\");\nt.is(\n(await pages[0].render()).trim(),\n\"<ol><li>item1</li><li>item2</li><li>item3</li><li>item4</li><li>item5</li></ol>\"\n);\n- t.is(await pages[1].getOutputPath(), \"./dist/paged/paged/1/index.html\");\n+ t.is(await pages[1].getOutputPath(), \"./dist/paged/1/index.html\");\nt.is(\n(await pages[1].render()).trim(),\n\"<ol><li>item6</li><li>item7</li><li>item8</li></ol>\"\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePermalinkTest.js", "new_path": "test/TemplatePermalinkTest.js", "diff": "@@ -2,25 +2,29 @@ import test from \"ava\";\nimport parsePath from \"parse-filepath\";\nimport TemplatePermalink from \"../src/TemplatePermalink\";\n-test(\"Simple\", t => {\n+test(\"Simple straight permalink\", t => {\nt.is(\n- new TemplatePermalink(\"permalinksubfolder/\").toString(),\n- \"permalinksubfolder/index.html\"\n+ new TemplatePermalink(\"permalinksubfolder/test.html\").toString(),\n+ \"permalinksubfolder/test.html\"\n);\nt.is(\n- new TemplatePermalink(\"./permalinksubfolder/\").toString(),\n- \"permalinksubfolder/index.html\"\n+ new TemplatePermalink(\"./permalinksubfolder/test.html\").toString(),\n+ \"permalinksubfolder/test.html\"\n);\n+});\n+test(\"Permalink without filename\", t => {\nt.is(\n- new TemplatePermalink(\"permalinksubfolder/test.html\").toString(),\n- \"permalinksubfolder/test.html\"\n+ new TemplatePermalink(\"permalinksubfolder/\").toString(),\n+ \"permalinksubfolder/index.html\"\n);\nt.is(\n- new TemplatePermalink(\"./permalinksubfolder/test.html\").toString(),\n- \"permalinksubfolder/test.html\"\n+ new TemplatePermalink(\"./permalinksubfolder/\").toString(),\n+ \"permalinksubfolder/index.html\"\n);\n+});\n+test(\"Permalink with pagination subdir\", t => {\nt.is(\nnew TemplatePermalink(\"permalinksubfolder/test.html\", \"0/\").toString(),\n\"permalinksubfolder/0/test.html\"\n@@ -30,3 +34,53 @@ test(\"Simple\", t => {\n\"permalinksubfolder/1/test.html\"\n);\n});\n+\n+test(\"Permalink generate\", t => {\n+ let gen = TemplatePermalink.generate;\n+\n+ t.is(gen(\"./\", \"index\").toString(), \"index.html\");\n+ t.is(gen(\".\", \"index\").toString(), \"index.html\");\n+ t.is(gen(\".\", \"test\").toString(), \"test/index.html\");\n+ t.is(gen(\".\", \"test\", \"0/\").toString(), \"test/0/index.html\");\n+ t.is(gen(\".\", \"test\", \"1/\").toString(), \"test/1/index.html\");\n+});\n+\n+test(\"Permalink generate with suffix\", t => {\n+ let gen = TemplatePermalink.generate;\n+\n+ t.is(gen(\".\", \"test\", null, \"-output\").toString(), \"test/index-output.html\");\n+ t.is(\n+ gen(\".\", \"test\", \"1/\", \"-output\").toString(),\n+ \"test/1/index-output.html\"\n+ );\n+});\n+\n+test(\"Permalink generate with subfolders\", t => {\n+ let gen = TemplatePermalink.generate;\n+\n+ t.is(\n+ gen(\"permalinksubfolder/\", \"index\").toString(),\n+ \"permalinksubfolder/index.html\"\n+ );\n+ t.is(\n+ gen(\"permalinksubfolder/\", \"test\").toString(),\n+ \"permalinksubfolder/test/index.html\"\n+ );\n+ t.is(\n+ gen(\"permalinksubfolder/\", \"test\", \"1/\", \"-output\").toString(),\n+ \"permalinksubfolder/test/1/index-output.html\"\n+ );\n+});\n+\n+test(\"Permalink matching folder and filename\", t => {\n+ let gen = TemplatePermalink.generate;\n+ let hasDupe = TemplatePermalink._hasDuplicateFolder;\n+ t.is(hasDupe(\"subfolder\", \"component\"), false);\n+ t.is(hasDupe(\"subfolder/\", \"component\"), false);\n+ t.is(hasDupe(\".\", \"component\"), false);\n+\n+ t.is(hasDupe(\"component\", \"component\"), true);\n+ t.is(hasDupe(\"component/\", \"component\"), true);\n+\n+ t.is(gen(\"component/\", \"component\").toString(), \"component/index.html\");\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -50,6 +50,17 @@ test(\"subfolder outputs to a subfolder\", async t => {\n);\nt.is(tmpl.parsed.dir, \"./test/stubs/subfolder\");\nt.is(tmpl.getTemplateSubfolder(), \"subfolder\");\n+ t.is(await tmpl.getOutputPath(), \"./dist/subfolder/index.html\");\n+});\n+\n+test(\"subfolder outputs to double subfolder\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/subfolder/subfolder/subfolder.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ t.is(tmpl.parsed.dir, \"./test/stubs/subfolder/subfolder\");\n+ t.is(tmpl.getTemplateSubfolder(), \"subfolder/subfolder\");\nt.is(await tmpl.getOutputPath(), \"./dist/subfolder/subfolder/index.html\");\n});\n" }, { "change_type": "ADD", "old_path": "test/stubs/subfolder/subfolder/subfolder.ejs", "new_path": "test/stubs/subfolder/subfolder/subfolder.ejs", "diff": "" } ]
JavaScript
MIT License
11ty/eleventy
URL simplification if directory and filename match.
699
19.12.2017 22:30:18
21,600
5dec686e6426076957a55ff50c6a67e66a8bb4db
Switch to -o instead of -output for html io exception
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -58,10 +58,10 @@ eleventy --input=. --output=. --watch --formats=md\n##### Exception: index.html Templates\n-When the input and output directories are the same, and if the source template is named `index.html`, it will output as `index-output.html` to avoid overwriting itself. This is a special case that only applies to `index.html` filenames. You can customize this `-output` suffix with the `htmlOutputSuffix` configuration option.\n+When the input and output directories are the same, and if the source template is named `index.html`, it will output as `index-o.html` to avoid overwriting itself. This is a special case that only applies to `index.html` filenames. You can customize the `-o` suffix with the `htmlOutputSuffix` configuration option.\n```\n-# Adds `-output` to index.html file names to avoid overwriting matching files.\n+# Adds `-o` to index.html file names to avoid overwriting matching files.\neleventy --input=. --output=. --formats=html\n```\n" }, { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -16,7 +16,7 @@ module.exports = {\nmarkdownTemplateEngine: \"liquid\",\nhtmlTemplateEngine: \"liquid\",\ndataTemplateEngine: \"liquid\",\n- htmlOutputSuffix: \"-output\",\n+ htmlOutputSuffix: \"-o\",\nkeys: {\npackage: \"pkg\",\nlayout: \"layout\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePermalinkTest.js", "new_path": "test/TemplatePermalinkTest.js", "diff": "@@ -48,11 +48,8 @@ test(\"Permalink generate\", t => {\ntest(\"Permalink generate with suffix\", t => {\nlet gen = TemplatePermalink.generate;\n- t.is(gen(\".\", \"test\", null, \"-output\").toString(), \"test/index-output.html\");\n- t.is(\n- gen(\".\", \"test\", \"1/\", \"-output\").toString(),\n- \"test/1/index-output.html\"\n- );\n+ t.is(gen(\".\", \"test\", null, \"-o\").toString(), \"test/index-o.html\");\n+ t.is(gen(\".\", \"test\", \"1/\", \"-o\").toString(), \"test/1/index-o.html\");\n});\ntest(\"Permalink generate with subfolders\", t => {\n@@ -67,8 +64,8 @@ test(\"Permalink generate with subfolders\", t => {\n\"permalinksubfolder/test/index.html\"\n);\nt.is(\n- gen(\"permalinksubfolder/\", \"test\", \"1/\", \"-output\").toString(),\n- \"permalinksubfolder/test/1/index-output.html\"\n+ gen(\"permalinksubfolder/\", \"test\", \"1/\", \"-o\").toString(),\n+ \"permalinksubfolder/test/1/index-o.html\"\n);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -88,7 +88,7 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(await tmpl.getOutputPath(), \"./test/stubs/index-output.html\");\n+ t.is(await tmpl.getOutputPath(), \"./test/stubs/index-o.html\");\n});\ntest(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index).\", async t => {\n@@ -97,7 +97,7 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(await tmpl.getOutputPath(), \"./test/stubs/subfolder/index-output.html\");\n+ t.is(await tmpl.getOutputPath(), \"./test/stubs/subfolder/index-o.html\");\n});\ntest(\"Test raw front matter from template\", t => {\n" } ]
JavaScript
MIT License
11ty/eleventy
Switch to -o instead of -output for html io exception
699
20.12.2017 08:08:46
21,600
5de0a35a286093fae91ecff007cb3a4c6f8647fb
Add write counts and --quiet option
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -4,6 +4,7 @@ const Eleventy = require(\"./src/Eleventy\");\nlet eleven = new Eleventy(argv.input, argv.output);\neleven.setFormats(argv.formats);\n+eleven.setIsVerbose(!argv.quiet);\n(async function() {\nawait eleven.init();\n@@ -17,6 +18,6 @@ eleven.setFormats(argv.formats);\n} else {\nawait eleven.write();\n- console.log(eleven.getElapsedTime());\n+ console.log(eleven.getFinishedLog());\n}\n})();\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -19,6 +19,7 @@ function Pagination(data) {\nthis.target = this._resolveItems(data);\nthis.items = this.getPagedItems();\n+ this.writeCount = 0;\n}\nPagination.prototype.hasPagination = function() {\n@@ -115,7 +116,12 @@ Pagination.prototype.write = async function() {\nlet pages = await this.getTemplates();\nfor (let page of pages) {\nawait page.write();\n+ this.writeCount += page.getWriteCount();\n}\n};\n+Pagination.prototype.getWriteCount = function() {\n+ return this.writeCount;\n+};\n+\nmodule.exports = Pagination;\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -10,6 +10,7 @@ const TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\nconst Layout = require(\"./Layout\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n+const Eleventy = require(\"./Eleventy\");\nlet cfg = TemplateConfig.getDefaultConfig();\n@@ -47,8 +48,15 @@ function Template(path, inputDir, outputDir, templateData) {\nthis.inputDir === this.outputDir &&\nthis.templateRender.isEngine(\"html\") &&\nthis.parsed.name === \"index\";\n+\n+ this.isVerbose = true;\n+ this.writeCount = 0;\n}\n+Template.prototype.setIsVerbose = function(isVerbose) {\n+ this.isVerbose = isVerbose;\n+};\n+\nTemplate.prototype.getTemplateSubfolder = function() {\nreturn TemplatePath.stripPathFromDir(this.parsed.dir, this.inputDir);\n};\n@@ -231,26 +239,40 @@ Template.prototype.runPlugins = async function(data) {\nTemplate.prototype.write = async function() {\nlet outputPath = await this.getOutputPath();\nif (this.isIgnored()) {\n+ if (this.isVerbose) {\nconsole.log(\"Ignoring\", outputPath);\n+ }\n} else {\n+ this.writeCount++;\n+\nlet data = await this.getData();\nlet str = await this.render(data);\nlet pluginRet = await this.runPlugins(data);\nif (pluginRet) {\nlet filtered = this.runFilters(str);\nawait pify(fs.outputFile)(outputPath, filtered);\n+\n+ if (this.isVerbose) {\nconsole.log(\"Writing\", outputPath, \"from\", this.inputPath);\n}\n}\n+ }\n};\nTemplate.prototype.clone = function() {\n- return new Template(\n+ // TODO better clone\n+ var tmpl = new Template(\nthis.inputPath,\nthis.inputDir,\nthis.outputDir,\nthis.templateData\n);\n+ tmpl.setIsVerbose(this.isVerbose);\n+ return tmpl;\n+};\n+\n+Template.prototype.getWriteCount = function() {\n+ return this.writeCount;\n};\nmodule.exports = Template;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -16,6 +16,8 @@ function TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.templateExtensions = extensions;\nthis.outputDir = outputDir;\nthis.templateData = templateData;\n+ this.isVerbose = true;\n+ this.writeCount = 0;\nthis.rawFiles = this.templateExtensions.map(\nfunction(extension) {\n@@ -98,14 +100,18 @@ TemplateWriter.prototype._getTemplate = function(path) {\nthis.templateData\n);\n+ tmpl.setIsVerbose(this.isVerbose);\n+\ntmpl.addFilter(function(str) {\nreturn pretty(str, { ocd: true });\n});\n+ let writer = this;\ntmpl.addPlugin(\"pagination\", async function(data) {\n- var paging = new Pagination(data);\n+ let paging = new Pagination(data);\npaging.setTemplate(this);\nawait paging.write();\n+ writer.writeCount += paging.getWriteCount();\nif (paging.cancel()) {\nreturn false;\n@@ -118,6 +124,7 @@ TemplateWriter.prototype._getTemplate = function(path) {\nTemplateWriter.prototype._writeTemplate = async function(path) {\nlet tmpl = this._getTemplate(path);\nawait tmpl.write();\n+ this.writeCount += tmpl.getWriteCount();\nreturn tmpl;\n};\n@@ -128,4 +135,12 @@ TemplateWriter.prototype.write = async function() {\n}\n};\n+TemplateWriter.prototype.setVerboseOutput = function(isVerbose) {\n+ this.isVerbose = isVerbose;\n+};\n+\n+TemplateWriter.prototype.getWriteCount = function() {\n+ return this.writeCount;\n+};\n+\nmodule.exports = TemplateWriter;\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyTest.js", "new_path": "test/EleventyTest.js", "diff": "@@ -25,6 +25,13 @@ test(\"Eleventy, get help\", t => {\nt.truthy(elev.getHelp());\n});\n+test(\"Eleventy, set is verbose\", t => {\n+ let elev = new Eleventy();\n+ elev.setIsVerbose(true);\n+\n+ t.true(elev.isVerbose);\n+});\n+\ntest(\"Eleventy set input/output\", async t => {\nlet elev = new Eleventy(\"./test/stubs\", \"./test/stubs/_site\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Add write counts and --quiet option
699
20.12.2017 08:29:30
21,600
e42531fcf5fed969fae215183b95b6dbf21d122f
New npm package name
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -15,6 +15,12 @@ Works with:\n* [Pug](https://github.com/pugjs/pug) (formerly Jade, `.pug`)\n* JavaScript Template Literals (`.jstl`) (strings with backticks \\`)\n+## Installation\n+\n+```\n+npm install -g eleventy-cli\n+```\n+\n## Usage\n```\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n- \"name\": \"eleventy\",\n+ \"name\": \"eleventy-cli\",\n\"version\": \"0.1.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"cmd.js\",\n" } ]
JavaScript
MIT License
11ty/eleventy
New npm package name
699
20.12.2017 10:09:43
21,600
f77b3b25bf8359b5aba42ea1f464770da1549e28
Uh, a new package.json name broke a few tests
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"name\": \"eleventy-cli\",\n\"version\": \"0.1.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n- \"main\": \"cmd.js\",\n+ \"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n\"engines\": {\n\"node\": \">=8.0.0\"\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -143,7 +143,7 @@ test(\"More advanced getData()\", async t => {\nkey2: \"value2\"\n});\n- t.is(data[cfg.keys.package].name, \"eleventy\");\n+ t.is(data[cfg.keys.package].name, \"eleventy-cli\");\nt.is(\ndata.key1,\n\"value1override\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Uh, a new package.json name broke a few tests
699
20.12.2017 12:42:55
21,600
1a1ffdd232f24042e281036701dfbc62ba41fdf3
Switches from slug-rfc to slugify to fix
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -17,6 +17,8 @@ Works with:\n## Installation\n+Available [on npm](https://www.npmjs.com/package/eleventy-cli).\n+\n```\nnpm install -g eleventy-cli\n```\n" }, { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "-const slug = require(\"slug-rfc\");\n+const slugify = require(\"slugify\");\nmodule.exports = {\ntemplateFormats: [\n@@ -31,7 +31,8 @@ module.exports = {\nhandlebarsHelpers: {},\nnunjucksFilters: {\nslug: function(str) {\n- return slug(str, {\n+ return slugify(str, {\n+ replacement: \"-\",\nlower: true\n});\n}\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"pify\": \"^3.0.0\",\n\"pretty\": \"^2.0.0\",\n\"pug\": \"^2.0.0-rc.4\",\n- \"slug-rfc\": \"^0.1.0\"\n+ \"slugify\": \"^1.2.7\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "-const slug = require(\"slug-rfc\");\nconst NunjucksLib = require(\"nunjucks\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nconst TemplateConfig = require(\"../TemplateConfig\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Switches from slug-rfc to slugify to fix #2
699
20.12.2017 12:45:27
21,600
568a79fa54fc1f7af60ac74e22d998b379b47e4a
Switch from git+ssh to https in an attempt to fix
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"prettier\": \"1.9.1\"\n},\n\"dependencies\": {\n- \"ejs\": \"git+ssh://[email protected]:zachleat/ejs.git#v2.5.7-h1\",\n+ \"ejs\": \"https://github.com/zachleat/ejs.git#v2.5.7-h1\",\n\"fs-extra\": \"^4.0.2\",\n\"glob-watcher\": \"^4.0.0\",\n\"globby\": \"^7.1.1\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Switch from git+ssh to https in an attempt to fix #3
699
21.12.2017 07:47:40
21,600
b19609f594d52f51139823e736c190397a36cb5e
Switch to use static partial includes to match Jekyll include syntax via
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"gray-matter\": \"^3.1.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.11\",\n- \"liquidjs\": \"^2.0.3\",\n+ \"liquidjs\": \"^2.2.0\",\n\"lodash.chunk\": \"^4.2.0\",\n\"lodash.clone\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -6,7 +6,8 @@ class Liquid extends TemplateEngine {\n// warning, the include syntax supported here does not match what jekyll uses.\nlet engine = LiquidLib({\nroot: [super.getInputDir()],\n- extname: \".liquid\"\n+ extname: \".liquid\",\n+ dynamicPartials: false\n});\nlet tmpl = await engine.parse(str);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderTest.js", "new_path": "test/TemplateRenderTest.js", "diff": "@@ -323,7 +323,7 @@ test(\"Liquid Render Include\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(\"<p>{% include 'included' %}</p>\");\n+ ).getCompiledTemplate(\"<p>{% include included %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n@@ -333,7 +333,7 @@ test(\"Liquid Render Include with Liquid Suffix\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(\"<p>{% include 'included.liquid' %}</p>\");\n+ ).getCompiledTemplate(\"<p>{% include included.liquid %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n@@ -343,7 +343,7 @@ test(\"Liquid Render Include with HTML Suffix\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(\"<p>{% include 'included.html' %}</p>\");\n+ ).getCompiledTemplate(\"<p>{% include included.html %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -234,7 +234,7 @@ test(\"Liquid template with include\", async t => {\n\"dist\"\n);\n- t.is(await tmpl.render(), `<p>This is an include.</p>`);\n+ t.is((await tmpl.render()).trim(), `<p>This is an include.</p>`);\n});\ntest(\"ES6 Template Literal\", async t => {\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/includer.liquid", "new_path": "test/stubs/includer.liquid", "diff": "-<p>{% include 'included' %}</p>\n\\ No newline at end of file\n+<p>{% include included %}</p>\n" } ]
JavaScript
MIT License
11ty/eleventy
Switch to use static partial includes to match Jekyll include syntax via https://github.com/harttle/liquidjs/issues/51
698
21.12.2017 23:35:19
0
026eb731c537cccf6e67a87ea5dce5c0f5b74f71
Update to ES6 format
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -6,7 +6,7 @@ let eleven = new Eleventy(argv.input, argv.output);\neleven.setFormats(argv.formats);\neleven.setIsVerbose(!argv.quiet);\n-(async function() {\n+(async () => {\nawait eleven.init();\nif (argv.version) {\n@@ -17,7 +17,6 @@ eleven.setIsVerbose(!argv.quiet);\neleven.watch();\n} else {\nawait eleven.write();\n-\nconsole.log(eleven.getFinishedLog());\n}\n})();\n" }, { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -30,7 +30,7 @@ module.exports = {\n},\nhandlebarsHelpers: {},\nnunjucksFilters: {\n- slug: function(str) {\n+ slug: str => {\nreturn slugify(str, {\nreplacement: \"-\",\nlower: true\n" } ]
JavaScript
MIT License
11ty/eleventy
Update to ES6 format
699
21.12.2017 22:17:47
21,600
fd29eecd1f8ea8884d97676c8903f31bdf11b8f0
Restrict `npm run default` to `playground` dir only.
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"eleventy\": \"./cmd.js\"\n},\n\"scripts\": {\n- \"default\": \"node cmd.js\",\n- \"watch\": \"node cmd.js --watch\",\n+ \"default\": \"node cmd.js --input=playground --output=_site\",\n\"test\": \"ava\",\n\"watch:test\": \"ava --watch --verbose\",\n\"precommit\": \"lint-staged\"\n" } ]
JavaScript
MIT License
11ty/eleventy
Restrict `npm run default` to `playground` dir only.
699
26.12.2017 09:34:06
21,600
98dd98d4a900cb4a4f3adbf2bed6294a4a90e2fd
Better error messaging, fixes
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n\"name\": \"eleventy-cli\",\n- \"version\": \"0.1.3\",\n+ \"version\": \"0.1.4\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n\"prettier\": \"1.9.1\"\n},\n\"dependencies\": {\n+ \"chalk\": \"^2.3.0\",\n\"ejs\": \"https://github.com/zachleat/ejs.git#v2.5.7-h1\",\n\"fs-extra\": \"^4.0.2\",\n\"glob-watcher\": \"^4.0.0\",\n" }, { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "const watch = require(\"glob-watcher\");\n+const chalk = require(\"chalk\");\nconst TemplateConfig = require(\"./TemplateConfig\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateWriter = require(\"./TemplateWriter\");\n+const EleventyError = require(\"./EleventyError\");\nconst pkg = require(\"../package.json\");\nlet cfg = TemplateConfig.getDefaultConfig();\n@@ -109,7 +111,7 @@ Eleventy.prototype.watch = function() {\n\"change\",\nfunction(path, stat) {\nconsole.log(\"File changed:\", path);\n- this.writer.write();\n+ this.write();\n}.bind(this)\n);\n@@ -117,13 +119,23 @@ Eleventy.prototype.watch = function() {\n\"add\",\nfunction(path, stat) {\nconsole.log(\"File added:\", path);\n- this.writer.write();\n+ this.write();\n}.bind(this)\n);\n};\nEleventy.prototype.write = async function() {\n- return this.writer.write();\n+ try {\n+ await this.writer.write();\n+ } catch (e) {\n+ console.log(\"\\n\" + chalk.red(\"Problem writing eleventy templates: \"));\n+ if (e instanceof EleventyError) {\n+ console.log(chalk.red(e.log()));\n+ console.log(\"\\n\" + e.dump());\n+ } else {\n+ console.log(e);\n+ }\n+ }\n};\nmodule.exports = Eleventy;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/EleventyError.js", "diff": "+class EleventyError {\n+ constructor(newErrorObj, oldErrorObj) {\n+ this.errors = [newErrorObj, oldErrorObj];\n+ }\n+\n+ // if already an existing EleventyError, will push on to stack instead of creating a new EleventyError obj\n+ static make(newErrorObj, oldErrorObj) {\n+ if (oldErrorObj instanceof EleventyError) {\n+ oldErrorObj.add(newErrorObj);\n+ return oldErrorObj;\n+ } else {\n+ return new EleventyError(newErrorObj, oldErrorObj);\n+ }\n+ }\n+\n+ add(errorObj) {\n+ this.errors.push(errorObj);\n+ }\n+\n+ dump() {\n+ for (let err of this.errors) {\n+ console.log(err);\n+ }\n+ }\n+\n+ log() {\n+ let str = [];\n+ for (let err of this.errors) {\n+ str.push(` * ${err}`);\n+ }\n+ return str.join(\"\\n\");\n+ }\n+}\n+\n+module.exports = EleventyError;\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -6,7 +6,7 @@ let cfg = TemplateConfig.getDefaultConfig();\nfunction Pagination(data) {\nthis.data = data || {};\n- this.size = 10;\n+ this.size = 1;\nthis.target = [];\nthis.writeCount = 0;\n@@ -14,10 +14,16 @@ function Pagination(data) {\nreturn;\n}\n- if (data.pagination.size) {\n- this.size = data.pagination.size;\n+ if (!data.pagination) {\n+ throw new Error(\n+ \"Misconfigured pagination data in template front matter (did you use tabs and not spaces?).\"\n+ );\n+ } else if (!(\"size\" in data.pagination)) {\n+ throw new Error(\"Missing pagination size in front matter data.\");\n}\n+ this.size = data.pagination.size;\n+\nthis.target = this._resolveItems(data);\nthis.items = this.getPagedItems();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -6,6 +6,7 @@ const Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n+const EleventyError = require(\"./EleventyError\");\nconst Pagination = require(\"./Plugins/Pagination\");\nconst pkg = require(\"../package.json\");\n@@ -69,7 +70,7 @@ TemplateWriter.getFileIgnores = function(baseDir) {\nTemplateWriter.prototype.addIgnores = function(baseDir, files) {\nfiles = files.concat(TemplateWriter.getFileIgnores(baseDir));\n-\n+ console.log(files);\nif (cfg.dir.output) {\nfiles = files.concat(\n\"!\" + normalize(baseDir + \"/\" + cfg.dir.output + \"/**\")\n@@ -123,7 +124,14 @@ TemplateWriter.prototype._getTemplate = function(path) {\nTemplateWriter.prototype._writeTemplate = async function(path) {\nlet tmpl = this._getTemplate(path);\n+ try {\nawait tmpl.write();\n+ } catch (e) {\n+ throw EleventyError.make(\n+ new Error(`Having trouble writing template: ${path}`),\n+ e\n+ );\n+ }\nthis.writeCount += tmpl.getWriteCount();\nreturn tmpl;\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Better error messaging, fixes #7
699
26.12.2017 09:41:28
21,600
30de0cdfc40fbf41c78e6cf587d441dfddbeb1ef
Fixes issue trailing whitespace line on .eleventyignore files.
[ { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -55,7 +55,12 @@ TemplateWriter.getFileIgnores = function(baseDir) {\nlet ignores = [];\nif (ignoreContent) {\n- ignores = ignoreContent.split(\"\\n\").map(line => {\n+ ignores = ignoreContent\n+ .split(\"\\n\")\n+ .filter(line => {\n+ return line.trim().length > 0;\n+ })\n+ .map(line => {\nline = line.trim();\npath = TemplatePath.normalize(baseDir, \"/\", line);\nif (fs.statSync(path).isDirectory()) {\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes issue trailing whitespace line on .eleventyignore files.
699
26.12.2017 10:03:48
21,600
5408ed5b42c5929f0b15865db0af8a4fbff858cb
globby requires leading dotslash for ignore files
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -20,6 +20,13 @@ TemplatePath.localPath = function(...paths) {\nreturn normalize(path.join(TemplatePath.getWorkingDir(), ...paths));\n};\n+TemplatePath.addLeadingDotSlash = function(path) {\n+ if (path.indexOf(\"/\") === 0 || path.indexOf(\".\") === 0) {\n+ return path;\n+ }\n+ return \"./\" + path;\n+};\n+\nTemplatePath.stripLeadingDotSlash = function(dir) {\nreturn dir.replace(/^\\.\\//, \"\");\n};\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -62,7 +62,9 @@ TemplateWriter.getFileIgnores = function(baseDir) {\n})\n.map(line => {\nline = line.trim();\n- path = TemplatePath.normalize(baseDir, \"/\", line);\n+ path = TemplatePath.addLeadingDotSlash(\n+ TemplatePath.normalize(baseDir, \"/\", line)\n+ );\nif (fs.statSync(path).isDirectory()) {\nreturn \"!\" + path + \"/**\";\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -23,6 +23,14 @@ test(\"stripLeadingDotSlash\", t => {\nt.is(TemplatePath.stripLeadingDotSlash(\"dist\"), \"dist\");\n});\n+test(\"addLeadingDotSlash\", t => {\n+ t.is(TemplatePath.addLeadingDotSlash(\"./test/stubs\"), \"./test/stubs\");\n+ t.is(TemplatePath.addLeadingDotSlash(\"./dist\"), \"./dist\");\n+ t.is(TemplatePath.addLeadingDotSlash(\"../dist\"), \"../dist\");\n+ t.is(TemplatePath.addLeadingDotSlash(\"/dist\"), \"/dist\");\n+ t.is(TemplatePath.addLeadingDotSlash(\"dist\"), \"./dist\");\n+});\n+\ntest(\"stripPathFromDir\", t => {\nt.is(\nTemplatePath.stripPathFromDir(\"./testing/hello\", \"./lskdjklfjz\"),\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -42,8 +42,8 @@ test(\"Output is a subdir of input\", async t => {\ntest(\".eleventyignore ignores parsing\", t => {\nlet ignores = new TemplateWriter.getFileIgnores(\"./test/stubs\");\n- t.is(ignores[0], \"!test/stubs/ignoredFolder/**\");\n- t.is(ignores[1], \"!test/stubs/ignoredFolder/ignored.md\");\n+ t.is(ignores[0], \"!./test/stubs/ignoredFolder/**\");\n+ t.is(ignores[1], \"!./test/stubs/ignoredFolder/ignored.md\");\n});\ntest(\".eleventyignore files\", async t => {\n@@ -56,7 +56,7 @@ test(\".eleventyignore files\", async t => {\nt.is(\nfiles.filter(file => {\n- return file.indexOf(\"test/stubs/ignoredFolder\") > -1;\n+ return file.indexOf(\"./test/stubs/ignoredFolder\") > -1;\n}).length,\n0\n);\n" } ]
JavaScript
MIT License
11ty/eleventy
globby requires leading dotslash for ignore files
699
26.12.2017 10:18:35
21,600
8fca9dede92370398a32e56dcf3cc72f32d87ae4
Fix for templateFormat overrides in config file.
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -27,7 +27,14 @@ TemplateConfig.prototype.mergeConfig = function(globalConfig) {\n// if file does not exist, return empty obj\nlocalConfig = {};\n}\n- return merge({}, globalConfig, localConfig);\n+ // Object assign overrides original values (good for templateFormats) but not good for helpers/filters\n+ // Handle those separately.\n+ let overrides = Object.assign({}, globalConfig, localConfig);\n+ let merges = [\"handlebarsHelpers\", \"nunjucksFilters\"];\n+ for (let key of merges) {\n+ overrides[key] = merge({}, globalConfig[key], localConfig[key]);\n+ }\n+ return overrides;\n};\nmodule.exports = TemplateConfig;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "@@ -9,4 +9,8 @@ test(\"Template Config local config overrides base config\", async t => {\nlet cfg = templateCfg.getConfig();\nt.is(cfg.markdownTemplateEngine, \"ejs\");\n+ t.is(cfg.templateFormats.join(\",\"), \"md,njk\");\n+\n+ t.is(Object.keys(cfg.handlebarsHelpers).length, 0);\n+ t.is(Object.keys(cfg.nunjucksFilters).length, 2);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/config.js", "new_path": "test/stubs/config.js", "diff": "module.exports = {\n- \"markdownTemplateEngine\": \"ejs\"\n+ markdownTemplateEngine: \"ejs\",\n+ templateFormats: [\"md\", \"njk\"],\n+ nunjucksFilters: {\n+ testing: str => {\n+ return str;\n+ }\n+ }\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix for templateFormat overrides in config file.
699
26.12.2017 11:20:56
21,600
100286429568a922947cf7fba93c27a6a8af7951
JavaScript Template Literal files work with or without backticks
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "const TemplateEngine = require(\"./TemplateEngine\");\n+const EleventyError = require(\"../EleventyError\");\nclass JavaScript extends TemplateEngine {\nasync compile(str) {\n@@ -15,13 +16,13 @@ class JavaScript extends TemplateEngine {\nstr = \"`\" + str + \"`\";\n}\n+ let evalStr = `${dataStr}\\n${str};`;\ntry {\n// TODO switch to https://www.npmjs.com/package/es6-template-strings\n- let val = eval(dataStr + \"\\n\" + str + \";\");\n+ let val = eval(evalStr);\nreturn val;\n} catch (e) {\n- console.log(\"Broken ES6 template: \", dataStr + \"\\n\" + str + \";\");\n- throw e;\n+ EleventyError.make(`Broken ES6 template:\\n${evalStr}`, e);\n}\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -237,7 +237,7 @@ test(\"Liquid template with include\", async t => {\nt.is((await tmpl.render()).trim(), `<p>This is an include.</p>`);\n});\n-test(\"ES6 Template Literal\", async t => {\n+test(\"ES6 Template Literal (No Backticks)\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n\"./test/stubs/formatTest.jstl\",\n@@ -246,7 +246,19 @@ test(\"ES6 Template Literal\", async t => {\ndataObj\n);\n- t.is(await tmpl.render(), `<p>ZACH</p>`);\n+ t.is((await tmpl.render()).trim(), `<p>ZACH</p>`);\n+});\n+\n+test(\"ES6 Template Literal (with Backticks)\", async t => {\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ let tmpl = new Template(\n+ \"./test/stubs/formatTestBackticks.jstl\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\n+\n+ t.is((await tmpl.render()).trim(), `<p>ZACH</p>`);\n});\ntest(\"Permalink output directory\", async t => {\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/formatTest.jstl", "new_path": "test/stubs/formatTest.jstl", "diff": "---\nname: zach\n---\n-`<p>${name.toUpperCase()}</p>`\n\\ No newline at end of file\n+<p>${name.toUpperCase()}</p>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/formatTestBackticks.jstl", "diff": "+---\n+name: zach\n+---\n+`<p>${name.toUpperCase()}</p>`\n" } ]
JavaScript
MIT License
11ty/eleventy
JavaScript Template Literal files work with or without backticks
699
26.12.2017 12:41:02
21,600
3ff8de942a6684905502d97f8e84d1953d79e3dd
Allow permalinks to ignore output dir.
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -20,7 +20,8 @@ module.exports = {\nkeys: {\npackage: \"pkg\",\nlayout: \"layout\",\n- permalink: \"permalink\"\n+ permalink: \"permalink\",\n+ permalinkRoot: \"permalinkBypassOutputDir\"\n},\ndir: {\ninput: \".\",\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -87,7 +87,11 @@ Template.prototype.getOutputLink = async function() {\n// TODO check for conflicts, see if file already exists?\nTemplate.prototype.getOutputPath = async function() {\nlet uri = await this.getOutputLink();\n+ if (this.getFrontMatterData()[cfg.keys.permalinkRoot]) {\n+ return normalize(uri);\n+ } else {\nreturn normalize(this.outputDir + \"/\" + uri);\n+ }\n};\nTemplate.prototype.setDataOverrides = function(overrides) {\n" } ]
JavaScript
MIT License
11ty/eleventy
Allow permalinks to ignore output dir.
699
26.12.2017 17:29:50
21,600
e77a82106910bb57a388dd31763aba52fd0ddd45
renderData on front matter to render variables in front matter data
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "},\n\"dependencies\": {\n\"chalk\": \"^2.3.0\",\n- \"ejs\": \"https://github.com/zachleat/ejs.git#v2.5.7-h1\",\n+ \"ejs\": \"git+https://github.com/zachleat/ejs.git#v2.5.7-h1\",\n\"fs-extra\": \"^4.0.2\",\n\"glob-watcher\": \"^4.0.0\",\n\"globby\": \"^7.1.1\",\n\"handlebars\": \"^4.0.11\",\n\"liquidjs\": \"^2.2.0\",\n\"lodash.chunk\": \"^4.2.0\",\n- \"lodash.clone\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n+ \"lodash.isarray\": \"^4.0.0\",\n+ \"lodash.isobject\": \"^3.0.2\",\n\"lodash.merge\": \"^4.6.0\",\n\"lodash.set\": \"^4.3.2\",\n\"markdown-it\": \"^8.4.0\",\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -4,7 +4,8 @@ const fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst matter = require(\"gray-matter\");\nconst normalize = require(\"normalize-path\");\n-const clone = require(\"lodash.clone\");\n+const _isArray = require(\"lodash.isarray\");\n+const _isObject = require(\"lodash.isobject\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\n@@ -70,6 +71,7 @@ Template.prototype.getOutputLink = async function() {\nif (permalink) {\nlet data = await this.getData();\nlet perm = new TemplatePermalink(\n+ // render variables inside permalink front matter\nawait this.renderContent(permalink, data),\nthis.extraOutputSubdirectory\n);\n@@ -146,6 +148,33 @@ Template.prototype.getLocalDataPath = function() {\nreturn this.parsed.dir + \"/\" + this.parsed.name + \".json\";\n};\n+Template.prototype.mapDataAsRenderedTemplates = async function(\n+ data,\n+ templateData\n+) {\n+ if (_isArray(data)) {\n+ let arr = [];\n+ for (let j = 0, k = data.length; j < k; j++) {\n+ arr.push(await this.mapDataAsRenderedTemplates(data[j], templateData));\n+ }\n+ return arr;\n+ } else if (_isObject(data)) {\n+ let obj = {};\n+ for (let value in data) {\n+ obj[value] = await this.mapDataAsRenderedTemplates(\n+ data[value],\n+ templateData\n+ );\n+ }\n+ return obj;\n+ } else if (typeof data === \"string\") {\n+ let str = await this.renderContent(data, templateData);\n+ return str;\n+ }\n+\n+ return data;\n+};\n+\nTemplate.prototype.getData = async function(localData) {\nlet data = {};\n@@ -153,18 +182,16 @@ Template.prototype.getData = async function(localData) {\ndata = await this.templateData.getLocalData(this.getLocalDataPath());\n}\n+ let mergedLocalData = Object.assign({}, localData, this.dataOverrides);\n+\n+ let frontMatterData = this.getFrontMatterData();\n+\nlet mergedLayoutData = await this.getAllLayoutFrontMatterData(\nthis,\n- this.getFrontMatterData()\n+ frontMatterData\n);\n- return Object.assign(\n- {},\n- data,\n- mergedLayoutData,\n- localData,\n- this.dataOverrides\n- );\n+ return Object.assign({}, data, mergedLayoutData, mergedLocalData);\n};\nTemplate.prototype.renderLayout = async function(tmpl, tmplData) {\n@@ -250,9 +277,16 @@ Template.prototype.write = async function() {\nthis.writeCount++;\nlet data = await this.getData();\n- let str = await this.render(data);\n+ if (data.renderData) {\n+ data.renderData = await this.mapDataAsRenderedTemplates(\n+ data.renderData,\n+ data\n+ );\n+ }\n+\nlet pluginRet = await this.runPlugins(data);\nif (pluginRet) {\n+ let str = await this.render(data);\nlet filtered = this.runFilters(str);\nawait pify(fs.outputFile)(outputPath, filtered);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -309,3 +309,55 @@ test(\"Permalink with variables!\", async t => {\nt.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-candidate/index.html\");\n});\n+\n+test(\"mapDataAsRenderedTemplates\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/default.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.deepEqual(\n+ await tmpl.mapDataAsRenderedTemplates(\n+ {\n+ key1: \"value1\",\n+ key2: \"value2\",\n+ key3: \"value3\"\n+ },\n+ { parsedKey: \"parsedValue\" }\n+ ),\n+ {\n+ key1: \"value1\",\n+ key2: \"value2\",\n+ key3: \"value3\"\n+ }\n+ );\n+\n+ t.deepEqual(\n+ await tmpl.mapDataAsRenderedTemplates(\n+ {\n+ key1: \"value1\",\n+ key2: \"<%= parsedKey %>\"\n+ },\n+ { parsedKey: \"parsedValue\" }\n+ ),\n+ {\n+ key1: \"value1\",\n+ key2: \"parsedValue\"\n+ }\n+ );\n+\n+ t.deepEqual(\n+ await tmpl.mapDataAsRenderedTemplates(\n+ {\n+ key1: \"value1\",\n+ key2: [\"<%= parsedKey %>\", 2]\n+ },\n+ { parsedKey: \"parsedValue\" }\n+ ),\n+ {\n+ key1: \"value1\",\n+ key2: [\"parsedValue\", 2]\n+ }\n+ );\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
renderData on front matter to render variables in front matter data
699
28.12.2017 07:45:11
21,600
d97a2f54c0273a8e5e14e8e7f0aa6e70fa094d53
Pagination variable aliasing.
[ { "change_type": "MODIFY", "old_path": "docs/pagination.md", "new_path": "docs/pagination.md", "diff": "@@ -53,6 +53,7 @@ Your front matter would look like this:\n---\npagination:\ndata: globalDataSet.myData\n+ size: 1\n---\n<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n```\n@@ -87,6 +88,7 @@ You can do more advanced things like this:\n---\npagination:\ndata: testdata\n+ size: 1\ntestdata:\n- My Item\npermalink: different/{{ pagination.items[0] | slug }}/index.html\n@@ -94,3 +96,43 @@ permalink: different/{{ pagination.items[0] | slug }}/index.html\n```\nUsing a Nunjucks `slug` filter (transforms `My Item` to `my-item`), this outputs: `_site/different/my-item/index.html`.\n+\n+#### Aliasing pagination items to a different variable\n+\n+Ok, so `pagination.items[0]` is ugly. We provide an option to alias this to something different.\n+\n+```\n+---\n+pagination:\n+ data: testdata\n+ size: 1\n+ alias: wonder\n+testdata:\n+ - Item1\n+ - Item2\n+permalink: different/{{ wonder | slug }}/index.html\n+---\n+You can use the alias in your content too {{ wonder }}.\n+```\n+\n+This writes to `_site/different/item1/index.html`.\n+\n+If your chunk `size` is greater than 1, the alias will be an array instead of a single value.\n+\n+```\n+---\n+pagination:\n+ data: testdata\n+ size: 2\n+ alias: wonder\n+testdata:\n+ - Item1\n+ - Item2\n+ - Item3\n+ - Item4\n+permalink: different/{{ wonder[0] | slug }}/index.html\n+---\n+You can use the alias in your content too {{ wonder[0] }}.\n+```\n+\n+This writes to `_site/different/item1/index.html`.\n" }, { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -209,3 +209,41 @@ test(\"Permalink with pagination variables (numeric, one indexed)\", async t => {\nt.falsy(page1Data.pagination.nextPageLink);\nt.is(page1Data.pagination.pageLinks.length, 2);\n});\n+\n+test(\"Alias to page data\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedalias.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getTemplates();\n+\n+ t.is(await pages[0].getOutputPath(), \"./dist/pagedalias/item1/index.html\");\n+ t.is(await pages[1].getOutputPath(), \"./dist/pagedalias/item2/index.html\");\n+\n+ t.is((await pages[0].render()).trim(), \"item1\");\n+ t.is((await pages[1].render()).trim(), \"item2\");\n+});\n+\n+test(\"Alias to page data (size 2)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedaliassize2.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getTemplates();\n+\n+ t.is(await pages[0].getOutputPath(), \"./dist/pagedalias/item1/index.html\");\n+ t.is(await pages[1].getOutputPath(), \"./dist/pagedalias/item3/index.html\");\n+\n+ t.is((await pages[0].render()).trim(), \"item1\");\n+ t.is((await pages[1].render()).trim(), \"item3\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/pagedalias.njk", "diff": "+---\n+pagination:\n+ data: items\n+ size: 1\n+ alias: font.test\n+items:\n+ - item1\n+ - item2\n+permalink: pagedalias/{{ font.test }}/index.html\n+---\n+{{ font.test }}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/pagedaliassize2.njk", "diff": "+---\n+pagination:\n+ data: items\n+ size: 2\n+ alias: font.test\n+items:\n+ - item1\n+ - item2\n+ - item3\n+ - item4\n+permalink: pagedalias/{{ font.test[0] }}/index.html\n+---\n+{{ font.test[0] }}\n" } ]
JavaScript
MIT License
11ty/eleventy
Pagination variable aliasing.
699
28.12.2017 23:14:03
21,600
a701be0293a69cd5626fe456b9e80e1f18b39abe
Run write once when starting to watch
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -14,7 +14,7 @@ eleven.setIsVerbose(!argv.quiet);\n} else if (argv.help) {\nconsole.log(eleven.getHelp());\n} else if (argv.watch) {\n- eleven.watch();\n+ await eleven.watch();\n} else {\nawait eleven.write();\nconsole.log(eleven.getFinishedLog());\n" } ]
JavaScript
MIT License
11ty/eleventy
Run write once when starting to watch
699
28.12.2017 23:19:00
21,600
d5be147fb7914309aa452ea3960c3806f0c52de5
Remove default pretty html printer, moves into `filters` configuration.
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -121,7 +121,7 @@ module.exports = {\n```\n| Configuration Option Key | Default Option | Valid Options | Command Line Override | Description |\n-| ------------------------ | ------------------------------------------------- | -------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |\n+| ------------------------ | ------------------------------------------------- | -------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `dir.input` | `.` | _Any valid directory._ | `--input` | Controls the top level directory inside which the templates should be found. |\n| `dir.includes` | `_includes` | _Any valid directory inside of `dir.input`._ | N/A | Controls the directory inside which the template includes/extends/partials/etc can be found. |\n| `dir.data` | `_data` | _Any valid directory inside of `dir.input`._ | N/A | Controls the directory inside which the global data template files, available to all templates, can be found. |\n@@ -131,6 +131,7 @@ module.exports = {\n| `htmlTemplateEngine` | `liquid` | _A valid template engine_ or `false` | N/A | Run HTML templates through this template engine before transforming it to (better) HTML. |\n| `templateFormats` | `liquid,ejs, md,hbs, mustache,haml, pug,njk,html` | _Any combination of these_ | `--formats` | Specify which type of templates should be transformed. |\n| `htmlOutputSuffix` | `-o` | `String` | N/A | If the input and output directory match, `index.html` files will have this suffix added to their output filename to prevent overwriting the template. |\n+| `filters` | `{}` | `Object` | N/A | Filters can transform output on a template. Take the format `function(str, outputPath) { return str; }`. For example, use a filter to format an HTML file with proper whitespace. |\n| `handlebarsHelpers` | `{}` | `Object` | N/A | The helper functions passed to `Handlebars.registerHelper`. Helper names are keys, functions are the values. |\n| `nunjucksFilters` | `{}` | `Object` | N/A | The helper functions passed to `nunjucksEnv.addFilter`. Helper names are keys, functions are the values. |\n" }, { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -29,6 +29,7 @@ module.exports = {\ndata: \"_data\",\noutput: \"_site\"\n},\n+ filters: {},\nhandlebarsHelpers: {},\nnunjucksFilters: {\nslug: str => {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "playground/pretty.html", "diff": "+<!doctype html>\n+<html lang=\"en\"><head></head><body></body></html>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -66,6 +66,7 @@ Template.prototype.setExtraOutputSubdirectory = function(dir) {\nthis.extraOutputSubdirectory = dir + \"/\";\n};\n+// TODO instead of isHTMLIOException, do a global search to check if output path = input path and then add extra suffix\nTemplate.prototype.getOutputLink = async function() {\nlet permalink = this.getFrontMatterData()[cfg.keys.permalink];\nif (permalink) {\n@@ -239,9 +240,10 @@ Template.prototype.addFilter = function(callback) {\nthis.filters.push(callback);\n};\n-Template.prototype.runFilters = function(str) {\n+Template.prototype.runFilters = async function(str) {\n+ let outputPath = await this.getOutputPath();\nthis.filters.forEach(function(filter) {\n- str = filter.call(this, str);\n+ str = filter.call(this, str, outputPath);\n});\nreturn str;\n@@ -287,7 +289,7 @@ Template.prototype.write = async function() {\nlet pluginRet = await this.runPlugins(data);\nif (pluginRet) {\nlet str = await this.render(data);\n- let filtered = this.runFilters(str);\n+ let filtered = await this.runFilters(str);\nawait pify(fs.outputFile)(outputPath, filtered);\nif (this.isVerbose) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "const globby = require(\"globby\");\nconst normalize = require(\"normalize-path\");\n-const pretty = require(\"pretty\");\nconst fs = require(\"fs-extra\");\nconst Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\n@@ -109,9 +108,18 @@ TemplateWriter.prototype._getTemplate = function(path) {\ntmpl.setIsVerbose(this.isVerbose);\n- tmpl.addFilter(function(str) {\n- return pretty(str, { ocd: true });\n- });\n+ /*\n+ * Sample filter: arg str, return pretty HTML string\n+ * function(str) {\n+ * return pretty(str, { ocd: true });\n+ * }\n+ */\n+ for (let filterName in cfg.filters) {\n+ let filter = cfg.filters[filterName];\n+ if (typeof filter === \"function\") {\n+ tmpl.addFilter(filter);\n+ }\n+ }\nlet writer = this;\ntmpl.addPlugin(\"pagination\", async function(data) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "@@ -16,4 +16,15 @@ test(\"Template Config local config overrides base config\", async t => {\nt.is(Object.keys(cfg.handlebarsHelpers).length, 0);\nt.is(Object.keys(cfg.nunjucksFilters).length, 2);\n+\n+ t.true(Object.keys(cfg.filters).length >= 1);\n+\n+ t.is(\n+ cfg.filters.prettyHtml(`<html><body><div></div></body></html>`),\n+ `<html>\n+ <body>\n+ <div></div>\n+ </body>\n+</html>`\n+ );\n});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/config.js", "new_path": "test/stubs/config.js", "diff": "+const pretty = require(\"pretty\");\n+\nmodule.exports = {\nmarkdownTemplateEngine: \"ejs\",\ntemplateFormats: [\"md\", \"njk\"],\nkeys: {\npackage: \"pkg2\"\n},\n+ filters: {\n+ prettyHtml: function(str, outputPath) {\n+ // todo check if HTML output before transforming\n+ return pretty(str, { ocd: true });\n+ }\n+ },\nnunjucksFilters: {\ntesting: str => {\nreturn str;\n" } ]
JavaScript
MIT License
11ty/eleventy
Remove default pretty html printer, moves into `filters` configuration.
699
28.12.2017 23:58:53
21,600
9ef53b0e33ed2190d0e1b9cc0280a2cd3286d1f8
Allow config.dir.data to be the same as the config.dir.input (by use "." or "")
[ { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -45,7 +45,10 @@ TemplateData.prototype.getGlobalDataGlob = async function() {\ndir = this.globalDataPath;\n}\n- return TemplatePath.normalize(dir, \"/\", cfg.dir.data) + \"/**/*.json\";\n+ return (\n+ TemplatePath.normalize(dir, \"/\", cfg.dir.data !== \".\" ? cfg.dir.data : \"\") +\n+ \"/**/*.json\"\n+ );\n};\nTemplateData.prototype.getGlobalDataFiles = async function() {\n@@ -55,7 +58,7 @@ TemplateData.prototype.getGlobalDataFiles = async function() {\nTemplateData.prototype.getObjectPathForDataFile = function(path) {\nlet reducedPath = TemplatePath.stripPathFromDir(\npath,\n- this.globalDataPath + \"/\" + cfg.dir.data\n+ this.globalDataPath + \"/\" + (cfg.dir.data !== \".\" ? cfg.dir.data : \"\")\n);\nlet parsed = parsePath(reducedPath);\nlet folders = parsed.dir ? parsed.dir.split(\"/\") : [];\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -91,7 +91,7 @@ TemplateWriter.prototype.addWritingIgnores = function(baseDir, files) {\n\"!\" + normalize(baseDir + \"/\" + cfg.dir.includes + \"/**\")\n);\n}\n- if (cfg.dir.data) {\n+ if (cfg.dir.data && cfg.dir.data !== \".\") {\nfiles = files.concat(\"!\" + normalize(baseDir + \"/\" + cfg.dir.data + \"/**\"));\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Allow config.dir.data to be the same as the config.dir.input (by use "." or "")
699
29.12.2017 21:26:29
21,600
650a5ef2d60cbe9ce602bf2c602d06ec4317bc0f
Okay, this should actually fix Move off of my custom fork of ejs.
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "},\n\"dependencies\": {\n\"chalk\": \"^2.3.0\",\n- \"ejs\": \"git+https://github.com/zachleat/ejs.git#v2.5.7-h1\",\n+ \"ejs\": \"^2.5.7\",\n\"fs-extra\": \"^4.0.2\",\n\"glob-watcher\": \"^4.0.0\",\n\"globby\": \"^7.1.1\",\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Ejs.js", "new_path": "src/Engines/Ejs.js", "diff": "@@ -5,7 +5,8 @@ class Ejs extends TemplateEngine {\nasync compile(str) {\nlet fn = ejsLib.compile(str, {\nroot: \"./\" + super.getInputDir(),\n- compileDebug: true\n+ compileDebug: true,\n+ filename: \"./\" + super.getInputDir()\n});\nreturn function(data) {\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "-const ejs = require(\"ejs\");\nconst pify = require(\"pify\");\nconst fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderTest.js", "new_path": "test/TemplateRenderTest.js", "diff": "@@ -90,7 +90,7 @@ test(\"EJS Render\", async t => {\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n});\n-test(\"EJS Render Include\", async t => {\n+test(\"EJS Render Include Preprocessor Directive\", async t => {\nt.is(path.resolve(undefined, \"/included\"), \"/included\");\nlet fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n@@ -99,6 +99,13 @@ test(\"EJS Render Include\", async t => {\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n+test(\"EJS Render Include, New Style no Data\", async t => {\n+ let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+ \"<p><%- include('/included') %></p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\ntest(\"EJS Render Include, New Style\", async t => {\nlet fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n\"<p><%- include('/included', {}) %></p>\"\n@@ -113,6 +120,22 @@ test(\"EJS Render Include, New Style with Data\", async t => {\nt.is(await fn(), \"<p>This is an Bill.</p>\");\n});\n+// test(\"EJS Render Include Preprocessor Directive Relative\", async t => {\n+\n+// let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+// \"<p><% include included %></p>\"\n+// );\n+// t.is(await fn(), \"<p>This is an include.</p>\");\n+// });\n+\n+// test(\"EJS Render Include, Relative Path New Style\", async t => {\n+// let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+// \"<p><%- include('stubs/includedrelative', {}) %></p>\"\n+// );\n+\n+// t.is(await fn(), \"<p>This is a relative include.</p>\");\n+// });\n+\n// Markdown\ntest(\"Markdown\", t => {\nt.is(new TemplateRender(\"md\").getEngineName(), \"md\");\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/includedrelative.ejs", "diff": "+This is a relative include.\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Okay, this should actually fix #14. Move off of my custom fork of ejs.
699
30.12.2017 13:30:06
21,600
08aea17abf2f4bce8f839febf57a1190c097d30f
Flag in readme for
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -165,6 +165,8 @@ Here are the features tested with each template engine that use external files a\n## Tests\n+Build Status: [![Build Status](https://travis-ci.org/zachleat/eleventy.svg?branch=master)](https://travis-ci.org/zachleat/eleventy)\n+\n```\nnpm run test\nnpm run watch:test\n" } ]
JavaScript
MIT License
11ty/eleventy
Flag in readme for #15
699
03.01.2018 07:03:30
21,600
e17cf3afbb7aec02b7a639f8ff6457a343dfa181
Renames to Layout to `TemplateLayout` for consistency.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -7,7 +7,7 @@ const _isObject = require(\"lodash.isobject\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\n-const Layout = require(\"./Layout\");\n+const Layout = require(\"./TemplateLayout\");\nconst TemplateConfig = require(\"./TemplateConfig\");\nconst Eleventy = require(\"./Eleventy\");\n" }, { "change_type": "RENAME", "old_path": "src/Layout.js", "new_path": "src/TemplateLayout.js", "diff": "@@ -3,22 +3,25 @@ const fs = require(\"fs-extra\");\nlet cfg = TemplateConfig.getDefaultConfig();\n-function Layout(name, dir) {\n+function TemplateLayout(name, dir) {\nthis.dir = dir;\nthis.name = name;\nthis.filename = this.findFileName();\nthis.fullPath = this.dir + \"/\" + this.filename;\n}\n-Layout.prototype.getFullPath = function() {\n+TemplateLayout.prototype.getFullPath = function() {\nreturn this.fullPath;\n};\n-Layout.prototype.findFileName = function() {\n+TemplateLayout.prototype.findFileName = function() {\nlet file;\nif (!fs.existsSync(this.dir)) {\nthrow Error(\n- \"Layout directory does not exist for \" + this.name + \": \" + this.dir\n+ \"TemplateLayout directory does not exist for \" +\n+ this.name +\n+ \": \" +\n+ this.dir\n);\n}\ncfg.templateFormats.forEach(\n@@ -33,4 +36,4 @@ Layout.prototype.findFileName = function() {\nreturn file;\n};\n-module.exports = Layout;\n+module.exports = TemplateLayout;\n" }, { "change_type": "RENAME", "old_path": "test/LayoutTest.js", "new_path": "test/TemplateLayoutTest.js", "diff": "import test from \"ava\";\n-import Layout from \"../src/Layout\";\n+import Layout from \"../src/TemplateLayout\";\ntest(t => {\nt.is(new Layout(\"default\", \"./test/stubs\").findFileName(), \"default.ejs\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Renames to Layout to `TemplateLayout` for consistency.
699
03.01.2018 20:19:46
21,600
64fd98bebc6e20633e9fb6adaa19a41baf7b4386
Now relies exclusively on .eleventyignore for ignoring files. Underscore files get processed. Underscore ignores are unintuitive and confusing, per my experience and comments on Reversal of and closes
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -9,6 +9,7 @@ const TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\nconst Layout = require(\"./TemplateLayout\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n+const Collection = require(\"./TemplateCollection\");\nconst Eleventy = require(\"./Eleventy\");\nlet cfg = TemplateConfig.getDefaultConfig();\n@@ -102,7 +103,7 @@ Template.prototype.setDataOverrides = function(overrides) {\n};\nTemplate.prototype.isIgnored = function() {\n- return this.parsed.name.match(/^\\_/) !== null || this.outputDir === false;\n+ return this.outputDir === false;\n};\nTemplate.prototype.getMatter = function() {\n@@ -176,6 +177,28 @@ Template.prototype.mapDataAsRenderedTemplates = async function(\nreturn data;\n};\n+Template.prototype._getCollectionLinks = async function(files) {\n+ // TODO start here this is going to be expensive\n+ return files.map(function() {\n+ return \"\";\n+ });\n+};\n+\n+Template.prototype.getCollectionData = async function() {\n+ let c = new Collection(this.inputPath);\n+ let files = await c.getSortedFiles();\n+ let links = this._getCollectionLinks(files);\n+ let index = c.getTemplatePathIndex(files);\n+\n+ return {\n+ collection: {\n+ links: links,\n+ next: index < links.length - 1 ? links[index + 1] : null,\n+ previous: index > 0 ? links[index - 1] : null\n+ }\n+ };\n+};\n+\nTemplate.prototype.getData = async function(localData) {\nlet data = {};\n@@ -183,6 +206,8 @@ Template.prototype.getData = async function(localData) {\ndata = await this.templateData.getLocalData(this.getLocalDataPath());\n}\n+ // data.collection =\n+\nlet mergedLocalData = Object.assign({}, localData, this.dataOverrides);\nlet frontMatterData = this.getFrontMatterData();\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -64,15 +64,6 @@ test(\"subfolder outputs to double subfolder\", async t => {\nt.is(await tmpl.getOutputPath(), \"./dist/subfolder/subfolder/index.html\");\n});\n-test(\"ignored files start with an underscore\", t => {\n- let tmpl = new Template(\n- \"./test/stubs/_ignored.ejs\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- t.is(tmpl.isIgnored(), true);\n-});\n-\ntest(\"HTML files output to the same as the input directory have a file suffix added (only if index, this is not index).\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/testing.html\",\n" }, { "change_type": "DELETE", "old_path": "test/stubs/_ignored.ejs", "new_path": "test/stubs/_ignored.ejs", "diff": "" } ]
JavaScript
MIT License
11ty/eleventy
Now relies exclusively on .eleventyignore for ignoring files. Underscore files get processed. Underscore ignores are unintuitive and confusing, per my experience and comments on https://github.com/jekyll/jekyll/issues/55 Reversal of and closes #18
699
03.01.2018 20:45:26
21,600
ea39e5af1373e7268e11ccae8653180e0f60fbf2
Start of collections
[ { "change_type": "ADD", "old_path": null, "new_path": "docs/collections.md", "diff": "+# Collections\n+\n+While [pagination](pagination.md) allows you do iterate over a data set to create multiple templates, a collection allows you to group content in interesting ways. By default, content is grouped by directory structure.\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -117,9 +117,18 @@ Pagination.prototype.getTemplates = async function() {\nfunction(cloned, pageNumber) {\noverrides[pageNumber].pagination.previousPageLink =\npageNumber > 0 ? links[pageNumber - 1] : null;\n+ overrides[pageNumber].pagination.previous =\n+ overrides[pageNumber].pagination.previousPageLink;\n+\noverrides[pageNumber].pagination.nextPageLink =\npageNumber < templates.length - 1 ? links[pageNumber + 1] : null;\n+ overrides[pageNumber].pagination.next =\n+ overrides[pageNumber].pagination.nextPageLink;\n+\n+ overrides[pageNumber].pagination.links = links;\n+ // todo deprecated, consistency with collections and use links instead\noverrides[pageNumber].pagination.pageLinks = links;\n+\ncloned.setDataOverrides(overrides[pageNumber]);\npages.push(cloned);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/TemplateCollection.js", "diff": "+const globby = require(\"globby\");\n+const parsePath = require(\"parse-filepath\");\n+const Path = require(\"./TemplatePath\");\n+const Sortable = require(\"./Util/Sortable\");\n+\n+class TemplateCollection extends Sortable {\n+ constructor(templatePath) {\n+ super();\n+ this.globSelector = null;\n+ this.templatePath = templatePath;\n+\n+ if (templatePath) {\n+ this.setDefaultGlobFromTemplatePath(templatePath);\n+ }\n+ }\n+\n+ setDefaultGlobFromTemplatePath(path) {\n+ let parsed = parsePath(path);\n+ this.globSelector = parsed.dir + \"/*\";\n+ }\n+\n+ setGlob(glob) {\n+ this.globSelector = glob;\n+ }\n+\n+ getTemplatePathIndex(files) {\n+ if (!this.templatePath) {\n+ return -1;\n+ }\n+\n+ return (files || []).indexOf(this.templatePath);\n+ }\n+\n+ async getSortedFiles() {\n+ let files = await this.getFiles();\n+ let sortFn = this.getSortFunction();\n+ return files.sort(sortFn);\n+ }\n+\n+ async getFiles() {\n+ if (!this.globSelector) {\n+ throw new Error(\n+ \"TemplateCollection->getFiles() requires you to `setGlob` first.\"\n+ );\n+ }\n+\n+ return globby(this.globSelector, { gitignore: true });\n+ }\n+}\n+module.exports = TemplateCollection;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Util/Sortable.js", "diff": "+class Sortable {\n+ constructor() {\n+ this.sortAscending = true;\n+ this.sortNumeric = false;\n+ }\n+\n+ isSortAscending() {\n+ return this.sortAscending;\n+ }\n+\n+ isSortNumeric() {\n+ return this.sortNumeric;\n+ }\n+\n+ setSortAscending(isAscending) {\n+ this.sortAscending = isAscending;\n+ }\n+\n+ setSortNumeric(isNumeric) {\n+ this.sortNumeric = isNumeric;\n+ }\n+\n+ static sortNumericAscending(a, b) {\n+ return a - b;\n+ }\n+\n+ static sortNumericDescending(a, b) {\n+ return b - a;\n+ }\n+\n+ static sortAlphabeticAscending(a, b) {\n+ if (a > b) {\n+ return 1;\n+ } else if (a < b) {\n+ return -1;\n+ }\n+ return 0;\n+ }\n+\n+ static sortAlphabeticDescending(a, b) {\n+ if (a > b) {\n+ return -1;\n+ } else if (a < b) {\n+ return 1;\n+ }\n+ return 0;\n+ }\n+\n+ getSortFunction() {\n+ if (this.sortNumeric) {\n+ if (this.sortAscending) {\n+ return Sortable.sortNumericAscending;\n+ } else {\n+ return Sortable.sortNumericDescending;\n+ }\n+ } else {\n+ if (this.sortAscending) {\n+ return Sortable.sortAlphabeticAscending;\n+ } else {\n+ return Sortable.sortAlphabeticDescending;\n+ }\n+ }\n+ }\n+}\n+\n+module.exports = Sortable;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateCollectionTest.js", "diff": "+import test from \"ava\";\n+import Collection from \"../src/TemplateCollection\";\n+// import Path from \"../src/TemplatePath\";\n+\n+test(\"Basic setup\", t => {\n+ let c = new Collection();\n+ t.is(c.isSortAscending(), true);\n+ t.is(c.isSortNumeric(), false);\n+});\n+\n+test(\"Files without a glob selector throws error\", async t => {\n+ let c = new Collection();\n+ await t.throws(c.getFiles());\n+});\n+\n+test(\"getFiles\", async t => {\n+ let c = new Collection();\n+ c.setGlob(\"./test/stubs/_collection/*.md\");\n+\n+ let files = await c.getFiles();\n+ t.is(files.length, 3);\n+ t.is(files[0], \"./test/stubs/_collection/test1.md\");\n+ t.is(files[1], \"./test/stubs/_collection/test2.md\");\n+ t.is(files[2], \"./test/stubs/_collection/test3.md\");\n+});\n+\n+test(\"sort functions ascending strings\", t => {\n+ let c = new Collection();\n+ t.deepEqual([\"z\", \"x\", \"a\"].sort(c.getSortFunction()), [\"a\", \"x\", \"z\"]);\n+});\n+\n+test(\"sort functions descending strings\", t => {\n+ let c = new Collection();\n+ c.setSortAscending(false);\n+ t.deepEqual([\"z\", \"g\", \"x\", \"a\"].sort(c.getSortFunction()), [\n+ \"z\",\n+ \"x\",\n+ \"g\",\n+ \"a\"\n+ ]);\n+});\n+\n+test(\"sort functions ascending numbers\", t => {\n+ let c = new Collection();\n+ c.setSortNumeric(true);\n+ t.deepEqual([1, 4, 2, 9, 11, 3].sort(c.getSortFunction()), [\n+ 1,\n+ 2,\n+ 3,\n+ 4,\n+ 9,\n+ 11\n+ ]);\n+});\n+\n+test(\"sort functions descending numbers\", t => {\n+ let c = new Collection();\n+ c.setSortNumeric(true);\n+ c.setSortAscending(false);\n+ t.deepEqual([1, 4, 2, 9, 11, 3].sort(c.getSortFunction()), [\n+ 11,\n+ 9,\n+ 4,\n+ 3,\n+ 2,\n+ 1\n+ ]);\n+});\n+\n+test(\"getSortedFiles ascending\", async t => {\n+ let c = new Collection();\n+ c.setGlob(\"./test/stubs/_collection/*.md\");\n+\n+ let files = await c.getSortedFiles();\n+ t.is(files.length, 3);\n+ t.is(files[0], \"./test/stubs/_collection/test1.md\");\n+ t.is(files[1], \"./test/stubs/_collection/test2.md\");\n+ t.is(files[2], \"./test/stubs/_collection/test3.md\");\n+});\n+\n+test(\"getSortedFiles descending\", async t => {\n+ let c = new Collection();\n+ c.setGlob(\"./test/stubs/_collection/*.md\");\n+ c.setSortAscending(false);\n+\n+ let files = await c.getSortedFiles();\n+ t.is(files.length, 3);\n+ t.is(files[0], \"./test/stubs/_collection/test3.md\");\n+ t.is(files[1], \"./test/stubs/_collection/test2.md\");\n+ t.is(files[2], \"./test/stubs/_collection/test1.md\");\n+});\n+\n+test(\"setDefaultGlobFromTemplatePath\", async t => {\n+ let c = new Collection();\n+ c.setDefaultGlobFromTemplatePath(\"./test/stubs/_collection/test2.md\");\n+\n+ let files = await c.getFiles();\n+ t.is(files.length, 3);\n+ t.is(files[0], \"./test/stubs/_collection/test1.md\");\n+ t.is(files[1], \"./test/stubs/_collection/test2.md\");\n+ t.is(files[2], \"./test/stubs/_collection/test3.md\");\n+});\n+\n+test(\"setDefaultGlobFromTemplatePath constructor\", async t => {\n+ let c = new Collection(\"./test/stubs/_collection/test2.md\");\n+\n+ let files = await c.getFiles();\n+ t.is(files.length, 3);\n+ t.is(files[0], \"./test/stubs/_collection/test1.md\");\n+ t.is(files[1], \"./test/stubs/_collection/test2.md\");\n+ t.is(files[2], \"./test/stubs/_collection/test3.md\");\n+});\n+\n+test(\"getTemplatePathIndex (middle)\", async t => {\n+ let c = new Collection(\"./test/stubs/_collection/test2.md\");\n+\n+ let files = await c.getSortedFiles();\n+ t.is(c.getTemplatePathIndex(files), 1);\n+});\n+\n+test(\"getTemplatePathIndex (last)\", async t => {\n+ let c = new Collection(\"./test/stubs/_collection/test3.md\");\n+\n+ let files = await c.getSortedFiles();\n+ t.is(c.getTemplatePathIndex(files), 2);\n+});\n+\n+test(\"getTemplatePathIndex (first, descending)\", async t => {\n+ let c = new Collection(\"./test/stubs/_collection/test3.md\");\n+ c.setSortAscending(false);\n+\n+ let files = await c.getSortedFiles();\n+ t.is(c.getTemplatePathIndex(files), 0);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/_collection/test1.md", "diff": "+# Test 1\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/_collection/test2.md", "diff": "+# Test 2\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/_collection/test3.md", "diff": "+# Test 3\n" } ]
JavaScript
MIT License
11ty/eleventy
Start of collections
699
04.01.2018 08:01:39
21,600
c0da554770eedf6de73a69d02c4b9e7e1f74b3a0
Switch to class syntax
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -9,12 +9,12 @@ const TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\nconst Layout = require(\"./TemplateLayout\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n-const Collection = require(\"./TemplateCollection\");\nconst Eleventy = require(\"./Eleventy\");\nlet cfg = TemplateConfig.getDefaultConfig();\n-function Template(path, inputDir, outputDir, templateData) {\n+class Template {\n+ constructor(path, inputDir, outputDir, templateData) {\nthis.inputPath = path;\nthis.inputContent = fs.readFileSync(path, \"utf-8\");\nthis.parsed = parsePath(path);\n@@ -53,20 +53,20 @@ function Template(path, inputDir, outputDir, templateData) {\nthis.writeCount = 0;\n}\n-Template.prototype.setIsVerbose = function(isVerbose) {\n+ setIsVerbose(isVerbose) {\nthis.isVerbose = isVerbose;\n-};\n+ }\n-Template.prototype.getTemplateSubfolder = function() {\n+ getTemplateSubfolder() {\nreturn TemplatePath.stripPathFromDir(this.parsed.dir, this.inputDir);\n-};\n+ }\n-Template.prototype.setExtraOutputSubdirectory = function(dir) {\n+ setExtraOutputSubdirectory(dir) {\nthis.extraOutputSubdirectory = dir + \"/\";\n-};\n+ }\n// TODO instead of isHTMLIOException, do a global search to check if output path = input path and then add extra suffix\n-Template.prototype.getOutputLink = async function() {\n+ async getOutputLink() {\nlet permalink = this.getFrontMatterData()[cfg.keys.permalink];\nif (permalink) {\nlet data = await this.getData();\n@@ -86,48 +86,44 @@ Template.prototype.getOutputLink = async function() {\nthis.extraOutputSubdirectory,\nthis.isHtmlIOException ? cfg.htmlOutputSuffix : \"\"\n).toString();\n-};\n+ }\n// TODO check for conflicts, see if file already exists?\n-Template.prototype.getOutputPath = async function() {\n+ async getOutputPath() {\nlet uri = await this.getOutputLink();\nif (this.getFrontMatterData()[cfg.keys.permalinkRoot]) {\nreturn normalize(uri);\n} else {\nreturn normalize(this.outputDir + \"/\" + uri);\n}\n-};\n+ }\n-Template.prototype.setDataOverrides = function(overrides) {\n+ setDataOverrides(overrides) {\nthis.dataOverrides = overrides;\n-};\n+ }\n-Template.prototype.isIgnored = function() {\n+ isIgnored() {\nreturn this.outputDir === false;\n-};\n+ }\n-Template.prototype.getMatter = function() {\n+ getMatter() {\nreturn matter(this.inputContent);\n-};\n+ }\n-Template.prototype.getPreRender = function() {\n+ getPreRender() {\nreturn this.frontMatter.content;\n-};\n+ }\n-Template.prototype.getLayoutTemplate = function(name) {\n+ getLayoutTemplate(name) {\nlet path = new Layout(name, this.layoutsDir).getFullPath();\nreturn new Template(path, this.inputDir, this.outputDir);\n-};\n+ }\n-Template.prototype.getFrontMatterData = function() {\n+ getFrontMatterData() {\nreturn this.frontMatter.data || {};\n-};\n+ }\n-Template.prototype.getAllLayoutFrontMatterData = async function(\n- tmpl,\n- data,\n- merged\n-) {\n+ async getAllLayoutFrontMatterData(tmpl, data, merged) {\nif (!merged) {\nmerged = data;\n}\n@@ -144,16 +140,13 @@ Template.prototype.getAllLayoutFrontMatterData = async function(\n}\nreturn merged;\n-};\n+ }\n-Template.prototype.getLocalDataPath = function() {\n+ getLocalDataPath() {\nreturn this.parsed.dir + \"/\" + this.parsed.name + \".json\";\n-};\n+ }\n-Template.prototype.mapDataAsRenderedTemplates = async function(\n- data,\n- templateData\n-) {\n+ async mapDataAsRenderedTemplates(data, templateData) {\nif (Array.isArray(data)) {\nlet arr = [];\nfor (let j = 0, k = data.length; j < k; j++) {\n@@ -175,39 +168,15 @@ Template.prototype.mapDataAsRenderedTemplates = async function(\n}\nreturn data;\n-};\n-\n-Template.prototype._getCollectionLinks = async function(files) {\n- // TODO start here this is going to be expensive\n- return files.map(function() {\n- return \"\";\n- });\n-};\n-\n-Template.prototype.getCollectionData = async function() {\n- let c = new Collection(this.inputPath);\n- let files = await c.getSortedFiles();\n- let links = this._getCollectionLinks(files);\n- let index = c.getTemplatePathIndex(files);\n-\n- return {\n- collection: {\n- links: links,\n- next: index < links.length - 1 ? links[index + 1] : null,\n- previous: index > 0 ? links[index - 1] : null\n}\n- };\n-};\n-Template.prototype.getData = async function(localData) {\n+ async getData(localData) {\nlet data = {};\nif (this.templateData) {\ndata = await this.templateData.getLocalData(this.getLocalDataPath());\n}\n- // data.collection =\n-\nlet mergedLocalData = Object.assign({}, localData, this.dataOverrides);\nlet frontMatterData = this.getFrontMatterData();\n@@ -218,9 +187,9 @@ Template.prototype.getData = async function(localData) {\n);\nreturn Object.assign({}, data, mergedLayoutData, mergedLocalData);\n-};\n+ }\n-Template.prototype.renderLayout = async function(tmpl, tmplData) {\n+ async renderLayout(tmpl, tmplData) {\nlet layoutName = tmplData[cfg.keys.layout];\n// TODO make layout key to be available to templates (without it causing issues with merge below)\ndelete tmplData[cfg.keys.layout];\n@@ -239,18 +208,18 @@ Template.prototype.renderLayout = async function(tmpl, tmplData) {\n}\nreturn layout.renderContent(layout.getPreRender(), layoutData);\n-};\n+ }\n-Template.prototype.getCompiledPromise = async function() {\n+ async getCompiledPromise() {\nreturn this.templateRender.getCompiledTemplate(this.getPreRender());\n-};\n+ }\n-Template.prototype.renderContent = async function(str, data, options) {\n+ async renderContent(str, data, options) {\nlet fn = await this.templateRender.getCompiledTemplate(str, options);\nreturn fn(data);\n-};\n+ }\n-Template.prototype.render = async function(data) {\n+ async render(data) {\nif (!data) {\ndata = await this.getData();\n}\n@@ -260,30 +229,30 @@ Template.prototype.render = async function(data) {\n} else {\nreturn this.renderContent(this.getPreRender(), data);\n}\n-};\n+ }\n-Template.prototype.addFilter = function(callback) {\n+ addFilter(callback) {\nthis.filters.push(callback);\n-};\n+ }\n-Template.prototype.runFilters = async function(str) {\n+ async runFilters(str) {\nlet outputPath = await this.getOutputPath();\nthis.filters.forEach(function(filter) {\nstr = filter.call(this, str, outputPath);\n});\nreturn str;\n-};\n+ }\n-Template.prototype.addPlugin = function(key, callback) {\n+ addPlugin(key, callback) {\nthis.plugins[key] = callback;\n-};\n+ }\n-Template.prototype.removePlugin = function(key) {\n+ removePlugin(key) {\ndelete this.plugins[key];\n-};\n+ }\n-Template.prototype.runPlugins = async function(data) {\n+ async runPlugins(data) {\nlet ret = true;\nfor (let key in this.plugins) {\nlet pluginRet = await this.plugins[key].call(this, data);\n@@ -293,9 +262,9 @@ Template.prototype.runPlugins = async function(data) {\n}\nreturn ret;\n-};\n+ }\n-Template.prototype.write = async function() {\n+ async write() {\nlet outputPath = await this.getOutputPath();\nif (this.isIgnored()) {\nif (this.isVerbose) {\n@@ -323,9 +292,9 @@ Template.prototype.write = async function() {\n}\n}\n}\n-};\n+ }\n-Template.prototype.clone = function() {\n+ clone() {\n// TODO better clone\nvar tmpl = new Template(\nthis.inputPath,\n@@ -335,10 +304,11 @@ Template.prototype.clone = function() {\n);\ntmpl.setIsVerbose(this.isVerbose);\nreturn tmpl;\n-};\n+ }\n-Template.prototype.getWriteCount = function() {\n+ getWriteCount() {\nreturn this.writeCount;\n-};\n+ }\n+}\nmodule.exports = Template;\n" } ]
JavaScript
MIT License
11ty/eleventy
Switch to class syntax
699
04.01.2018 08:19:55
21,600
3476284f9f0f2116632c256db66de2aad6602891
Surely it was not I that used var instead of let
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -6,7 +6,7 @@ class JavaScript extends TemplateEngine {\nreturn function(data) {\n// avoid `with`\nlet dataStr = \"\";\n- for (var j in data) {\n+ for (let j in data) {\ndataStr += `let ${j} = ${JSON.stringify(data[j])};\\n`;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Markdown.js", "new_path": "src/Engines/Markdown.js", "diff": "@@ -4,7 +4,7 @@ const TemplateEngine = require(\"./TemplateEngine\");\nclass Markdown extends TemplateEngine {\nasync compile(str, preTemplateEngine, bypassMarkdown) {\nif (preTemplateEngine) {\n- var engine = TemplateEngine.getEngine(\n+ let engine = TemplateEngine.getEngine(\npreTemplateEngine,\nsuper.getInputDir()\n);\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -26,7 +26,7 @@ class TemplateEngine {\nlet partialFiles = this.inputDir\n? globby.sync(this.inputDir + \"/*\" + this.extension)\n: [];\n- for (var j = 0, k = partialFiles.length; j < k; j++) {\n+ for (let j = 0, k = partialFiles.length; j < k; j++) {\nlet key = parsePath(partialFiles[j]).name;\npartials[key] = fs.readFileSync(partialFiles[j], \"utf-8\");\n}\n@@ -34,7 +34,7 @@ class TemplateEngine {\n}\nasync render(str, data) {\n- var fn = await this.compile(str);\n+ let fn = await this.compile(str);\nreturn fn(data);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -78,7 +78,7 @@ Pagination.prototype.getTemplates = async function() {\nlet links = [];\nlet overrides = [];\n- for (var pageNumber = 0, k = items.length; pageNumber < k; pageNumber++) {\n+ for (let pageNumber = 0, k = items.length; pageNumber < k; pageNumber++) {\nlet chunk = items[pageNumber];\nlet cloned = tmpl.clone();\n// TODO maybe also move this permalink additions up into the pagination class\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -71,7 +71,7 @@ TemplateData.prototype.getAllGlobalData = async function() {\nlet globalData = {};\nlet files = await this.getGlobalDataFiles();\n- for (var j = 0, k = files.length; j < k; j++) {\n+ for (let j = 0, k = files.length; j < k; j++) {\nlet folders = await this.getObjectPathForDataFile(files[j]);\nlet data = await this.getJson(files[j], this.rawImports);\nlodashset(globalData, folders, data);\n" } ]
JavaScript
MIT License
11ty/eleventy
Surely it was not I that used var instead of let
699
04.01.2018 08:24:01
21,600
009999481cb311bbb8d9347ca464d9fe62f2796c
Adds `renderData` front matter test
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -189,6 +189,17 @@ class Template {\nreturn Object.assign({}, data, mergedLayoutData, mergedLocalData);\n}\n+ async getRenderedData() {\n+ let data = await this.getData();\n+ if (data.renderData) {\n+ data.renderData = await this.mapDataAsRenderedTemplates(\n+ data.renderData,\n+ data\n+ );\n+ }\n+ return data;\n+ }\n+\nasync renderLayout(tmpl, tmplData) {\nlet layoutName = tmplData[cfg.keys.layout];\n// TODO make layout key to be available to templates (without it causing issues with merge below)\n@@ -221,7 +232,7 @@ class Template {\nasync render(data) {\nif (!data) {\n- data = await this.getData();\n+ data = await this.getRenderedData();\n}\nif (data[cfg.keys.layout]) {\n@@ -264,7 +275,7 @@ class Template {\nreturn ret;\n}\n- async write() {\n+ async writeWithData(data) {\nlet outputPath = await this.getOutputPath();\nif (this.isIgnored()) {\nif (this.isVerbose) {\n@@ -273,14 +284,6 @@ class Template {\n} else {\nthis.writeCount++;\n- let data = await this.getData();\n- if (data.renderData) {\n- data.renderData = await this.mapDataAsRenderedTemplates(\n- data.renderData,\n- data\n- );\n- }\n-\nlet pluginRet = await this.runPlugins(data);\nif (pluginRet) {\nlet str = await this.render(data);\n@@ -294,9 +297,14 @@ class Template {\n}\n}\n+ async write() {\n+ let data = await this.getRenderedData();\n+ await this.writeWithData(data);\n+ }\n+\nclone() {\n// TODO better clone\n- var tmpl = new Template(\n+ let tmpl = new Template(\nthis.inputPath,\nthis.inputDir,\nthis.outputDir,\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -352,3 +352,13 @@ test(\"mapDataAsRenderedTemplates\", async t => {\n}\n);\n});\n+\n+test(\"renderData\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/renderData/renderData.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is((await tmpl.render()).trim(), `hi:value2-value1.css`);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/renderData/renderData.njk", "diff": "+---\n+key1: value1\n+renderData:\n+ key2:\n+ - value2-{{ key1 }}.css\n+---\n+hi:{{ renderData.key2 }}\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `renderData` front matter test
699
04.01.2018 20:21:40
21,600
e36f40df7ad0851759a5815ede3941c6bcfa46b2
Work in progress, collections
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -53,6 +53,10 @@ class Template {\nthis.writeCount = 0;\n}\n+ getInputPath() {\n+ return this.inputPath;\n+ }\n+\nsetIsVerbose(isVerbose) {\nthis.isVerbose = isVerbose;\n}\n@@ -275,8 +279,7 @@ class Template {\nreturn ret;\n}\n- async writeWithData(data) {\n- let outputPath = await this.getOutputPath();\n+ async writeWithData(outputPath, data) {\nif (this.isIgnored()) {\nif (this.isVerbose) {\nconsole.log(\"Ignoring\", outputPath);\n@@ -298,8 +301,9 @@ class Template {\n}\nasync write() {\n+ let outputPath = await this.getOutputPath();\nlet data = await this.getRenderedData();\n- await this.writeWithData(data);\n+ await this.writeWithData(outputPath, data);\n}\nclone() {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -4,23 +4,8 @@ const Path = require(\"./TemplatePath\");\nconst Sortable = require(\"./Util/Sortable\");\nclass TemplateCollection extends Sortable {\n- constructor(templatePath) {\n+ constructor() {\nsuper();\n- this.globSelector = null;\n- this.templatePath = templatePath;\n-\n- if (templatePath) {\n- this.setDefaultGlobFromTemplatePath(templatePath);\n- }\n- }\n-\n- setDefaultGlobFromTemplatePath(path) {\n- let parsed = parsePath(path);\n- this.globSelector = parsed.dir + \"/*\";\n- }\n-\n- setGlob(glob) {\n- this.globSelector = glob;\n}\ngetTemplatePathIndex(files) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -98,6 +98,24 @@ TemplateWriter.prototype.addWritingIgnores = function(baseDir, files) {\nreturn files;\n};\n+TemplateWriter.prototype._getAllPaths = async function() {\n+ return globby(this.files, { gitignore: true });\n+};\n+\n+TemplateWriter.prototype._getTemplatesMap = async function(paths) {\n+ let templates = [];\n+ for (let path of paths) {\n+ let tmpl = this._getTemplate(path);\n+ templates.push({\n+ inputPath: tmpl.getInputPath(),\n+ outputPath: await tmpl.getOutputPath(),\n+ template: tmpl,\n+ data: await tmpl.getRenderedData()\n+ });\n+ }\n+ return templates;\n+};\n+\nTemplateWriter.prototype._getTemplate = function(path) {\nlet tmpl = new Template(\npath,\n@@ -136,24 +154,40 @@ TemplateWriter.prototype._getTemplate = function(path) {\nreturn tmpl;\n};\n-TemplateWriter.prototype._writeTemplate = async function(path) {\n- let tmpl = this._getTemplate(path);\n+TemplateWriter.prototype._writeTemplate = async function(\n+ tmpl,\n+ outputPath,\n+ data\n+) {\ntry {\n- await tmpl.write();\n+ await tmpl.writeWithData(outputPath, data);\n} catch (e) {\nthrow EleventyError.make(\nnew Error(`Having trouble writing template: ${path}`),\ne\n);\n}\n+\nthis.writeCount += tmpl.getWriteCount();\nreturn tmpl;\n};\n+TemplateWriter.prototype.buildDataMap = function(templatesMap) {\n+ let dataMap = [];\n+};\n+\nTemplateWriter.prototype.write = async function() {\n- var paths = await globby(this.files, { gitignore: true });\n- for (var j = 0, k = paths.length; j < k; j++) {\n- await this._writeTemplate(paths[j]);\n+ let paths = await this._getAllPaths();\n+ let templatesMap = await this._getTemplatesMap(paths);\n+\n+ this.buildDataMap(templatesMap);\n+\n+ for (let template of templatesMap) {\n+ await this._writeTemplate(\n+ template.template,\n+ template.outputPath,\n+ template.data\n+ );\n}\n};\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Sortable.js", "new_path": "src/Util/Sortable.js", "diff": "@@ -2,6 +2,19 @@ class Sortable {\nconstructor() {\nthis.sortAscending = true;\nthis.sortNumeric = false;\n+ this.items = [];\n+ }\n+\n+ add(item) {\n+ this.items.push(item);\n+ }\n+\n+ sort(sortFunction) {\n+ if (!sortFunction) {\n+ sortFunction = this.getSortFunction();\n+ }\n+\n+ return this.items.sort(sortFunction);\n}\nisSortAscending() {\n@@ -12,6 +25,10 @@ class Sortable {\nreturn this.sortNumeric;\n}\n+ setSortDescending() {\n+ this.sortAscending = false;\n+ }\n+\nsetSortAscending(isAscending) {\nthis.sortAscending = isAscending;\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/SortableTest.js", "diff": "+import test from \"ava\";\n+import Sortable from \"../src/Util/Sortable\";\n+\n+test(\"Alphabetic Ascending\", t => {\n+ var s = new Sortable();\n+ s.add(\"a\");\n+ s.add(\"z\");\n+ s.add(\"m\");\n+ t.deepEqual(s.sort(), [\"a\", \"m\", \"z\"]);\n+});\n+\n+test(\"Alphabetic Descending\", t => {\n+ var s = new Sortable();\n+ s.setSortDescending();\n+ s.add(\"a\");\n+ s.add(\"z\");\n+ s.add(\"m\");\n+ t.deepEqual(s.sort(), [\"z\", \"m\", \"a\"]);\n+});\n+\n+test(\"Numeric Ascending\", t => {\n+ var s = new Sortable();\n+ s.setSortNumeric(true);\n+ s.add(1);\n+ s.add(4);\n+ s.add(2);\n+ t.deepEqual(s.sort(), [1, 2, 4]);\n+});\n+\n+test(\"Numeric Descending\", t => {\n+ var s = new Sortable();\n+ s.setSortDescending();\n+ s.add(1);\n+ s.add(4);\n+ s.add(2);\n+ t.deepEqual(s.sort(), [4, 2, 1]);\n+});\n+\n+// test(\"Combo (alphabetic) Ascending\", t => {\n+// var s = new Sortable();\n+// s.add(\"a\");\n+// s.add(\"z\");\n+// s.add(\"m\");\n+// s.add(0);\n+// s.add(10);\n+// s.add(1);\n+// s.add(12);\n+// });\n+\n+// test(\"Combo (numeric) Ascending\", t => {\n+// var s = new Sortable();\n+// s.setSortNumeric(true);\n+// s.add(\"a\");\n+// s.add(\"z\");\n+// s.add(\"m\");\n+// s.add(0);\n+// s.add(10);\n+// s.add(1);\n+// s.add(12);\n+// });\n" } ]
JavaScript
MIT License
11ty/eleventy
Work in progress, collections
699
05.01.2018 08:29:17
21,600
41e69976496b9cb2b2f7c40b5a4080b43537a4c8
Allows HTML to output without escaping in markdown render. (Option to markdown-it)
[ { "change_type": "MODIFY", "old_path": "src/Engines/Markdown.js", "new_path": "src/Engines/Markdown.js", "diff": "-const mdlib = require(\"markdown-it\")();\n+const mdlib = require(\"markdown-it\")({\n+ html: true\n+});\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Markdown extends TemplateEngine {\n" } ]
JavaScript
MIT License
11ty/eleventy
Allows HTML to output without escaping in markdown render. (Option to markdown-it)
699
05.01.2018 08:45:52
21,600
7ffc7a278333f10c63bdc648a58b966126c93d2e
Working collections!
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -33,6 +33,9 @@ module.exports = {\ncontentMapCollectionFilters: {\nposts: function(collection, activeTemplate) {\nreturn collection.getFilteredByTag(\"post\", activeTemplate);\n+ },\n+ all: function(collection, activeTemplate) {\n+ return collection.getAll(activeTemplate);\n}\n},\nonContentMapped: function(map) {\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"handlebars\": \"^4.0.11\",\n\"liquidjs\": \"^2.2.0\",\n\"lodash.chunk\": \"^4.2.0\",\n+ \"lodash.clonedeep\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n\"lodash.isobject\": \"^3.0.2\",\n\"lodash.merge\": \"^4.6.0\",\n" }, { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -54,9 +54,9 @@ Eleventy.prototype.init = async function() {\nthis.data\n);\n- if (this.isVerbose) {\n- console.log(\"Formats:\", this.formats.join(\", \"));\n- }\n+ // if (this.isVerbose) {\n+ // console.log(\"Formats:\", this.formats.join(\", \"));\n+ // }\nthis.writer.setVerboseOutput(this.isVerbose);\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -324,11 +324,13 @@ class Template {\nasync getMapped() {\nlet outputPath = await this.getOutputPath();\n+ let url = await this.getOutputLink();\nlet data = await this.getRenderedData();\nlet map = {\ntemplate: this,\ninputPath: this.getInputPath(),\noutputPath: outputPath,\n+ url: url,\ndata: data\n};\nreturn map;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -28,23 +28,24 @@ class TemplateCollection extends Sortable {\n});\n}\n+ getAll(activeTemplate) {\n+ return this.getSortedByInputPath().map(function(templateMap) {\n+ templateMap.active =\n+ activeTemplate && templateMap.template === activeTemplate;\n+ return templateMap;\n+ });\n+ }\n+\ngetFiltered(callback) {\n- return this.getSortedByInputPath().filter(callback);\n+ return this.getAll().filter(callback);\n}\ngetFilteredByTag(tagName, activeTemplate) {\n- return this.getSortedByInputPath()\n- .filter(function(item) {\n+ return this.getAll(activeTemplate).filter(function(item) {\nreturn (\n!tagName ||\n- (Array.isArray(item.data.tags) &&\n- item.data.tags.indexOf(tagName) > -1)\n+ (Array.isArray(item.data.tags) && item.data.tags.indexOf(tagName) > -1)\n);\n- })\n- .map(function(templateMap) {\n- templateMap.active =\n- activeTemplate && templateMap.template === activeTemplate;\n- return templateMap;\n});\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "const globby = require(\"globby\");\nconst normalize = require(\"normalize-path\");\nconst fs = require(\"fs-extra\");\n+const lodashCloneDeep = require(\"lodash.clonedeep\");\nconst Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateRender = require(\"./TemplateRender\");\n@@ -19,7 +20,7 @@ function TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.templateData = templateData;\nthis.isVerbose = true;\nthis.writeCount = 0;\n- this.collection = new Collection();\n+ this.collection = null;\nthis.rawFiles = this.templateExtensions.map(\nfunction(extension) {\n@@ -63,7 +64,7 @@ TemplateWriter.getFileIgnores = function(baseDir) {\n})\n.map(line => {\nline = line.trim();\n- path = TemplatePath.addLeadingDotSlash(\n+ let path = TemplatePath.addLeadingDotSlash(\nTemplatePath.normalize(baseDir, \"/\", line)\n);\nif (fs.statSync(path).isDirectory()) {\n@@ -105,6 +106,8 @@ TemplateWriter.prototype._getAllPaths = async function() {\n};\nTemplateWriter.prototype._populateCollection = function(templateMaps) {\n+ this.collection = new Collection();\n+\nfor (let map of templateMaps) {\nthis.collection.add(map);\n}\n@@ -158,12 +161,36 @@ TemplateWriter.prototype._getTemplate = function(path) {\nreturn tmpl;\n};\n-TemplateWriter.prototype._addCollectionsToData = function(data, template) {\n+TemplateWriter.prototype._createTemplateMapCopy = function(templatesMap) {\n+ let copy = [];\n+ for (let map of templatesMap) {\n+ let mapCopy = lodashCloneDeep(map);\n+\n+ // For simplification, maybe re-add this later?\n+ delete mapCopy.template;\n+\n+ // Circular reference\n+ delete mapCopy.data.collections;\n+\n+ copy.push(mapCopy);\n+ }\n+\n+ return copy;\n+};\n+\n+TemplateWriter.prototype._getCollectionsData = function(template) {\nlet filters = cfg.contentMapCollectionFilters;\n+ let collections = {};\n+\nfor (let filterName in filters) {\n- data[filterName] = filters[filterName](this.collection, template);\n+ collections[filterName] = this._createTemplateMapCopy(\n+ filters[filterName](this.collection, template)\n+ );\n}\n- return data;\n+ // console.log( \"collections>>>>\", collections );\n+ // console.log( \">>>>> end collections\" );\n+\n+ return collections;\n};\nTemplateWriter.prototype._writeTemplate = async function(\n@@ -172,12 +199,12 @@ TemplateWriter.prototype._writeTemplate = async function(\ndata\n) {\ntry {\n- data = this._addCollectionsToData(data, tmpl);\n+ data.collections = this._getCollectionsData(tmpl);\nawait tmpl.writeWithData(outputPath, data);\n} catch (e) {\nthrow EleventyError.make(\n- new Error(`Having trouble writing template: ${path}`),\n+ new Error(`Having trouble writing template: ${outputPath}`),\ne\n);\n}\n@@ -191,8 +218,8 @@ TemplateWriter.prototype.write = async function() {\nlet templatesMap = await this._getTemplatesMap(paths);\nthis._populateCollection(templatesMap);\n- let contentMap = this.collection.getSortedByInputPath();\nif (typeof cfg.onContentMapped === \"function\") {\n+ let contentMap = this.collection.getSortedByInputPath();\ncfg.onContentMapped(contentMap);\n}\n@@ -200,8 +227,7 @@ TemplateWriter.prototype.write = async function() {\nawait this._writeTemplate(\ntemplate.template,\ntemplate.outputPath,\n- template.data,\n- contentMap\n+ template.data\n);\n}\n};\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -76,7 +76,7 @@ test(\"_getTemplatesMap\", async t => {\nt.truthy(templatesMap[0].data);\n});\n-test(\"_addCollectionsToData\", async t => {\n+test(\"_getCollectionsData\", async t => {\nlet tw = new TemplateWriter(\"./test/stubs/collection\", \"./test/stubs/_site\", [\n\"md\"\n]);\n@@ -85,5 +85,18 @@ test(\"_addCollectionsToData\", async t => {\nlet templatesMap = await tw._getTemplatesMap(paths);\ntw._populateCollection(templatesMap);\n- t.is(tw._addCollectionsToData({}).posts.length, 2);\n+ t.is(tw._getCollectionsData().posts.length, 2);\n+});\n+\n+test(\"populating the collection twice should clear the previous values (--watch was making it cumulative)\", async t => {\n+ let tw = new TemplateWriter(\"./test/stubs/collection\", \"./test/stubs/_site\", [\n+ \"md\"\n+ ]);\n+\n+ let paths = await tw._getAllPaths();\n+ let templatesMap = await tw._getTemplatesMap(paths);\n+ tw._populateCollection(templatesMap);\n+ tw._populateCollection(templatesMap);\n+\n+ t.is(tw._getCollectionsData().posts.length, 2);\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
Working collections! #17
699
05.01.2018 23:37:43
21,600
81d71d58127b5c313e93203e743f9cf722880ef9
Allows tags to be a string or any array of strings
[ { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -44,7 +44,9 @@ class TemplateCollection extends Sortable {\nreturn this.getAll(activeTemplate).filter(function(item) {\nreturn (\n!tagName ||\n- (Array.isArray(item.data.tags) && item.data.tags.indexOf(tagName) > -1)\n+ ((Array.isArray(item.data.tags) ||\n+ typeof item.data.tags === \"string\") &&\n+ item.data.tags.indexOf(tagName) > -1)\n);\n});\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateCollectionTest.js", "new_path": "test/TemplateCollectionTest.js", "diff": "@@ -52,11 +52,11 @@ test(\"getFilteredByTag\", async t => {\nt.deepEqual(posts[1].template, tmpl3);\nlet cats = c.getFilteredByTag(\"cat\");\n- t.truthy(cats.length);\n- t.deepEqual(cats[0].template, tmpl3);\n+ t.is(cats.length, 2);\n+ t.deepEqual(cats[0].template, tmpl2);\nlet dogs = c.getFilteredByTag(\"dog\");\n- t.truthy(dogs.length);\n+ t.is(dogs.length, 1);\nt.deepEqual(dogs[0].template, tmpl1);\n});\n@@ -74,7 +74,8 @@ test(\"getFilteredByTag (added out of order, sorted)\", async t => {\nlet cats = c.getFilteredByTag(\"cat\", tmpl1);\nt.truthy(cats.length);\n- t.deepEqual(cats[0].template, tmpl3);\n+ t.is(cats.length, 2);\n+ t.deepEqual(cats[0].template, tmpl2);\nt.false(cats[0].active);\nlet dogs = c.getFilteredByTag(\"dog\", tmpl2);\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/collection/test2.md", "new_path": "test/stubs/collection/test2.md", "diff": "+---\n+tags: cat\n+---\n+\n# Test 2\n" } ]
JavaScript
MIT License
11ty/eleventy
Allows tags to be a string or any array of strings
699
07.01.2018 14:42:42
21,600
eec14bfd5dc6b149d020965b6508f0756d4f967c
Create a collection for every tag used on any template.
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -31,9 +31,6 @@ module.exports = {\n},\nfilters: {},\ncontentMapCollectionFilters: {\n- posts: function(collection, activeTemplate) {\n- return collection.getFilteredByTag(\"post\", activeTemplate);\n- },\nall: function(collection, activeTemplate) {\nreturn collection.getAll(activeTemplate);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -161,6 +161,21 @@ TemplateWriter.prototype._getTemplate = function(path) {\nreturn tmpl;\n};\n+TemplateWriter.prototype._getAllTagsFromMap = function(templatesMap) {\n+ let allTags = {};\n+ for (let map of templatesMap) {\n+ let tags = map.data.tags;\n+ if (Array.isArray(tags)) {\n+ for (let tag of tags) {\n+ allTags[tag] = true;\n+ }\n+ } else if (tags) {\n+ allTags[tags] = true;\n+ }\n+ }\n+ return Object.keys(allTags);\n+};\n+\nTemplateWriter.prototype._createTemplateMapCopy = function(templatesMap) {\nlet copy = [];\nfor (let map of templatesMap) {\n@@ -168,7 +183,6 @@ TemplateWriter.prototype._createTemplateMapCopy = function(templatesMap) {\n// For simplification, maybe re-add this later?\ndelete mapCopy.template;\n-\n// Circular reference\ndelete mapCopy.data.collections;\n@@ -181,10 +195,14 @@ TemplateWriter.prototype._createTemplateMapCopy = function(templatesMap) {\nTemplateWriter.prototype._getCollectionsData = function(template) {\nlet filters = cfg.contentMapCollectionFilters;\nlet collections = {};\n+ collections.all = this._createTemplateMapCopy(\n+ filters.all(this.collection, template)\n+ );\n- for (let filterName in filters) {\n- collections[filterName] = this._createTemplateMapCopy(\n- filters[filterName](this.collection, template)\n+ let tags = this._getAllTagsFromMap(collections.all);\n+ for (let tag of tags) {\n+ collections[tag] = this._createTemplateMapCopy(\n+ this.collection.getFilteredByTag(tag, template)\n);\n}\n// console.log( \"collections>>>>\", collections );\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -85,7 +85,22 @@ test(\"_getCollectionsData\", async t => {\nlet templatesMap = await tw._getTemplatesMap(paths);\ntw._populateCollection(templatesMap);\n- t.is(tw._getCollectionsData().posts.length, 2);\n+ let collectionsData = tw._getCollectionsData();\n+ t.is(collectionsData.post.length, 2);\n+ t.is(collectionsData.cat.length, 2);\n+ t.is(collectionsData.dog.length, 1);\n+});\n+\n+test(\"_getAllTags\", async t => {\n+ let tw = new TemplateWriter(\"./test/stubs/collection\", \"./test/stubs/_site\", [\n+ \"md\"\n+ ]);\n+\n+ let paths = await tw._getAllPaths();\n+ let templatesMap = await tw._getTemplatesMap(paths);\n+ let tags = tw._getAllTagsFromMap(templatesMap);\n+\n+ t.deepEqual(tags.sort(), [\"cat\", \"dog\", \"post\"].sort());\n});\ntest(\"populating the collection twice should clear the previous values (--watch was making it cumulative)\", async t => {\n@@ -98,5 +113,5 @@ test(\"populating the collection twice should clear the previous values (--watch\ntw._populateCollection(templatesMap);\ntw._populateCollection(templatesMap);\n- t.is(tw._getCollectionsData().posts.length, 2);\n+ t.is(tw._getCollectionsData().post.length, 2);\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
Create a collection for every tag used on any template.
699
07.01.2018 21:33:26
21,600
ed2d1c8ea1e309b6bd201b60d39cb4572fbbbcac
Pluralize word utility
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "const watch = require(\"glob-watcher\");\nconst chalk = require(\"chalk\");\n-const TemplateConfig = require(\"./TemplateConfig\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateWriter = require(\"./TemplateWriter\");\nconst EleventyError = require(\"./EleventyError\");\n+const simplePlural = require(\"./Util/Pluralize\");\n+const config = require(\"./Config\");\nconst pkg = require(\"../package.json\");\n-let cfg = TemplateConfig.getDefaultConfig();\n-\nfunction Eleventy(input, output) {\n- this.input = input || cfg.dir.input;\n- this.output = output || cfg.dir.output;\n- this.formats = cfg.templateFormats;\n+ this.input = input || config.dir.input;\n+ this.output = output || config.dir.output;\n+ this.formats = config.templateFormats;\nthis.data = null;\nthis.start = new Date();\n}\n@@ -20,10 +19,6 @@ Eleventy.prototype.restart = function() {\nthis.start = new Date();\n};\n-Eleventy.prototype._simplePlural = function(count, singleWord, pluralWord) {\n- return count === 1 ? singleWord : pluralWord;\n-};\n-\nEleventy.prototype.getFinishedLog = function() {\nif (!this.writer) {\nthrow new Error(\n@@ -34,12 +29,10 @@ Eleventy.prototype.getFinishedLog = function() {\nlet ret = [];\nlet writeCount = this.writer.getWriteCount();\n- ret.push(\n- `Wrote ${writeCount} ${this._simplePlural(writeCount, \"file\", \"files\")}`\n- );\n+ ret.push(`Wrote ${writeCount} ${simplePlural(writeCount, \"file\", \"files\")}`);\nlet time = ((new Date() - this.start) / 1000).toFixed(2);\n- ret.push(`in ${time} ${this._simplePlural(time, \"second\", \"seconds\")}`);\n+ ret.push(`in ${time} ${simplePlural(time, \"second\", \"seconds\")}`);\nreturn ret.join(\" \");\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Util/Pluralize.js", "diff": "+module.exports = function(count, singleWord, pluralWord) {\n+ return count === 1 ? singleWord : pluralWord;\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/PluralizeTest.js", "diff": "+import test from \"ava\";\n+import pluralize from \"../src/Util/Pluralize\";\n+\n+test(\"Pluralize\", t => {\n+ t.is(pluralize(0, \"test\", \"tests\"), \"tests\");\n+ t.is(pluralize(1, \"test\", \"tests\"), \"test\");\n+ t.is(pluralize(2, \"test\", \"tests\"), \"tests\");\n+ t.is(pluralize(3, \"test\", \"tests\"), \"tests\");\n+ t.is(pluralize(3.5, \"test\", \"tests\"), \"tests\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Pluralize word utility
699
07.01.2018 21:35:45
21,600
99d210b113cd34b03c7d52fe50a3df6c944e7c03
Config singleton
[ { "change_type": "ADD", "old_path": null, "new_path": "src/Config.js", "diff": "+const TemplateConfig = require(\"./TemplateConfig\");\n+module.exports = TemplateConfig.getDefaultConfig();\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Handlebars.js", "new_path": "src/Engines/Handlebars.js", "diff": "const HandlebarsLib = require(\"handlebars\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n-const TemplateConfig = require(\"../TemplateConfig\");\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+const config = require(\"../Config\");\nclass Handlebars extends TemplateEngine {\nconstructor(name, inputDir) {\n@@ -13,7 +11,7 @@ class Handlebars extends TemplateEngine {\nHandlebarsLib.registerPartial(name, partials[name]);\n}\n- this.addHelpers(cfg.handlebarsHelpers);\n+ this.addHelpers(config.handlebarsHelpers);\n}\naddHelpers(helpers) {\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "const NunjucksLib = require(\"nunjucks\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n-const TemplateConfig = require(\"../TemplateConfig\");\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+const config = require(\"../Config\");\nclass Nunjucks extends TemplateEngine {\nconstructor(name, inputDir) {\n@@ -12,7 +10,7 @@ class Nunjucks extends TemplateEngine {\nnew NunjucksLib.FileSystemLoader(super.getInputDir())\n);\n- this.addFilters(cfg.nunjucksFilters);\n+ this.addFilters(config.nunjucksFilters);\n}\naddFilters(helpers) {\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "const lodashchunk = require(\"lodash.chunk\");\nconst lodashget = require(\"lodash.get\");\nconst lodashset = require(\"lodash.set\");\n-const TemplateConfig = require(\"../TemplateConfig\");\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+const config = require(\"../Config\");\nfunction Pagination(data) {\nthis.data = data || {};\n@@ -82,7 +80,7 @@ Pagination.prototype.getTemplates = async function() {\nlet chunk = items[pageNumber];\nlet cloned = tmpl.clone();\n// TODO maybe also move this permalink additions up into the pagination class\n- if (pageNumber > 0 && !this.data[cfg.keys.permalink]) {\n+ if (pageNumber > 0 && !this.data[config.keys.permalink]) {\ncloned.setExtraOutputSubdirectory(pageNumber);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -8,10 +8,8 @@ const TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\nconst Layout = require(\"./TemplateLayout\");\n-const TemplateConfig = require(\"./TemplateConfig\");\nconst Eleventy = require(\"./Eleventy\");\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+const config = require(\"./Config\");\nclass Template {\nconstructor(path, inputDir, outputDir, templateData) {\n@@ -24,7 +22,7 @@ class Template {\nif (inputDir) {\nthis.inputDir = normalize(inputDir);\n- this.layoutsDir = this.inputDir + \"/\" + cfg.dir.includes;\n+ this.layoutsDir = this.inputDir + \"/\" + config.dir.includes;\n} else {\nthis.inputDir = false;\n}\n@@ -71,7 +69,7 @@ class Template {\n// TODO instead of isHTMLIOException, do a global search to check if output path = input path and then add extra suffix\nasync getOutputLink() {\n- let permalink = this.getFrontMatterData()[cfg.keys.permalink];\n+ let permalink = this.getFrontMatterData()[config.keys.permalink];\nif (permalink) {\nlet data = await this.getData();\nlet perm = new TemplatePermalink(\n@@ -88,14 +86,14 @@ class Template {\nthis.getTemplateSubfolder(),\nthis.parsed.name,\nthis.extraOutputSubdirectory,\n- this.isHtmlIOException ? cfg.htmlOutputSuffix : \"\"\n+ this.isHtmlIOException ? config.htmlOutputSuffix : \"\"\n).toString();\n}\n// TODO check for conflicts, see if file already exists?\nasync getOutputPath() {\nlet uri = await this.getOutputLink();\n- if (this.getFrontMatterData()[cfg.keys.permalinkRoot]) {\n+ if (this.getFrontMatterData()[config.keys.permalinkRoot]) {\nreturn normalize(uri);\n} else {\nreturn normalize(this.outputDir + \"/\" + uri);\n@@ -132,8 +130,8 @@ class Template {\nmerged = data;\n}\n- if (data[cfg.keys.layout]) {\n- let layout = tmpl.getLayoutTemplate(data[cfg.keys.layout]);\n+ if (data[config.keys.layout]) {\n+ let layout = tmpl.getLayoutTemplate(data[config.keys.layout]);\nlet layoutData = layout.getFrontMatterData();\nreturn this.getAllLayoutFrontMatterData(\n@@ -205,9 +203,9 @@ class Template {\n}\nasync renderLayout(tmpl, tmplData) {\n- let layoutName = tmplData[cfg.keys.layout];\n+ let layoutName = tmplData[config.keys.layout];\n// TODO make layout key to be available to templates (without it causing issues with merge below)\n- delete tmplData[cfg.keys.layout];\n+ delete tmplData[config.keys.layout];\nlet layout = this.getLayoutTemplate(layoutName);\nlet layoutData = await layout.getData(tmplData);\n@@ -218,7 +216,7 @@ class Template {\ntmplData\n);\n- if (layoutData[cfg.keys.layout]) {\n+ if (layoutData[config.keys.layout]) {\nreturn this.renderLayout(layout, layoutData);\n}\n@@ -239,7 +237,7 @@ class Template {\ndata = await this.getRenderedData();\n}\n- if (data[cfg.keys.layout]) {\n+ if (data[config.keys.layout]) {\nreturn this.renderLayout(this, data);\n} else {\nreturn this.renderContent(this.getPreRender(), data);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "-const TemplateConfig = require(\"./TemplateConfig\");\nconst fs = require(\"fs-extra\");\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+const config = require(\"./Config\");\nfunction TemplateLayout(name, dir) {\nthis.dir = dir;\n@@ -24,7 +22,7 @@ TemplateLayout.prototype.findFileName = function() {\nthis.dir\n);\n}\n- cfg.templateFormats.forEach(\n+ config.templateFormats.forEach(\nfunction(extension) {\nlet filename = this.name + \".\" + extension;\nif (!file && fs.existsSync(this.dir + \"/\" + filename)) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateRender.js", "new_path": "src/TemplateRender.js", "diff": "const parsePath = require(\"parse-filepath\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateEngine = require(\"./Engines/TemplateEngine\");\n-const TemplateConfig = require(\"./TemplateConfig\");\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+const config = require(\"./Config\");\n// works with full path names or short engine name\nfunction TemplateRender(tmplPath, inputDir) {\n@@ -14,8 +12,8 @@ function TemplateRender(tmplPath, inputDir) {\nthis.inputDir = this._normalizeInputDir(inputDir);\nthis.engine = TemplateEngine.getEngine(this.engineName, this.inputDir);\n- this.defaultMarkdownEngine = cfg.markdownTemplateEngine;\n- this.defaultHtmlEngine = cfg.htmlTemplateEngine;\n+ this.defaultMarkdownEngine = config.markdownTemplateEngine;\n+ this.defaultHtmlEngine = config.htmlTemplateEngine;\n}\nTemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\n@@ -32,8 +30,8 @@ TemplateRender.prototype.getEngineName = function() {\nTemplateRender.prototype._normalizeInputDir = function(dir) {\nreturn dir\n- ? TemplatePath.normalize(dir, cfg.dir.includes)\n- : TemplatePath.normalize(cfg.dir.input, cfg.dir.includes);\n+ ? TemplatePath.normalize(dir, config.dir.includes)\n+ : TemplatePath.normalize(config.dir.input, config.dir.includes);\n};\nTemplateRender.prototype.getInputDir = function() {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -5,13 +5,12 @@ const lodashCloneDeep = require(\"lodash.clonedeep\");\nconst Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateRender = require(\"./TemplateRender\");\n-const TemplateConfig = require(\"./TemplateConfig\");\nconst EleventyError = require(\"./EleventyError\");\nconst Pagination = require(\"./Plugins/Pagination\");\nconst Collection = require(\"./TemplateCollection\");\n+const eleventyEmitter = require(\"./EleventyEmitter\");\nconst pkg = require(\"../package.json\");\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+const config = require(\"./Config\");\nfunction TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.baseDir = baseDir;\n@@ -79,9 +78,9 @@ TemplateWriter.getFileIgnores = function(baseDir) {\nTemplateWriter.prototype.addIgnores = function(baseDir, files) {\nfiles = files.concat(TemplateWriter.getFileIgnores(baseDir));\n- if (cfg.dir.output) {\n+ if (config.dir.output) {\nfiles = files.concat(\n- \"!\" + normalize(baseDir + \"/\" + cfg.dir.output + \"/**\")\n+ \"!\" + normalize(baseDir + \"/\" + config.dir.output + \"/**\")\n);\n}\n@@ -89,13 +88,15 @@ TemplateWriter.prototype.addIgnores = function(baseDir, files) {\n};\nTemplateWriter.prototype.addWritingIgnores = function(baseDir, files) {\n- if (cfg.dir.includes) {\n+ if (config.dir.includes) {\nfiles = files.concat(\n- \"!\" + normalize(baseDir + \"/\" + cfg.dir.includes + \"/**\")\n+ \"!\" + normalize(baseDir + \"/\" + config.dir.includes + \"/**\")\n);\n}\n- if (cfg.dir.data && cfg.dir.data !== \".\") {\n- files = files.concat(\"!\" + normalize(baseDir + \"/\" + cfg.dir.data + \"/**\"));\n+ if (config.dir.data && config.dir.data !== \".\") {\n+ files = files.concat(\n+ \"!\" + normalize(baseDir + \"/\" + config.dir.data + \"/**\")\n+ );\n}\nreturn files;\n@@ -139,8 +140,8 @@ TemplateWriter.prototype._getTemplate = function(path) {\n* return pretty(str, { ocd: true });\n* }\n*/\n- for (let filterName in cfg.filters) {\n- let filter = cfg.filters[filterName];\n+ for (let filterName in config.filters) {\n+ let filter = config.filters[filterName];\nif (typeof filter === \"function\") {\ntmpl.addFilter(filter);\n}\n@@ -193,7 +194,7 @@ TemplateWriter.prototype._createTemplateMapCopy = function(templatesMap) {\n};\nTemplateWriter.prototype._getCollectionsData = function(template) {\n- let filters = cfg.contentMapCollectionFilters;\n+ let filters = config.contentMapCollectionFilters;\nlet collections = {};\ncollections.all = this._createTemplateMapCopy(\nfilters.all(this.collection, template)\n@@ -236,11 +237,6 @@ TemplateWriter.prototype.write = async function() {\nlet templatesMap = await this._getTemplatesMap(paths);\nthis._populateCollection(templatesMap);\n- if (typeof cfg.onContentMapped === \"function\") {\n- let contentMap = this.collection.getSortedByInputPath();\n- cfg.onContentMapped(contentMap);\n- }\n-\nfor (let template of templatesMap) {\nawait this._writeTemplate(\ntemplate.template,\n@@ -248,6 +244,8 @@ TemplateWriter.prototype.write = async function() {\ntemplate.data\n);\n}\n+ console.log(\"emitting event\");\n+ eleventyEmitter.emit(\"11ty.datamap\", this.collection.getSortedByInputPath());\n};\nTemplateWriter.prototype.setVerboseOutput = function(isVerbose) {\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyTest.js", "new_path": "test/EleventyTest.js", "diff": "import test from \"ava\";\nimport Eleventy from \"../src/Eleventy\";\n-import TemplateConfig from \"../src/TemplateConfig\";\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+import config from \"../src/Config\";\ntest(\"Eleventy, defaults inherit from config\", async t => {\nlet elev = new Eleventy();\nt.truthy(elev.input);\nt.truthy(elev.output);\n- t.is(elev.input, cfg.dir.input);\n- t.is(elev.output, cfg.dir.output);\n+ t.is(elev.input, config.dir.input);\n+ t.is(elev.output, config.dir.output);\n});\ntest(\"Eleventy, get version\", t => {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateDataTest.js", "new_path": "test/TemplateDataTest.js", "diff": "import test from \"ava\";\nimport TemplateData from \"../src/TemplateData\";\n-import TemplateConfig from \"../src/TemplateConfig\";\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+import config from \"../src/Config\";\ntest(\"Create\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/\");\nlet data = await dataObj.getData();\n- t.true(Object.keys(data[cfg.keys.package]).length > 0);\n+ t.true(Object.keys(data[config.keys.package]).length > 0);\n});\n// test(\"Create (old method, file name not dir)\", async t => {\n// let dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n// let data = await dataObj.getData();\n-// t.true(Object.keys(data[cfg.keys.package]).length > 0);\n+// t.true(Object.keys(data[config.keys.package]).length > 0);\n// });\ntest(\"getData()\", async t => {\n@@ -28,12 +26,12 @@ test(\"getData()\", async t => {\nt.is(\ndata.globalData.datakey2,\n\"eleventy-cli\",\n- `variables, resolve ${cfg.keys.package} to its value.`\n+ `variables, resolve ${config.keys.package} to its value.`\n);\nt.true(\n- Object.keys(data[cfg.keys.package]).length > 0,\n- `package.json imported to data in ${cfg.keys.package}`\n+ Object.keys(data[config.keys.package]).length > 0,\n+ `package.json imported to data in ${config.keys.package}`\n);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "import test from \"ava\";\nimport TemplateData from \"../src/TemplateData\";\n-import TemplateConfig from \"../src/TemplateConfig\";\nimport Template from \"../src/Template\";\nimport pretty from \"pretty\";\nimport normalize from \"normalize-path\";\n-\n-let cfg = TemplateConfig.getDefaultConfig();\n+import config from \"../src/Config\";\nfunction cleanHtml(str) {\nreturn pretty(str, { ocd: true });\n@@ -134,7 +132,7 @@ test(\"More advanced getData()\", async t => {\nkey2: \"value2\"\n});\n- t.is(data[cfg.keys.package].name, \"eleventy-cli\");\n+ t.is(data[config.keys.package].name, \"eleventy-cli\");\nt.is(\ndata.key1,\n\"value1override\",\n@@ -153,10 +151,10 @@ test(\"One Layout\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data[cfg.keys.layout], \"defaultLayout\");\n+ t.is(tmpl.frontMatter.data[config.keys.layout], \"defaultLayout\");\nlet data = await tmpl.getData();\n- t.is(data[cfg.keys.layout], \"defaultLayout\");\n+ t.is(data[config.keys.layout], \"defaultLayout\");\nt.is(\ncleanHtml(await tmpl.renderLayout(tmpl, data)),\n@@ -183,10 +181,10 @@ test(\"Two Layouts\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data[cfg.keys.layout], \"layout-a\");\n+ t.is(tmpl.frontMatter.data[config.keys.layout], \"layout-a\");\nlet data = await tmpl.getData();\n- t.is(data[cfg.keys.layout], \"layout-a\");\n+ t.is(data[config.keys.layout], \"layout-a\");\nt.is(data.key1, \"value1\");\nt.is(\n" } ]
JavaScript
MIT License
11ty/eleventy
Config singleton
699
07.01.2018 22:52:31
21,600
e2f1d2a5606e7166df8d61502083b2452fbb716f
Clean up collections stuff a bit
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -21,20 +21,20 @@ function EleventyNodeVersionCheck() {\nEleventyNodeVersionCheck().then(function() {\nconst Eleventy = require(\"./src/Eleventy\");\n- let eleven = new Eleventy(argv.input, argv.output);\n- eleven.setFormats(argv.formats);\n- eleven.setIsVerbose(!argv.quiet);\n+ let elev = new Eleventy(argv.input, argv.output);\n+ elev.setFormats(argv.formats);\n+ elev.setIsVerbose(!argv.quiet);\n- eleven.init().then(function() {\n+ elev.init().then(function() {\nif (argv.version) {\n- console.log(eleven.getVersion());\n+ console.log(elev.getVersion());\n} else if (argv.help) {\n- console.log(eleven.getHelp());\n+ console.log(elev.getHelp());\n} else if (argv.watch) {\n- eleven.watch();\n+ elev.watch();\n} else {\n- eleven.write().then(function() {\n- console.log(eleven.getFinishedLog());\n+ elev.write().then(function() {\n+ console.log(elev.getFinishedLog());\n});\n}\n});\n" }, { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -30,14 +30,6 @@ module.exports = {\noutput: \"_site\"\n},\nfilters: {},\n- contentMapCollectionFilters: {\n- all: function(collection, activeTemplate) {\n- return collection.getAll(activeTemplate);\n- }\n- },\n- onContentMapped: function(map) {\n- // console.log( \"Content map\", map );\n- },\nhandlebarsHelpers: {},\nnunjucksFilters: {\nslug: str => {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "const fs = require(\"fs-extra\");\n-const merge = require(\"lodash.merge\");\n+const lodashMerge = require(\"lodash.merge\");\nconst TemplatePath = require(\"./TemplatePath\");\n+const eleventyEmitter = require(\"./EleventyEmitter\");\n-function TemplateConfig(globalConfig, localConfigPath) {\n- this.localConfigPath = localConfigPath || \".eleventy.js\";\n- this.config = this.mergeConfig(globalConfig);\n+function TemplateConfig(rootConfig, projectConfigPath) {\n+ this.projectConfigPath = projectConfigPath || \".eleventy.js\";\n+ this.rootConfig = rootConfig;\n+ this.config = this.mergeConfig();\n}\n+/* Static function to get active config */\nTemplateConfig.getDefaultConfig = function() {\n- let templateCfg = new TemplateConfig(require(\"../config.js\"));\n- return templateCfg.getConfig();\n+ let cachedTemplateConfig = new TemplateConfig(require(\"../config.js\"));\n+ return cachedTemplateConfig.getConfig();\n};\nTemplateConfig.prototype.getConfig = function() {\nreturn this.config;\n};\n-TemplateConfig.prototype.mergeConfig = function(globalConfig) {\n+TemplateConfig.prototype.mergeConfig = function() {\nlet localConfig;\nlet path = TemplatePath.normalize(\n- TemplatePath.getWorkingDir() + \"/\" + this.localConfigPath\n+ TemplatePath.getWorkingDir() + \"/\" + this.projectConfigPath\n);\n+\ntry {\nlocalConfig = require(path);\n+ if (typeof localConfig === \"function\") {\n+ localConfig = localConfig(eleventyEmitter);\n+ }\n} catch (e) {\n// if file does not exist, return empty obj\nlocalConfig = {};\n}\n// Object assign overrides original values (good only for templateFormats) but not good for everything else\n- let merged = merge({}, globalConfig, localConfig);\n+ let merged = lodashMerge({}, this.rootConfig, localConfig);\nlet overrides = [\"templateFormats\"];\nfor (let key of overrides) {\n- merged[key] = localConfig[key] || globalConfig[key];\n+ merged[key] = localConfig[key] || this.rootConfig[key];\n}\nreturn merged;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -8,7 +8,6 @@ const TemplateRender = require(\"./TemplateRender\");\nconst EleventyError = require(\"./EleventyError\");\nconst Pagination = require(\"./Plugins/Pagination\");\nconst Collection = require(\"./TemplateCollection\");\n-const eleventyEmitter = require(\"./EleventyEmitter\");\nconst pkg = require(\"../package.json\");\nconst config = require(\"./Config\");\n@@ -194,10 +193,9 @@ TemplateWriter.prototype._createTemplateMapCopy = function(templatesMap) {\n};\nTemplateWriter.prototype._getCollectionsData = function(template) {\n- let filters = config.contentMapCollectionFilters;\nlet collections = {};\ncollections.all = this._createTemplateMapCopy(\n- filters.all(this.collection, template)\n+ this.collection.getAll(template)\n);\nlet tags = this._getAllTagsFromMap(collections.all);\n@@ -244,6 +242,7 @@ TemplateWriter.prototype.write = async function() {\ntemplate.data\n);\n}\n+\nconsole.log(\"emitting event\");\neleventyEmitter.emit(\"11ty.datamap\", this.collection.getSortedByInputPath());\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Clean up collections stuff a bit
730
08.01.2018 20:08:46
21,600
b9acd24fb04ca4147903a35634ccef6a8e988e68
Fix help Updating to what the README says
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -81,16 +81,16 @@ Eleventy.prototype.getHelp = function() {\nlet out = [];\nout.push(\"usage: eleventy\");\nout.push(\" eleventy --watch\");\n- out.push(\" eleventy --input=./templates --output=./dist\");\n+ out.push(\" eleventy --input=. --output=./_site\");\nout.push(\"\");\nout.push(\"Arguments: \");\nout.push(\" --version\");\nout.push(\" --watch\");\n- out.push(\" Wait for files to change and automatically rewrite.\");\n+ out.push(\" Wait for files to change and automatically rewrite\");\nout.push(\" --input\");\n- out.push(\" Input template files (default: `templates`)\");\n+ out.push(\" Input template files (default: `.`)\");\nout.push(\" --output\");\n- out.push(\" Write HTML output to this folder (default: `dist`)\");\n+ out.push(\" Write HTML output to this folder (default: `_site`)\");\nout.push(\" --formats=liquid,md\");\nout.push(\" Whitelist only certain template types (default: `*`)\");\nout.push(\" --quiet\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix help Updating to what the README says
699
08.01.2018 23:35:32
21,600
288c1fb83fbf28a0fdedb6219ebb6fec0b66f291
Fixes adds docs.
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -103,6 +103,8 @@ This allows you to assign data values right in the template itself. Here are a f\n* `permalink`: Add in front matter to change the output target of the current template. You can use template syntax for variables here. [Read more about Permalinks](docs/permalinks.md).\n* `layout`: Wrap current template with a layout template found in the `_includes` folder.\n* `pagination`: Enable to iterate over data. Output multiple HTML files from a single template. [Read more about Pagination](docs/pagination.md).\n+* `tags`: A single string or array that identifies that a piece of content is part of a collection. Collections can be reused in any other template. [Read more about Collections](docs/collections.md).\n+* `date`: Override the default date (file creation) to customize how the file is sorted in a collection. [Read more about Collections](docs/collections.md).\n#### Special Variables\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -10,23 +10,30 @@ class TemplateCollection extends Sortable {\nsuper.add(templateMap);\n}\n- getAll(activeTemplate) {\n- return this.sort(Sortable.sortFunctionDirDateFilename).map(function(\n- templateMap\n- ) {\n+ _assignActiveTemplate(items, activeTemplate) {\nif (activeTemplate) {\n+ return items.map(function(templateMap) {\ntemplateMap.active = templateMap.template === activeTemplate;\n- }\nreturn templateMap;\n});\n+ } else {\n+ return items;\n+ }\n}\n- getFiltered(callback) {\n- return this.getAll().filter(callback);\n+ getAll() {\n+ return this.items;\n+ }\n+\n+ getAllSorted(activeTemplate) {\n+ return this._assignActiveTemplate(\n+ this.sort(Sortable.sortFunctionDirDateFilename),\n+ activeTemplate\n+ );\n}\ngetFilteredByTag(tagName, activeTemplate) {\n- return this.getAll(activeTemplate).filter(function(item) {\n+ return this.getAllSorted(activeTemplate).filter(function(item) {\nreturn (\n!tagName ||\n((Array.isArray(item.data.tags) ||\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -196,7 +196,7 @@ TemplateWriter.prototype._createTemplateMapCopy = function(templatesMap) {\nTemplateWriter.prototype._getCollectionsData = function(activeTemplate) {\nlet collections = {};\ncollections.all = this._createTemplateMapCopy(\n- this.collection.getAll(activeTemplate)\n+ this.collection.getAllSorted(activeTemplate)\n);\nlet tags = this._getAllTagsFromMap(collections.all);\n@@ -252,7 +252,7 @@ TemplateWriter.prototype.write = async function() {\n);\n}\n- eleventyEmitter.emit(\"alldata\", this.collection.getAll());\n+ eleventyConfig.emit(\"alldata\", this.collection.getAllSorted());\n};\nTemplateWriter.prototype.setVerboseOutput = function(isVerbose) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateCollectionTest.js", "new_path": "test/TemplateCollectionTest.js", "diff": "@@ -38,19 +38,6 @@ test(\"Basic setup\", async t => {\nt.is(c.length, 3);\n});\n-test(\"getFiltered\", async t => {\n- let c = new Collection();\n- await c.addTemplate(tmpl1);\n- await c.addTemplate(tmpl2);\n- await c.addTemplate(tmpl3);\n-\n- let filtered = c.getFiltered(function(item) {\n- return item.data && item.data.title;\n- });\n-\n- t.deepEqual(filtered[0].template, tmpl1);\n-});\n-\ntest(\"getSortedByDirAndDate\", async t => {\nlet c = new Collection();\nawait c.addTemplate(tmpl1);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -176,3 +176,27 @@ test(\"_getCollectionsData with custom collection (ascending)\", async t => {\nt.is(parsePath(collectionsData.customPosts[0].inputPath).base, \"test2.md\");\nt.is(parsePath(collectionsData.customPosts[1].inputPath).base, \"test1.md\");\n});\n+\n+test(\"_getCollectionsData with custom collection (filter only to markdown input)\", async t => {\n+ let tw = new TemplateWriter(\n+ \"./test/stubs/collection2\",\n+ \"./test/stubs/_site\",\n+ [\"md\"]\n+ );\n+\n+ let paths = await tw._getAllPaths();\n+ let templatesMap = await tw._getTemplatesMap(paths);\n+ tw._populateCollection(templatesMap);\n+\n+ eleventyConfig.addCollection(\"onlyMarkdown\", function(collection) {\n+ return collection.getAllSorted().filter(function(item) {\n+ let extension = item.inputPath.split(\".\").pop();\n+ return extension === \"md\";\n+ });\n+ });\n+\n+ let collectionsData = tw._getCollectionsData();\n+ t.is(collectionsData.onlyMarkdown.length, 2);\n+ t.is(parsePath(collectionsData.onlyMarkdown[0].inputPath).base, \"test1.md\");\n+ t.is(parsePath(collectionsData.onlyMarkdown[1].inputPath).base, \"test2.md\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes #17, adds docs.
699
08.01.2018 23:52:40
21,600
0e4e384efcfc7285710006109d32e4cef7c5ca05
Minor collections docs improvements
[ { "change_type": "MODIFY", "old_path": "docs/collections.md", "new_path": "docs/collections.md", "diff": "@@ -132,27 +132,27 @@ return collection.getAllSorted().reverse();\nreturn collection.getFilteredByTag(\"post\");\n// Filter using `Array.filter`\n-return collection.filter(function(item) {\n+return collection.getAll().filter(function(item) {\n// Side-step tags and do your own filtering\nreturn \"myCustomDataKey\" in item.data;\n});\n// Filter using `Array.filter`\n-return collection.filter(function(item) {\n+return collection.getAll().filter(function(item) {\n// Only return content that was originally a markdown file\nlet extension = item.inputPath.split('.').pop();\nreturn extension === \"md\";\n});\n-// Get tagged content and sort by date only (descending)\n-return collection.getFilteredByTag(\"post\").sort(function(a, b) {\n+// Sort with `Array.sort`\n+return collection.getAll().sort(function(a, b) {\nreturn b.date - a.date;\n});\n```\n### Individual collection items (useful for sort callbacks)\n-See how the `sort` function above uses `a.date` and `b.date`? Well, any of the following items can be used for sorting and filtering the content.\n+See how the `Array.sort` function above uses `a.date` and `b.date`? Similarly, any of the following items can be used for sorting and filtering the content.\n* `inputPath`: the path to the source input file\n* `outputPath`: the path to the output file to be written for this content\n" } ]
JavaScript
MIT License
11ty/eleventy
Minor collections docs improvements
699
09.01.2018 00:04:51
21,600
cfacd41f6768256322d077614bba487098fd05aa
Simplifies default collection sort (simplify to file creation and inputPath)
[ { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -27,7 +27,7 @@ class TemplateCollection extends Sortable {\ngetAllSorted(activeTemplate) {\nreturn this._assignActiveTemplate(\n- this.sort(Sortable.sortFunctionDirDateFilename),\n+ this.sort(Sortable.sortFunctionDateInputPath),\nactiveTemplate\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Sortable.js", "new_path": "src/Util/Sortable.js", "diff": "-const parsePath = require(\"parse-filepath\");\nconst capitalize = require(\"./Capitalize\");\nclass Sortable {\n@@ -95,28 +94,16 @@ class Sortable {\nreturn Sortable.sortFunctionAscending(b, a);\n}\n- static sortFunctionDirDateFilename(mapA, mapB) {\n- let parsedA = parsePath(mapA.inputPath);\n- let parsedB = parsePath(mapB.inputPath);\n- let sortDir = Sortable.sortFunctionAlphabeticAscending(\n- parsedA.dir,\n- parsedB.dir\n- );\n- if (sortDir === 0) {\n- let sortDate = Sortable.sortFunctionNumericAscending(\n- mapA.date,\n- mapB.date\n- );\n+ static sortFunctionDateInputPath(mapA, mapB) {\n+ let sortDate = Sortable.sortFunctionNumericAscending(mapA.date, mapB.date);\nif (sortDate === 0) {\nreturn Sortable.sortFunctionAlphabeticAscending(\n- parsedA.base,\n- parsedB.base\n+ mapA.inputPath,\n+ mapB.inputPath\n);\n}\nreturn sortDate;\n}\n- return sortDir;\n- }\n/* End sort functions */\ngetSortFunction() {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateCollectionTest.js", "new_path": "test/TemplateCollectionTest.js", "diff": "@@ -38,13 +38,13 @@ test(\"Basic setup\", async t => {\nt.is(c.length, 3);\n});\n-test(\"getSortedByDirAndDate\", async t => {\n+test(\"sortFunctionDateInputPath\", async t => {\nlet c = new Collection();\nawait c.addTemplate(tmpl1);\nawait c.addTemplate(tmpl4);\nawait c.addTemplate(tmpl5);\n- let posts = c.sort(Sortable.sortFunctionDirDateFilename);\n+ let posts = c.sort(Sortable.sortFunctionDateInputPath);\nt.is(posts.length, 3);\nt.deepEqual(posts[0].template, tmpl4);\nt.deepEqual(posts[1].template, tmpl1);\n" } ]
JavaScript
MIT License
11ty/eleventy
Simplifies default collection sort (simplify to file creation and inputPath)
699
09.01.2018 08:20:01
21,600
808fba908f677efd28dfa790ab9940152d88aef9
Start of debugging logs
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -7,7 +7,12 @@ EleventyNodeVersionCheck().then(function() {\nlet elev = new Eleventy(argv.input, argv.output);\nelev.setFormats(argv.formats);\n+\n+ if (process.env.DEBUG) {\n+ elev.setIsVerbose(false);\n+ } else {\nelev.setIsVerbose(!argv.quiet);\n+ }\nelev.init().then(function() {\nif (argv.version) {\n@@ -18,7 +23,7 @@ EleventyNodeVersionCheck().then(function() {\nelev.watch();\n} else {\nelev.write().then(function() {\n- console.log(elev.getFinishedLog());\n+ // do something custom if you want\n});\n}\n});\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"dependencies\": {\n\"chalk\": \"^2.3.0\",\n\"check-node-version\": \"^3.1.1\",\n+ \"debug\": \"^3.1.0\",\n\"ejs\": \"^2.5.7\",\n\"fs-extra\": \"^4.0.2\",\n\"glob-watcher\": \"^4.0.0\",\n" }, { "change_type": "MODIFY", "old_path": "src/Config.js", "new_path": "src/Config.js", "diff": "const TemplateConfig = require(\"./TemplateConfig\");\n-module.exports = TemplateConfig.getDefaultConfig();\n+const debug = require(\"debug\")(\"Eleventy:Config\");\n+\n+debug(\"Getting all config values.\");\n+let config = TemplateConfig.getDefaultConfig();\n+\n+module.exports = config;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -11,6 +11,7 @@ const Collection = require(\"./TemplateCollection\");\nconst pkg = require(\"../package.json\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst config = require(\"./Config\");\n+const debug = require(\"debug\")(\"Eleventy:TemplateWriter\");\nfunction TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.baseDir = baseDir;\n@@ -46,6 +47,7 @@ TemplateWriter.prototype.getFiles = function() {\n};\nTemplateWriter.getFileIgnores = function(baseDir) {\n+ debug(\"Getting ignored files in .eleventyignore\");\nlet ignorePath = TemplatePath.normalize(baseDir + \"/.eleventyignore\");\nlet ignoreContent;\ntry {\n@@ -72,12 +74,12 @@ TemplateWriter.getFileIgnores = function(baseDir) {\nreturn \"!\" + path;\n});\n}\n-\nreturn ignores;\n};\nTemplateWriter.prototype.addIgnores = function(baseDir, files) {\nfiles = files.concat(TemplateWriter.getFileIgnores(baseDir));\n+\nif (config.dir.output) {\nfiles = files.concat(\n\"!\" + normalize(baseDir + \"/\" + config.dir.output + \"/**\")\n@@ -115,12 +117,16 @@ TemplateWriter.prototype._populateCollection = function(templateMaps) {\n};\nTemplateWriter.prototype._getTemplatesMap = async function(paths) {\n+ debug(\"Iterating over paths\");\nlet templates = [];\nfor (let path of paths) {\nlet tmpl = this._getTemplate(path);\n+ debug(`Template for ${path} retrieved.`);\nlet map = await tmpl.getMapped();\n+ debug(\"Map for template retrieved.\");\ntemplates.push(map);\n}\n+ debug(\"All templates mapped.\");\nreturn templates;\n};\n@@ -131,6 +137,7 @@ TemplateWriter.prototype._getTemplate = function(path) {\nthis.outputDir,\nthis.templateData\n);\n+ debug(\"new Template object created.\");\ntmpl.setIsVerbose(this.isVerbose);\n@@ -146,6 +153,7 @@ TemplateWriter.prototype._getTemplate = function(path) {\ntmpl.addFilter(filter);\n}\n}\n+ debug(\"Add filters from config to template.\");\nlet writer = this;\ntmpl.addPlugin(\"pagination\", async function(data) {\n@@ -158,6 +166,7 @@ TemplateWriter.prototype._getTemplate = function(path) {\nreturn false;\n}\n});\n+ debug(\"Pagination plugin added.\");\nreturn tmpl;\n};\n@@ -240,11 +249,17 @@ TemplateWriter.prototype._writeTemplate = async function(\n};\nTemplateWriter.prototype.write = async function() {\n+ debug(\"Creating templates map.\");\nlet paths = await this._getAllPaths();\n+ debug(\"Paths retrieved.\");\nlet templatesMap = await this._getTemplatesMap(paths);\n+ debug(\"Got the templates map.\");\nthis._populateCollection(templatesMap);\n+ debug(\"Populating the collections.\");\n+ debug(\"Writing templates\");\nfor (let template of templatesMap) {\n+ debug(`Writing template ${template.outputPath} from ${template.inputPath}`);\nawait this._writeTemplate(\ntemplate.template,\ntemplate.outputPath,\n@@ -252,6 +267,7 @@ TemplateWriter.prototype.write = async function() {\n);\n}\n+ debug(\"Triggering `alldata` event.\");\neleventyConfig.emit(\"alldata\", this.collection.getAllSorted());\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Start of debugging logs
699
09.01.2018 08:26:26
21,600
66feafdfee80ff9629793b05b372e2c68791bc37
Renames npm package name under 11ty npm scope as
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n- \"name\": \"eleventy-cli\",\n- \"version\": \"0.1.9\",\n+ \"name\": \"@11ty/eleventy\",\n+ \"version\": \"0.2.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -133,7 +133,7 @@ test(\"More advanced getData()\", async t => {\nkey2: \"value2\"\n});\n- t.is(data[config.keys.package].name, \"eleventy-cli\");\n+ t.is(data[config.keys.package].name, \"@11ty/eleventy\");\nt.is(\ndata.key1,\n\"value1override\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Renames npm package name under 11ty npm scope as @11ty/eleventy
699
09.01.2018 08:45:52
21,600
2e655bcd5612f71247f34d3d3e91eecd9c1ac5c2
Couple of missed renames.
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"0.2.0\",\n+ \"version\": \"0.2.1\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n},\n\"repository\": {\n\"type\": \"git\",\n- \"url\": \"git://github.com/zachleat/eleventy.git\"\n+ \"url\": \"git://github.com/11ty/eleventy.git\"\n},\n\"ava\": {\n\"files\": [\"test/*.js\"],\n" } ]
JavaScript
MIT License
11ty/eleventy
Couple of missed renames.
699
09.01.2018 08:50:45
21,600
bda34f49ace03b4c55a37f0fb14b7c80cea1d1be
Link was wrong.
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -21,7 +21,7 @@ Requires Node version 8 or above. `node --version` will tell you what version yo\n### Installation\n-Available [on npm](https://www.npmjs.com/package/@11ty/cli).\n+Available [on npm](https://www.npmjs.com/package/@11ty/eleventy).\n```\nnpm install -g @11ty/eleventy\n" } ]
JavaScript
MIT License
11ty/eleventy
Link was wrong.
699
09.01.2018 23:39:23
21,600
d7b38d7e24c739c46a7ff808218be7871029b22f
Allows a single file as input, e.g. `--input=myfile.md` (no need for formats here)
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "+const fs = require(\"fs\");\nconst watch = require(\"glob-watcher\");\nconst chalk = require(\"chalk\");\n+const parsePath = require(\"parse-filepath\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateWriter = require(\"./TemplateWriter\");\nconst EleventyError = require(\"./EleventyError\");\n@@ -9,12 +11,20 @@ const pkg = require(\"../package.json\");\nfunction Eleventy(input, output) {\nthis.input = input || config.dir.input;\n+ this.inputDir = this._getDir(this.input);\nthis.output = output || config.dir.output;\nthis.formats = config.templateFormats;\nthis.data = null;\nthis.start = new Date();\n}\n+Eleventy.prototype._getDir = function(inputPath) {\n+ if (!fs.statSync(inputPath).isDirectory()) {\n+ return parsePath(inputPath).dir;\n+ }\n+ return inputPath;\n+};\n+\nEleventy.prototype.restart = function() {\nthis.start = new Date();\n};\n@@ -38,7 +48,7 @@ Eleventy.prototype.getFinishedLog = function() {\n};\nEleventy.prototype.init = async function() {\n- this.data = new TemplateData(this.input);\n+ this.data = new TemplateData(this.inputDir);\nthis.writer = new TemplateWriter(\nthis.input,\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -7,8 +7,10 @@ const TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst config = require(\"./Config\");\n-function TemplateData(globalDataPath) {\n- this.globalDataPath = globalDataPath;\n+function TemplateData(inputDir) {\n+ this.inputDir = inputDir;\n+ this.dataDir =\n+ inputDir + \"/\" + (config.dir.data !== \".\" ? config.dir.data : \"\");\nthis.rawImports = {};\nthis.rawImports[config.keys.package] = this.getJsonRaw(\n@@ -31,16 +33,14 @@ TemplateData.prototype.cacheData = async function() {\nTemplateData.prototype.getGlobalDataGlob = async function() {\nlet dir = \".\";\n- if (this.globalDataPath) {\n- let globalPathStat = await pify(fs.stat)(this.globalDataPath);\n+ if (this.inputDir) {\n+ let globalPathStat = await pify(fs.stat)(this.inputDir);\nif (!globalPathStat.isDirectory()) {\n- throw new Error(\n- \"Could not find data path directory: \" + this.globalDataPath\n- );\n+ throw new Error(\"Could not find data path directory: \" + this.inputDir);\n}\n- dir = this.globalDataPath;\n+ dir = this.inputDir;\n}\nreturn (\n@@ -57,10 +57,7 @@ TemplateData.prototype.getGlobalDataFiles = async function() {\n};\nTemplateData.prototype.getObjectPathForDataFile = function(path) {\n- let reducedPath = TemplatePath.stripPathFromDir(\n- path,\n- this.globalDataPath + \"/\" + (config.dir.data !== \".\" ? config.dir.data : \"\")\n- );\n+ let reducedPath = TemplatePath.stripPathFromDir(path, this.dataDir);\nlet parsed = parsePath(reducedPath);\nlet folders = parsed.dir ? parsed.dir.split(\"/\") : [];\nfolders.push(parsed.name);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -2,6 +2,7 @@ const globby = require(\"globby\");\nconst normalize = require(\"normalize-path\");\nconst fs = require(\"fs-extra\");\nconst lodashCloneDeep = require(\"lodash.clonedeep\");\n+const parsePath = require(\"parse-filepath\");\nconst Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateRender = require(\"./TemplateRender\");\n@@ -12,8 +13,9 @@ const pkg = require(\"../package.json\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst config = require(\"./Config\");\n-function TemplateWriter(baseDir, outputDir, extensions, templateData) {\n- this.baseDir = baseDir;\n+function TemplateWriter(inputPath, outputDir, extensions, templateData) {\n+ this.input = inputPath;\n+ this.inputDir = this._getInputPathDir(inputPath);\nthis.templateExtensions = extensions;\nthis.outputDir = outputDir;\nthis.templateData = templateData;\n@@ -21,22 +23,34 @@ function TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.writeCount = 0;\nthis.collection = null;\n+ // Input was a directory\n+ if (this.input === this.inputDir) {\nthis.rawFiles = this.templateExtensions.map(\nfunction(extension) {\n- return normalize(this.baseDir + \"/**/*.\" + extension);\n+ return normalize(this.inputDir + \"/**/*.\" + extension);\n}.bind(this)\n);\n+ } else {\n+ this.rawFiles = [normalize(inputPath)];\n+ }\n+\n+ this.watchedFiles = this.addIgnores(this.inputDir, this.rawFiles);\n+ this.files = this.addWritingIgnores(this.inputDir, this.watchedFiles);\n+}\n- this.watchedFiles = this.addIgnores(baseDir, this.rawFiles);\n- this.files = this.addWritingIgnores(baseDir, this.watchedFiles);\n+TemplateWriter.prototype._getInputPathDir = function(inputPath) {\n+ if (!fs.statSync(inputPath).isDirectory()) {\n+ return parsePath(inputPath).dir;\n}\n+ return inputPath;\n+};\nTemplateWriter.prototype.getRawFiles = function() {\nreturn this.rawFiles;\n};\nTemplateWriter.prototype.getWatchedIgnores = function() {\n- return this.addIgnores(this.baseDir, []).map(ignore =>\n+ return this.addIgnores(this.inputDir, []).map(ignore =>\nTemplatePath.stripLeadingDotSlash(ignore.substr(1))\n);\n};\n@@ -45,8 +59,8 @@ TemplateWriter.prototype.getFiles = function() {\nreturn this.files;\n};\n-TemplateWriter.getFileIgnores = function(baseDir) {\n- let ignorePath = TemplatePath.normalize(baseDir + \"/.eleventyignore\");\n+TemplateWriter.getFileIgnores = function(inputDir) {\n+ let ignorePath = TemplatePath.normalize(inputDir + \"/.eleventyignore\");\nlet ignoreContent;\ntry {\nignoreContent = fs.readFileSync(ignorePath, \"utf-8\");\n@@ -64,7 +78,7 @@ TemplateWriter.getFileIgnores = function(baseDir) {\n.map(line => {\nline = line.trim();\nlet path = TemplatePath.addLeadingDotSlash(\n- TemplatePath.normalize(baseDir, \"/\", line)\n+ TemplatePath.normalize(inputDir, \"/\", line)\n);\nif (fs.statSync(path).isDirectory()) {\nreturn \"!\" + path + \"/**\";\n@@ -76,26 +90,26 @@ TemplateWriter.getFileIgnores = function(baseDir) {\nreturn ignores;\n};\n-TemplateWriter.prototype.addIgnores = function(baseDir, files) {\n- files = files.concat(TemplateWriter.getFileIgnores(baseDir));\n+TemplateWriter.prototype.addIgnores = function(inputDir, files) {\n+ files = files.concat(TemplateWriter.getFileIgnores(inputDir));\nif (config.dir.output) {\nfiles = files.concat(\n- \"!\" + normalize(baseDir + \"/\" + config.dir.output + \"/**\")\n+ \"!\" + normalize(inputDir + \"/\" + config.dir.output + \"/**\")\n);\n}\nreturn files;\n};\n-TemplateWriter.prototype.addWritingIgnores = function(baseDir, files) {\n+TemplateWriter.prototype.addWritingIgnores = function(inputDir, files) {\nif (config.dir.includes) {\nfiles = files.concat(\n- \"!\" + normalize(baseDir + \"/\" + config.dir.includes + \"/**\")\n+ \"!\" + normalize(inputDir + \"/\" + config.dir.includes + \"/**\")\n);\n}\nif (config.dir.data && config.dir.data !== \".\") {\nfiles = files.concat(\n- \"!\" + normalize(baseDir + \"/\" + config.dir.data + \"/**\")\n+ \"!\" + normalize(inputDir + \"/\" + config.dir.data + \"/**\")\n);\n}\n@@ -127,7 +141,7 @@ TemplateWriter.prototype._getTemplatesMap = async function(paths) {\nTemplateWriter.prototype._getTemplate = function(path) {\nlet tmpl = new Template(\npath,\n- this.baseDir,\n+ this.inputDir,\nthis.outputDir,\nthis.templateData\n);\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyTest.js", "new_path": "test/EleventyTest.js", "diff": "@@ -40,3 +40,11 @@ test(\"Eleventy set input/output\", async t => {\nt.truthy(elev.data);\nt.truthy(elev.writer);\n});\n+\n+test(\"Eleventy set input/output, one file input\", async t => {\n+ let elev = new Eleventy(\"./test/stubs/index.html\", \"./test/stubs/_site\");\n+\n+ t.is(elev.input, \"./test/stubs/index.html\");\n+ t.is(elev.inputDir, \"./test/stubs\");\n+ t.is(elev.output, \"./test/stubs/_site\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Allows a single file as input, e.g. `--input=myfile.md` (no need for formats here)
699
10.01.2018 00:04:07
21,600
03ebe8d9f7218ee260e08be5d562a339668a572c
Adding better Getting Started to documentation.
[ { "change_type": "ADD", "old_path": null, "new_path": "docs/install-local.md", "diff": "+# Install locally\n+\n+Rather than a global install, like so:\n+\n+```\n+npm install -g @11ty/eleventy\n+```\n+\n+You can install locally into your current project, like so:\n+\n+```\n+npm install --save-dev @11ty/eleventy\n+```\n+\n+Then use npx to run your local project version:\n+\n+```\n+npx eleventy\n+```\n" } ]
JavaScript
MIT License
11ty/eleventy
Adding better Getting Started to documentation.
699
10.01.2018 00:11:55
21,600
19a7c95eb493325b27c56a85d4ea1426b99f15aa
Minor bug with --input=SINGLEFILE.md
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -11,7 +11,7 @@ const pkg = require(\"../package.json\");\nfunction Eleventy(input, output) {\nthis.input = input || config.dir.input;\n- this.inputDir = this._getDir(this.input);\n+ this.inputDir = this._getDir(this.input) || \".\";\nthis.output = output || config.dir.output;\nthis.formats = config.templateFormats;\nthis.data = null;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -15,7 +15,7 @@ const config = require(\"./Config\");\nfunction TemplateWriter(inputPath, outputDir, extensions, templateData) {\nthis.input = inputPath;\n- this.inputDir = this._getInputPathDir(inputPath);\n+ this.inputDir = this._getInputPathDir(inputPath) || \".\";\nthis.templateExtensions = extensions;\nthis.outputDir = outputDir;\nthis.templateData = templateData;\n" } ]
JavaScript
MIT License
11ty/eleventy
Minor bug with --input=SINGLEFILE.md
699
10.01.2018 08:18:50
21,600
90ea3e035b253fa1b7152af263606bc7dffe9153
Encourage people to use extensions in their layout names, for less ambiguity (and perf, probably). Adds layout tests for liquid to test unescaped output by default.
[ { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "@@ -4,9 +4,22 @@ const config = require(\"./Config\");\nfunction TemplateLayout(name, dir) {\nthis.dir = dir;\nthis.name = name;\n+ this.pathNameAlreadyHasExtension = this.dir + \"/\" + this.name;\n+ if (\n+ this.name.split(\".\").length > 0 &&\n+ fs.existsSync(this.pathNameAlreadyHasExtension)\n+ ) {\n+ this.filename = this.name;\n+ this.fullPath = this.pathNameAlreadyHasExtension;\n+ } else {\nthis.filename = this.findFileName();\nthis.fullPath = this.dir + \"/\" + this.filename;\n}\n+}\n+\n+TemplateLayout.prototype.getFileName = function() {\n+ return this.filename;\n+};\nTemplateLayout.prototype.getFullPath = function() {\nreturn this.fullPath;\n@@ -22,6 +35,7 @@ TemplateLayout.prototype.findFileName = function() {\nthis.dir\n);\n}\n+\nconfig.templateFormats.forEach(\nfunction(extension) {\nlet filename = this.name + \".\" + extension;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -206,6 +206,36 @@ test(\"One Layout (_layoutContent deprecated but supported)\", async t => {\nt.is(mergedFrontMatter.keylayout, \"valuelayout\");\n});\n+test(\"One Layout (liquid test)\", async t => {\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ let tmpl = new Template(\n+ \"./test/stubs/templateWithLayout.liquid\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\n+\n+ t.is(tmpl.frontMatter.data[config.keys.layout], \"layoutLiquid.liquid\");\n+\n+ let data = await tmpl.getData();\n+ t.is(data[config.keys.layout], \"layoutLiquid.liquid\");\n+\n+ t.is(\n+ cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ `<div id=\"layout\">\n+ <p>Hello.</p>\n+</div>`\n+ );\n+\n+ let mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\n+ tmpl,\n+ tmpl.getFrontMatterData()\n+ );\n+\n+ t.is(mergedFrontMatter.keymain, \"valuemain\");\n+ t.is(mergedFrontMatter.keylayout, \"valuelayout\");\n+});\n+\ntest(\"Two Layouts\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/_includes/layoutLiquid.liquid", "diff": "+---\n+keylayout: valuelayout\n+---\n+\n+<div id=\"layout\">\n+ {{ content }}\n+</div>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateWithLayout.liquid", "diff": "+---\n+layout: layoutLiquid.liquid\n+keymain: valuemain\n+title: 'Font Aliasing, or How to Rename a Font in CSS'\n+permalink: /rename-font/\n+---\n+\n+<p>Hello.</p>\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Encourage people to use extensions in their layout names, for less ambiguity (and perf, probably). Adds layout tests for liquid to test unescaped output by default.
699
11.01.2018 23:21:26
21,600
dba284f1090a4492e0a01b4e50468c3cfc0f0c66
Add collections to debug
[ { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -241,12 +241,16 @@ TemplateWriter.prototype._getCollectionsData = function(activeTemplate) {\ncollections.all = this._createTemplateMapCopy(\nthis.collection.getAllSorted(activeTemplate)\n);\n+ debug(`Collection: collections.all has ${collections.all.length} items.`);\nlet tags = this._getAllTagsFromMap(collections.all);\nfor (let tag of tags) {\ncollections[tag] = this._createTemplateMapCopy(\nthis.collection.getFilteredByTag(tag, activeTemplate)\n);\n+ debug(\n+ `Collection: collections.${tag} has ${collections[tag].length} items.`\n+ );\n}\nlet configCollections = eleventyConfig.getCollections();\n@@ -254,6 +258,9 @@ TemplateWriter.prototype._getCollectionsData = function(activeTemplate) {\ncollections[name] = this._createTemplateMapCopy(\nconfigCollections[name](this.collection)\n);\n+ debug(\n+ `Collection: collections.${name} has ${collections[name].length} items.`\n+ );\n}\n// console.log( \"collections>>>>\", collections );\n" } ]
JavaScript
MIT License
11ty/eleventy
Add collections to debug
699
13.01.2018 14:50:55
21,600
aa70e20671c8bf562751b9c763b3eaf8ec4476d1
Add support message to DEBUG
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -181,6 +181,11 @@ Eleventy.prototype.write = async function() {\ntry {\nlet ret = await this.writer.write();\nthis.finish();\n+\n+ debug(`\n+Getting frustrated? Have a suggestion/feature request/feedback?\n+I want to hear it! Open an issue: https://github.com/11ty/eleventy/issues/new`);\n+\nreturn ret;\n} catch (e) {\nconsole.log(\"\\n\" + chalk.red(\"Problem writing eleventy templates: \"));\n" } ]
JavaScript
MIT License
11ty/eleventy
Add support message to DEBUG
699
13.01.2018 14:57:39
21,600
899cf2a34fb12f8dce9771596fd846b17c3bd23d
Output current config options in DEBUG mode
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -49,13 +49,7 @@ class TemplateConfig {\nmerged[key] = localConfig[key] || this.rootConfig[key];\n}\n- for (let key in merged) {\n- let str = merged[key];\n- if (typeof merged[key] === \"object\") {\n- str = JSON.stringify(merged[key]);\n- }\n- debug(`Config ${key} = ${str}`);\n- }\n+ debug(\"Current configuration: %o\", merged);\nreturn merged;\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Output current config options in DEBUG mode
699
13.01.2018 16:06:40
21,600
912cc29b20d43adbfa3be35700c252298ba11ab8
Adds TemplateGlob class for working with globby arguments.
[ { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -5,6 +5,7 @@ const parsePath = require(\"parse-filepath\");\nconst lodashset = require(\"lodash.set\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\n+const TemplateGlob = require(\"./TemplateGlob\");\nconst config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateData\");\n@@ -49,12 +50,11 @@ TemplateData.prototype.getGlobalDataGlob = async function() {\ndir = this.inputDir;\n}\n- return (\n- TemplatePath.normalize(\n+ return TemplateGlob.normalizePath(\ndir,\n\"/\",\n- this.config.dir.data !== \".\" ? this.config.dir.data : \"\"\n- ) + \"/**/*.json\"\n+ this.config.dir.data !== \".\" ? this.config.dir.data : \"\",\n+ \"/**/*.json\"\n);\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/TemplateGlob.js", "diff": "+const globby = require(\"globby\");\n+const TemplatePath = require(\"./TemplatePath\");\n+\n+class TemplateGlob {\n+ static normalizePath(...paths) {\n+ if (paths[0].charAt(0) === \"!\") {\n+ throw new Error(\n+ `TemplateGlob.normalizePath does not accept ! glob paths like: ${paths.join(\n+ \"\"\n+ )}`\n+ );\n+ }\n+ return TemplatePath.addLeadingDotSlash(TemplatePath.normalize(...paths));\n+ }\n+\n+ static normalize(path) {\n+ path = path.trim();\n+ if (path.charAt(0) === \"!\") {\n+ return \"!\" + TemplateGlob.normalizePath(path.substr(1));\n+ } else {\n+ return TemplateGlob.normalizePath(path);\n+ }\n+ }\n+\n+ static map(files) {\n+ if (typeof files === \"string\") {\n+ return TemplateGlob.normalize(files);\n+ } else if (Array.isArray(files)) {\n+ return files.map(function(path) {\n+ return TemplateGlob.normalize(path);\n+ });\n+ } else {\n+ return files;\n+ }\n+ }\n+}\n+\n+module.exports = TemplateGlob;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -35,10 +35,6 @@ TemplatePath.stripLeadingDotSlash = function(dir) {\nreturn dir.replace(/^\\.\\//, \"\");\n};\n-TemplatePath.cleanupPathForGlobby = function(path) {\n- return TemplatePath.addLeadingDotSlash(TemplatePath.normalize(path));\n-};\n-\nTemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\ntargetDir = TemplatePath.stripLeadingDotSlash(normalize(targetDir));\nprunedPath = TemplatePath.stripLeadingDotSlash(normalize(prunedPath));\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "const globby = require(\"globby\");\n-const normalize = require(\"normalize-path\");\nconst fs = require(\"fs-extra\");\nconst lodashCloneDeep = require(\"lodash.clonedeep\");\nconst parsePath = require(\"parse-filepath\");\n@@ -9,6 +8,7 @@ const TemplateRender = require(\"./TemplateRender\");\nconst EleventyError = require(\"./EleventyError\");\nconst Pagination = require(\"./Plugins/Pagination\");\nconst Collection = require(\"./TemplateCollection\");\n+const TemplateGlob = require(\"./TemplateGlob\");\nconst pkg = require(\"../package.json\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst config = require(\"./Config\");\n@@ -31,15 +31,15 @@ function TemplateWriter(inputPath, outputDir, extensions, templateData) {\n// Input was a directory\nif (this.input === this.inputDir) {\n- this.rawFiles = this.templateExtensions.map(\n+ this.rawFiles = TemplateGlob.map(\n+ this.templateExtensions.map(\nfunction(extension) {\n- return TemplatePath.cleanupPathForGlobby(\n- this.inputDir + \"/**/*.\" + extension\n- );\n+ return this.inputDir + \"/**/*.\" + extension;\n}.bind(this)\n+ )\n);\n} else {\n- this.rawFiles = [TemplatePath.cleanupPathForGlobby(inputPath)];\n+ this.rawFiles = TemplateGlob.map([inputPath]);\n}\nthis.watchedFiles = this.addIgnores(this.inputDir, this.rawFiles);\n@@ -105,9 +105,7 @@ TemplateWriter.getFileIgnores = function(ignoreFile) {\nreturn line.length > 0 && line.charAt(0) !== \"#\";\n})\n.map(line => {\n- let path = TemplatePath.addLeadingDotSlash(\n- TemplatePath.normalize(dir, \"/\", line)\n- );\n+ let path = TemplateGlob.normalizePath(dir, \"/\", line);\ndebug(`${ignoreFile} ignoring: ${path}`);\ntry {\nlet stat = fs.statSync(path);\n@@ -130,24 +128,18 @@ TemplateWriter.prototype.addIgnores = function(inputDir, files) {\n);\nfiles = files.concat(TemplateWriter.getFileIgnores(\".gitignore\"));\n- files = files.concat(\n- \"!\" + TemplatePath.addLeadingDotSlash(normalize(this.outputDir + \"/**\"))\n- );\n+ files = files.concat(TemplateGlob.map(\"!\" + this.outputDir + \"/**\"));\nreturn files;\n};\nTemplateWriter.prototype.addWritingIgnores = function(inputDir, files) {\nif (this.config.dir.includes) {\n- files = files.concat(\n- \"!\" + TemplatePath.addLeadingDotSlash(normalize(this.includesDir + \"/**\"))\n- );\n+ files = files.concat(TemplateGlob.map(\"!\" + this.includesDir + \"/**\"));\n}\nif (this.config.dir.data && this.config.dir.data !== \".\") {\n- files = files.concat(\n- \"!\" + TemplatePath.addLeadingDotSlash(normalize(this.dataDir + \"/**\"))\n- );\n+ files = files.concat(TemplateGlob.map(\"!\" + this.dataDir + \"/**\"));\n}\nreturn files;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateGlobTest.js", "diff": "+import test from \"ava\";\n+import globby from \"globby\";\n+import TemplatePath from \"../src/TemplatePath\";\n+import TemplateGlob from \"../src/TemplateGlob\";\n+\n+test(\"TemplatePath assumptions\", t => {\n+ t.is(TemplatePath.normalize(\"ignoredFolder\"), \"ignoredFolder\");\n+ t.is(TemplatePath.normalize(\"./ignoredFolder\"), \"ignoredFolder\");\n+ t.is(TemplatePath.normalize(\"./ignoredFolder/\"), \"ignoredFolder\");\n+});\n+\n+test(\"Normalize string argument\", t => {\n+ t.deepEqual(TemplateGlob.map(\"views\"), \"./views\");\n+ t.deepEqual(TemplateGlob.map(\"views/\"), \"./views\");\n+ t.deepEqual(TemplateGlob.map(\"./views\"), \"./views\");\n+ t.deepEqual(TemplateGlob.map(\"./views/\"), \"./views\");\n+});\n+\n+test(\"Normalize with nots\", t => {\n+ t.deepEqual(TemplateGlob.map(\"!views\"), \"!./views\");\n+ t.deepEqual(TemplateGlob.map(\"!views/\"), \"!./views\");\n+ t.deepEqual(TemplateGlob.map(\"!./views\"), \"!./views\");\n+ t.deepEqual(TemplateGlob.map(\"!./views/\"), \"!./views\");\n+});\n+\n+test(\"Normalize with globstar\", t => {\n+ t.deepEqual(TemplateGlob.map(\"!views/**\"), \"!./views/**\");\n+ t.deepEqual(TemplateGlob.map(\"!./views/**\"), \"!./views/**\");\n+});\n+\n+test(\"Normalize with globstar and star\", t => {\n+ t.deepEqual(TemplateGlob.map(\"!views/**/*\"), \"!./views/**/*\");\n+ t.deepEqual(TemplateGlob.map(\"!./views/**/*\"), \"!./views/**/*\");\n+});\n+\n+test(\"Normalize with globstar and star and file extension\", t => {\n+ t.deepEqual(TemplateGlob.map(\"!views/**/*.json\"), \"!./views/**/*.json\");\n+ t.deepEqual(TemplateGlob.map(\"!./views/**/*.json\"), \"!./views/**/*.json\");\n+});\n+\n+test(\"NormalizePath with globstar and star and file extension\", t => {\n+ t.deepEqual(\n+ TemplateGlob.normalizePath(\"views\", \"/\", \"**/*.json\"),\n+ \"./views/**/*.json\"\n+ );\n+ t.deepEqual(\n+ TemplateGlob.normalizePath(\"./views\", \"/\", \"**/*.json\"),\n+ \"./views/**/*.json\"\n+ );\n+});\n+\n+test(\"NormalizePath with globstar and star and file extension\", t => {\n+ t.throws(() => {\n+ TemplateGlob.normalizePath(\"!views/**/*.json\");\n+ });\n+\n+ t.throws(() => {\n+ TemplateGlob.normalizePath(\"!views\", \"/\", \"**/*.json\");\n+ });\n+\n+ t.throws(() => {\n+ TemplateGlob.normalizePath(\"!./views/**/*.json\");\n+ });\n+\n+ t.throws(() => {\n+ TemplateGlob.normalizePath(\"!./views\", \"/\", \"**/*.json\");\n+ });\n+});\n+\n+test(\"Normalize array argument\", t => {\n+ t.deepEqual(TemplateGlob.map([\"views\", \"content\"]), [\"./views\", \"./content\"]);\n+ t.deepEqual(TemplateGlob.map(\"views/\"), \"./views\");\n+ t.deepEqual(TemplateGlob.map(\"./views\"), \"./views\");\n+ t.deepEqual(TemplateGlob.map(\"./views/\"), \"./views\");\n+});\n+\n+test(\"matuzo project issue with globby assumptions\", async t => {\n+ let dotslashincludes = await globby(\n+ TemplateGlob.map([\n+ \"./test/stubs/globby/**/*.html\",\n+ \"!./test/stubs/globby/_includes/**/*\",\n+ \"!./test/stubs/globby/_data/**/*\"\n+ ])\n+ );\n+\n+ t.is(\n+ dotslashincludes.filter(function(file) {\n+ return file.indexOf(\"_includes\") > -1;\n+ }).length,\n+ 0\n+ );\n+\n+ let globincludes = await globby(\n+ TemplateGlob.map([\n+ \"test/stubs/globby/**/*.html\",\n+ \"!./test/stubs/globby/_includes/**/*\",\n+ \"!./test/stubs/globby/_data/**/*\"\n+ ])\n+ );\n+ t.is(\n+ globincludes.filter(function(file) {\n+ return file.indexOf(\"_includes\") > -1;\n+ }).length,\n+ 0\n+ );\n+});\n+\n+test(\"globby assumptions\", async t => {\n+ let glob = await globby(\"test/stubs/ignoredFolder/**\");\n+ t.is(glob.length, 1);\n+\n+ let glob2 = await globby(\"test/stubs/ignoredFolder/**/*\");\n+ t.is(glob2.length, 1);\n+\n+ let glob3 = await globby([\n+ \"./test/stubs/ignoredFolder/**/*.md\",\n+ \"!./test/stubs/ignoredFolder/**\"\n+ ]);\n+ t.is(glob3.length, 0);\n+\n+ let glob4 = await globby([\n+ \"./test/stubs/ignoredFolder/*.md\",\n+ \"!./test/stubs/ignoredFolder/**\"\n+ ]);\n+ t.is(glob4.length, 0);\n+\n+ let glob5 = await globby([\n+ \"./test/stubs/ignoredFolder/ignored.md\",\n+ \"!./test/stubs/ignoredFolder/**\"\n+ ]);\n+ t.is(glob5.length, 0);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -62,58 +62,6 @@ test(\"Output is a subdir of input\", async t => {\n);\n});\n-test(\"globby assumptions\", async t => {\n- let glob = await globby(\"test/stubs/ignoredFolder/**\");\n- t.is(glob.length, 1);\n-\n- let glob2 = await globby(\"test/stubs/ignoredFolder/**/*\");\n- t.is(glob2.length, 1);\n-\n- let glob3 = await globby([\n- \"./test/stubs/ignoredFolder/**/*.md\",\n- \"!./test/stubs/ignoredFolder/**\"\n- ]);\n- t.is(glob3.length, 0);\n-\n- let glob4 = await globby([\n- \"./test/stubs/ignoredFolder/*.md\",\n- \"!./test/stubs/ignoredFolder/**\"\n- ]);\n- t.is(glob4.length, 0);\n-\n- let glob5 = await globby([\n- \"./test/stubs/ignoredFolder/ignored.md\",\n- \"!./test/stubs/ignoredFolder/**\"\n- ]);\n- t.is(glob5.length, 0);\n-});\n-\n-test(\"matuzo project issue with globby assumptions\", async t => {\n- let dotslashincludes = await globby([\n- \"./test/stubs/globby/**/*.html\",\n- \"!./test/stubs/globby/_includes/**/*\",\n- \"!./test/stubs/globby/_data/**/*\"\n- ]);\n- t.is(\n- dotslashincludes.filter(function(file) {\n- return file.indexOf(\"_includes\") > -1;\n- }).length,\n- 0\n- );\n-\n- let globincludes = await globby([\n- TemplatePath.cleanupPathForGlobby(\"test/stubs/globby/**/*.html\"),\n- \"!./test/stubs/globby/_includes/**/*\",\n- \"!./test/stubs/globby/_data/**/*\"\n- ]);\n- t.is(\n- globincludes.filter(function(file) {\n- return file.indexOf(\"_includes\") > -1;\n- }).length,\n- 0\n- );\n-});\n-\ntest(\".eleventyignore parsing\", t => {\nlet ignores = new TemplateWriter.getFileIgnores(\n\"./test/stubs/.eleventyignore\"\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds TemplateGlob class for working with globby arguments.
699
13.01.2018 22:44:54
21,600
3375edcd790a9251de57862d6d475ea4b30d6b1a
Layouts can now be a full path instead of a filename or basename (including subdirectories). Make a `layouts` folder inside of `_includes` if you want!
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -8,9 +8,10 @@ const { DateTime } = require(\"luxon\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\n-const Layout = require(\"./TemplateLayout\");\n+const TemplateLayout = require(\"./TemplateLayout\");\nconst Eleventy = require(\"./Eleventy\");\nconst config = require(\"./Config\");\n+const debug = require(\"debug\")(\"Eleventy:Template\");\nclass Template {\nconstructor(path, inputDir, outputDir, templateData) {\n@@ -118,8 +119,8 @@ class Template {\nreturn this.frontMatter.content;\n}\n- getLayoutTemplate(name) {\n- let path = new Layout(name, this.layoutsDir).getFullPath();\n+ getLayoutTemplate(layoutPath) {\n+ let path = new TemplateLayout(layoutPath, this.layoutsDir).getFullPath();\nreturn new Template(path, this.inputDir, this.outputDir);\n}\n@@ -205,11 +206,12 @@ class Template {\n}\nasync renderLayout(tmpl, tmplData) {\n- let layoutName = tmplData[this.config.keys.layout];\n+ let layoutPath = tmplData[this.config.keys.layout];\n+ debug(`Template ${this.inputPath} is using layout: ${layoutPath}`);\n// TODO make layout key to be available to templates (without it causing issues with merge below)\ndelete tmplData[this.config.keys.layout];\n- let layout = this.getLayoutTemplate(layoutName);\n+ let layout = this.getLayoutTemplate(layoutPath);\nlet layoutData = await layout.getData(tmplData);\n// console.log( await this.renderContent( tmpl.getPreRender(), tmplData ) );\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "const fs = require(\"fs-extra\");\nconst config = require(\"./Config\");\n-function TemplateLayout(name, dir) {\n+function TemplateLayout(path, dir) {\nthis.config = config.getConfig();\nthis.dir = dir;\n- this.name = name;\n- this.pathNameAlreadyHasExtension = this.dir + \"/\" + this.name;\n+ this.path = path;\n+ this.pathAlreadyHasExtension = this.dir + \"/\" + this.path;\n+\nif (\n- this.name.split(\".\").length > 0 &&\n- fs.existsSync(this.pathNameAlreadyHasExtension)\n+ this.path.split(\".\").length > 0 &&\n+ fs.existsSync(this.pathAlreadyHasExtension)\n) {\n- this.filename = this.name;\n- this.fullPath = this.pathNameAlreadyHasExtension;\n+ this.filename = this.path;\n+ this.fullPath = this.pathAlreadyHasExtension;\n} else {\nthis.filename = this.findFileName();\nthis.fullPath = this.dir + \"/\" + this.filename;\n@@ -31,7 +32,7 @@ TemplateLayout.prototype.findFileName = function() {\nif (!fs.existsSync(this.dir)) {\nthrow Error(\n\"TemplateLayout directory does not exist for \" +\n- this.name +\n+ this.path +\n\": \" +\nthis.dir\n);\n@@ -39,7 +40,7 @@ TemplateLayout.prototype.findFileName = function() {\nthis.config.templateFormats.forEach(\nfunction(extension) {\n- let filename = this.name + \".\" + extension;\n+ let filename = this.path + \".\" + extension;\nif (!file && fs.existsSync(this.dir + \"/\" + filename)) {\nfile = filename;\n}\n" }, { "change_type": "ADD", "old_path": "test/stubs/_includes/layouts/inasubdir.njk", "new_path": "test/stubs/_includes/layouts/inasubdir.njk", "diff": "" } ]
JavaScript
MIT License
11ty/eleventy
Layouts can now be a full path instead of a filename or basename (including subdirectories). Make a `layouts` folder inside of `_includes` if you want!
699
14.01.2018 13:12:43
21,600
0aa441a16dbbc50cb143952b49fac02477ed6139
Refactor TemplateWriter to use a formal TemplateMap class, where metadata about all content and collections are stored.
[ { "change_type": "MODIFY", "old_path": "src/EleventyConfig.js", "new_path": "src/EleventyConfig.js", "diff": "@@ -22,6 +22,12 @@ class EleventyConfig {\n}\naddCollection(name, callback) {\n+ if (this.collections[name]) {\n+ throw new Error(\n+ `config.addCollection(${name}) already exists. Try a different name for your collection.`\n+ );\n+ }\n+\nthis.collections[name] = callback;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -360,6 +360,13 @@ class Template {\nreturn date;\n}\n+ async isEqual(compareTo) {\n+ return (\n+ compareTo.getInputPath() === this.getInputPath() &&\n+ (await compareTo.getOutputPath()) === (await this.getOutputPath())\n+ );\n+ }\n+\nasync getMapped() {\nlet outputPath = await this.getOutputPath();\nlet url = await this.getOutputLink();\n@@ -372,6 +379,7 @@ class Template {\ndata: data\n};\n+ // console.log( await this.render(data) );\nmap.date = await this.getMappedDate(data);\nreturn map;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -10,36 +10,25 @@ class TemplateCollection extends Sortable {\nsuper.add(templateMap);\n}\n- _assignActiveTemplate(items, activeTemplate) {\n- if (activeTemplate) {\n- return items.map(function(templateMap) {\n- templateMap.active = templateMap.template === activeTemplate;\n- return templateMap;\n- });\n- } else {\n- return items;\n- }\n- }\n-\ngetAll() {\nreturn this.items;\n}\n- getAllSorted(activeTemplate) {\n- return this._assignActiveTemplate(\n- this.sort(Sortable.sortFunctionDateInputPath),\n- activeTemplate\n- );\n+ getAllSorted() {\n+ return this.sort(Sortable.sortFunctionDateInputPath);\n}\n- getFilteredByTag(tagName, activeTemplate) {\n- return this.getAllSorted(activeTemplate).filter(function(item) {\n- return (\n- !tagName ||\n- ((Array.isArray(item.data.tags) ||\n- typeof item.data.tags === \"string\") &&\n- item.data.tags.indexOf(tagName) > -1)\n- );\n+ getFilteredByTag(tagName) {\n+ return this.getAllSorted().filter(function(item) {\n+ if (!tagName) {\n+ return true;\n+ } else if (\n+ Array.isArray(item.data.tags) ||\n+ typeof item.data.tags === \"string\"\n+ ) {\n+ return item.data.tags.indexOf(tagName) > -1;\n+ }\n+ return false;\n});\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/TemplateMap.js", "diff": "+const lodashCloneDeep = require(\"lodash.clonedeep\");\n+const Template = require(\"./Template\");\n+const TemplateCollection = require(\"./TemplateCollection\");\n+const eleventyConfig = require(\"./EleventyConfig\");\n+const debug = require(\"debug\")(\"Eleventy:TemplateMap\");\n+\n+class TemplateMap {\n+ constructor() {\n+ this.map = [];\n+ this.collection = new TemplateCollection();\n+ this.collectionsData = null;\n+ this.tags = [];\n+ }\n+\n+ async add(template) {\n+ this.map.push(await template.getMapped());\n+ }\n+\n+ getMap() {\n+ return this.map;\n+ }\n+\n+ cache() {\n+ this.populateCollection();\n+ this.tags = this.getAllTags();\n+ this.collectionsData = this.getAllCollectionsData();\n+ }\n+\n+ populateCollection() {\n+ this.collection = new TemplateCollection();\n+ for (let map of this.map) {\n+ this.collection.add(map);\n+ }\n+ }\n+\n+ createTemplateMapCopy(filteredMap) {\n+ let copy = [];\n+ for (let map of filteredMap) {\n+ let mapCopy = lodashCloneDeep(map);\n+\n+ // For simplification, maybe re-add this later?\n+ // delete mapCopy.template;\n+ // Circular reference\n+ delete mapCopy.data.collections;\n+\n+ copy.push(mapCopy);\n+ }\n+\n+ return copy;\n+ }\n+\n+ getAllTags() {\n+ let allTags = {};\n+ for (let map of this.map) {\n+ let tags = map.data.tags;\n+ if (Array.isArray(tags)) {\n+ for (let tag of tags) {\n+ allTags[tag] = true;\n+ }\n+ } else if (tags) {\n+ allTags[tags] = true;\n+ }\n+ }\n+ return Object.keys(allTags);\n+ }\n+\n+ getAllCollectionsData() {\n+ let collections = {};\n+ collections.all = this.createTemplateMapCopy(\n+ this.collection.getAllSorted()\n+ );\n+ debug(`Collection: collections.all has ${collections.all.length} items.`);\n+\n+ for (let tag of this.tags) {\n+ collections[tag] = this.createTemplateMapCopy(\n+ this.collection.getFilteredByTag(tag)\n+ );\n+ debug(\n+ `Collection: collections.${tag} has ${collections[tag].length} items.`\n+ );\n+ }\n+\n+ let configCollections = eleventyConfig.getCollections();\n+ for (let name in configCollections) {\n+ collections[name] = this.createTemplateMapCopy(\n+ configCollections[name](this.collection)\n+ );\n+ debug(\n+ `Collection: collections.${name} has ${collections[name].length} items.`\n+ );\n+ }\n+\n+ // console.log( \"collections>>>>\", collections );\n+ // console.log( \">>>>> end collections\" );\n+\n+ return collections;\n+ }\n+\n+ async assignActiveTemplate(activeTemplate) {\n+ if (activeTemplate) {\n+ for (let collectionName in this.collectionsData) {\n+ for (let item of this.collectionsData[collectionName]) {\n+ // Assign active keys for all templates (both true and false)\n+ item.active = await item.template.isEqual(activeTemplate);\n+ }\n+ }\n+ }\n+ }\n+\n+ async getCollectionsDataForTemplate(template) {\n+ if (!this.collectionsData) {\n+ this.cache();\n+ }\n+\n+ await this.assignActiveTemplate(template);\n+\n+ return this.collectionsData;\n+ }\n+}\n+\n+module.exports = TemplateMap;\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyConfigTest.js", "new_path": "test/EleventyConfigTest.js", "diff": "@@ -16,3 +16,14 @@ test(\"Add Collections\", t => {\neleventyConfig.addCollection(\"myCollection\", function(collection) {});\nt.deepEqual(Object.keys(eleventyConfig.getCollections()), [\"myCollection\"]);\n});\n+\n+test(\"Add Collections throws error on key collision\", t => {\n+ eleventyConfig.addCollection(\"myCollectionCollision\", function(\n+ collection\n+ ) {});\n+ t.throws(() => {\n+ eleventyConfig.addCollection(\"myCollectionCollision\", function(\n+ collection\n+ ) {});\n+ });\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateCollectionTest.js", "new_path": "test/TemplateCollectionTest.js", "diff": "@@ -77,20 +77,17 @@ test(\"getFilteredByTag (added out of order, sorted)\", async t => {\nawait c.addTemplate(tmpl2);\nawait c.addTemplate(tmpl1);\n- let posts = c.getFilteredByTag(\"post\", tmpl3);\n+ let posts = c.getFilteredByTag(\"post\");\nt.is(posts.length, 2);\nt.deepEqual(posts[0].template, tmpl1);\nt.deepEqual(posts[1].template, tmpl3);\n- t.true(posts[1].active);\n- let cats = c.getFilteredByTag(\"cat\", tmpl1);\n+ let cats = c.getFilteredByTag(\"cat\");\nt.truthy(cats.length);\nt.is(cats.length, 2);\nt.deepEqual(cats[0].template, tmpl2);\n- t.false(cats[0].active);\n- let dogs = c.getFilteredByTag(\"dog\", tmpl2);\n+ let dogs = c.getFilteredByTag(\"dog\");\nt.truthy(dogs.length);\nt.deepEqual(dogs[0].template, tmpl1);\n- t.false(dogs[0].active);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "@@ -15,7 +15,7 @@ test(\"Template Config local config overrides base config\", async t => {\nt.true(Object.keys(cfg.keys).length > 1);\nt.is(Object.keys(cfg.handlebarsHelpers).length, 0);\n- t.is(Object.keys(cfg.nunjucksFilters).length, 2);\n+ t.true(Object.keys(cfg.nunjucksFilters).length > 2);\nt.true(Object.keys(cfg.filters).length >= 1);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateMapTest.js", "diff": "+import test from \"ava\";\n+import Template from \"../src/Template\";\n+import TemplateMap from \"../src/TemplateMap\";\n+\n+let tmpl1 = new Template(\n+ \"./test/stubs/collection/test1.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+);\n+let tmpl2 = new Template(\n+ \"./test/stubs/collection/test2.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+);\n+\n+test(\"populating the collection twice should clear the previous values (--watch was making it cumulative)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ tm.cache();\n+ tm.cache();\n+\n+ t.is(tm.getMap().length, 2);\n+});\n+\n+test(\"Active template flags are set properly by `assignActiveTemplate`\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+ let collectionsData = await tm.getCollectionsDataForTemplate(tmpl1);\n+ t.is(collectionsData.all.length, 2);\n+ t.true(collectionsData.all[0].active);\n+ t.false(collectionsData.all[1].active);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -353,6 +353,7 @@ test(\"Clone the template\", async t => {\nt.is(await tmpl.getOutputPath(), \"./dist/default/index.html\");\nt.is(await cloned.getOutputPath(), \"./dist/default/index.html\");\n+ t.is(await tmpl.isEqual(cloned), true);\n});\ntest(\"Permalink with variables!\", async t => {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -87,7 +87,7 @@ test(\".eleventyignore files\", async t => {\n);\n});\n-test(\"_getTemplatesMap\", async t => {\n+test(\"_createTemplateMap\", async t => {\nlet tw = new TemplateWriter(\n\"./test/stubs/writeTest\",\n\"./test/stubs/_writeTestSite\",\n@@ -97,22 +97,21 @@ test(\"_getTemplatesMap\", async t => {\nlet paths = await tw._getAllPaths();\nt.true(paths.length > 0);\n- let templatesMap = await tw._getTemplatesMap(paths);\n- t.true(templatesMap.length > 0);\n- t.truthy(templatesMap[0].template);\n- t.truthy(templatesMap[0].data);\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let map = templateMap.getMap();\n+ t.true(map.length > 0);\n+ t.truthy(map[0].template);\n+ t.truthy(map[0].data);\n});\n-test(\"_getCollectionsData\", async t => {\n+test(\"getCollectionsDataForTemplate\", async t => {\nlet tw = new TemplateWriter(\"./test/stubs/collection\", \"./test/stubs/_site\", [\n\"md\"\n]);\nlet paths = await tw._getAllPaths();\n- let templatesMap = await tw._getTemplatesMap(paths);\n- tw._populateCollection(templatesMap);\n-\n- let collectionsData = tw._getCollectionsData();\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let collectionsData = await templateMap.getCollectionsDataForTemplate();\nt.is(collectionsData.post.length, 2);\nt.is(collectionsData.cat.length, 2);\nt.is(collectionsData.dog.length, 1);\n@@ -124,35 +123,20 @@ test(\"_getAllTags\", async t => {\n]);\nlet paths = await tw._getAllPaths();\n- let templatesMap = await tw._getTemplatesMap(paths);\n- let tags = tw._getAllTagsFromMap(templatesMap);\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let tags = templateMap.getAllTags();\nt.deepEqual(tags.sort(), [\"cat\", \"dog\", \"post\"].sort());\n});\n-test(\"populating the collection twice should clear the previous values (--watch was making it cumulative)\", async t => {\n- let tw = new TemplateWriter(\"./test/stubs/collection\", \"./test/stubs/_site\", [\n- \"md\"\n- ]);\n-\n- let paths = await tw._getAllPaths();\n- let templatesMap = await tw._getTemplatesMap(paths);\n- tw._populateCollection(templatesMap);\n- tw._populateCollection(templatesMap);\n-\n- t.is(tw._getCollectionsData().post.length, 2);\n-});\n-\ntest(\"Collection of files sorted by date\", async t => {\nlet tw = new TemplateWriter(\"./test/stubs/dates\", \"./test/stubs/_site\", [\n\"md\"\n]);\nlet paths = await tw._getAllPaths();\n- let templatesMap = await tw._getTemplatesMap(paths);\n- tw._populateCollection(templatesMap);\n-\n- let collectionsData = tw._getCollectionsData();\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let collectionsData = await templateMap.getCollectionsDataForTemplate();\nt.is(collectionsData.dateTestTag.length, 5);\n});\n@@ -163,20 +147,18 @@ test(\"_getCollectionsData with custom collection (ascending)\", async t => {\n[\"md\"]\n);\n- let paths = await tw._getAllPaths();\n- let templatesMap = await tw._getTemplatesMap(paths);\n- tw._populateCollection(templatesMap);\n-\n- eleventyConfig.addCollection(\"customPosts\", function(collection) {\n+ eleventyConfig.addCollection(\"customPostsAsc\", function(collection) {\nreturn collection.getFilteredByTag(\"post\").sort(function(a, b) {\nreturn a.date - b.date;\n});\n});\n- let collectionsData = tw._getCollectionsData();\n- t.is(collectionsData.customPosts.length, 2);\n- t.is(parsePath(collectionsData.customPosts[0].inputPath).base, \"test1.md\");\n- t.is(parsePath(collectionsData.customPosts[1].inputPath).base, \"test2.md\");\n+ let paths = await tw._getAllPaths();\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let collectionsData = await templateMap.getCollectionsDataForTemplate();\n+ t.is(collectionsData.customPostsAsc.length, 2);\n+ t.is(parsePath(collectionsData.customPostsAsc[0].inputPath).base, \"test1.md\");\n+ t.is(parsePath(collectionsData.customPostsAsc[1].inputPath).base, \"test2.md\");\n});\ntest(\"_getCollectionsData with custom collection (descending)\", async t => {\n@@ -186,17 +168,15 @@ test(\"_getCollectionsData with custom collection (descending)\", async t => {\n[\"md\"]\n);\n- let paths = await tw._getAllPaths();\n- let templatesMap = await tw._getTemplatesMap(paths);\n- tw._populateCollection(templatesMap);\n-\neleventyConfig.addCollection(\"customPosts\", function(collection) {\nreturn collection.getFilteredByTag(\"post\").sort(function(a, b) {\nreturn b.date - a.date;\n});\n});\n- let collectionsData = tw._getCollectionsData();\n+ let paths = await tw._getAllPaths();\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let collectionsData = await templateMap.getCollectionsDataForTemplate();\nt.is(collectionsData.customPosts.length, 2);\nt.is(parsePath(collectionsData.customPosts[0].inputPath).base, \"test2.md\");\nt.is(parsePath(collectionsData.customPosts[1].inputPath).base, \"test1.md\");\n@@ -209,10 +189,6 @@ test(\"_getCollectionsData with custom collection (filter only to markdown input)\n[\"md\"]\n);\n- let paths = await tw._getAllPaths();\n- let templatesMap = await tw._getTemplatesMap(paths);\n- tw._populateCollection(templatesMap);\n-\neleventyConfig.addCollection(\"onlyMarkdown\", function(collection) {\nreturn collection.getAllSorted().filter(function(item) {\nlet extension = item.inputPath.split(\".\").pop();\n@@ -220,7 +196,9 @@ test(\"_getCollectionsData with custom collection (filter only to markdown input)\n});\n});\n- let collectionsData = tw._getCollectionsData();\n+ let paths = await tw._getAllPaths();\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let collectionsData = await templateMap.getCollectionsDataForTemplate();\nt.is(collectionsData.onlyMarkdown.length, 2);\nt.is(parsePath(collectionsData.onlyMarkdown[0].inputPath).base, \"test1.md\");\nt.is(parsePath(collectionsData.onlyMarkdown[1].inputPath).base, \"test2.md\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Refactor TemplateWriter to use a formal TemplateMap class, where metadata about all content and collections are stored.
699
14.01.2018 22:12:02
21,600
1562597e5dfaf6e9d82d0a24ff35c88a8a1cf279
Adds `templateContent` to template map for RSS feeds to output post content (without layout wraps).
[ { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -9,37 +9,58 @@ class TemplateMap {\nthis.map = [];\nthis.collection = new TemplateCollection();\nthis.collectionsData = null;\n- this.tags = [];\n}\nasync add(template) {\n- this.map.push(await template.getMapped());\n+ let map = await template.getMapped();\n+ this.map.push(map);\n+ this.collection.add(map);\n}\ngetMap() {\nreturn this.map;\n}\n- cache() {\n- this.populateCollection();\n- this.tags = this.getAllTags();\n- this.collectionsData = this.getAllCollectionsData();\n+ getCollection() {\n+ return this.collection;\n}\n- populateCollection() {\n- this.collection = new TemplateCollection();\n+ async cache() {\n+ this.collectionsData = await this.getAllCollectionsData();\n+ await this.populateDataInMap();\n+ this.populateCollectionsWithContent();\n+ }\n+\n+ getMapTemplateIndex(item) {\n+ let inputPath = item.inputPath;\n+ for (let j = 0, k = this.map.length; j < k; j++) {\n+ if (this.map[j].inputPath === inputPath) {\n+ return j;\n+ }\n+ }\n+\n+ return -1;\n+ }\n+\n+ async populateDataInMap() {\nfor (let map of this.map) {\n- this.collection.add(map);\n+ map.data.collections = await this.getCollectionsDataForTemplate(\n+ map.template\n+ );\n+ }\n+\n+ for (let map of this.map) {\n+ map.template.setWrapWithLayouts(false);\n+ map.templateContent = await map.template.getFinalContent(map.data);\n+ map.template.setWrapWithLayouts(true);\n}\n}\n- createTemplateMapCopy(filteredMap) {\n+ async createTemplateMapCopy(filteredMap) {\nlet copy = [];\nfor (let map of filteredMap) {\nlet mapCopy = lodashCloneDeep(map);\n- // For simplification, maybe re-add this later?\n- // delete mapCopy.template;\n// Circular reference\ndelete mapCopy.data.collections;\n@@ -64,15 +85,16 @@ class TemplateMap {\nreturn Object.keys(allTags);\n}\n- getAllCollectionsData() {\n+ async getAllCollectionsData() {\nlet collections = {};\n- collections.all = this.createTemplateMapCopy(\n+ collections.all = await this.createTemplateMapCopy(\nthis.collection.getAllSorted()\n);\ndebug(`Collection: collections.all has ${collections.all.length} items.`);\n- for (let tag of this.tags) {\n- collections[tag] = this.createTemplateMapCopy(\n+ let tags = this.getAllTags();\n+ for (let tag of tags) {\n+ collections[tag] = await this.createTemplateMapCopy(\nthis.collection.getFilteredByTag(tag)\n);\ndebug(\n@@ -82,7 +104,7 @@ class TemplateMap {\nlet configCollections = eleventyConfig.getCollections();\nfor (let name in configCollections) {\n- collections[name] = this.createTemplateMapCopy(\n+ collections[name] = await this.createTemplateMapCopy(\nconfigCollections[name](this.collection)\n);\ndebug(\n@@ -90,12 +112,20 @@ class TemplateMap {\n);\n}\n- // console.log( \"collections>>>>\", collections );\n- // console.log( \">>>>> end collections\" );\n-\nreturn collections;\n}\n+ populateCollectionsWithContent() {\n+ for (let collectionName in this.collectionsData) {\n+ for (let item of this.collectionsData[collectionName]) {\n+ let index = this.getMapTemplateIndex(item);\n+ if (index !== -1) {\n+ item.templateContent = this.map[index].templateContent;\n+ }\n+ }\n+ }\n+ }\n+\nasync assignActiveTemplate(activeTemplate) {\nif (activeTemplate) {\nfor (let collectionName in this.collectionsData) {\n@@ -109,7 +139,7 @@ class TemplateMap {\nasync getCollectionsDataForTemplate(template) {\nif (!this.collectionsData) {\n- this.cache();\n+ await this.cache();\n}\nawait this.assignActiveTemplate(template);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -18,8 +18,8 @@ test(\"populating the collection twice should clear the previous values (--watch\nawait tm.add(tmpl1);\nawait tm.add(tmpl2);\n- tm.cache();\n- tm.cache();\n+ await tm.cache();\n+ await tm.cache();\nt.is(tm.getMap().length, 2);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -175,6 +175,63 @@ test(\"One Layout (using new content var)\", async t => {\nt.is(mergedFrontMatter.keylayout, \"valuelayout\");\n});\n+test(\"One Layout (using layoutContent)\", async t => {\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ let tmpl = new Template(\n+ \"./test/stubs/templateWithLayoutContent.ejs\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\n+\n+ t.is(tmpl.frontMatter.data[config.keys.layout], \"defaultLayoutLayoutContent\");\n+\n+ let data = await tmpl.getData();\n+ t.is(data[config.keys.layout], \"defaultLayoutLayoutContent\");\n+\n+ t.is(\n+ cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ `<div id=\"layout\">\n+ <p>Hello.</p>\n+</div>`\n+ );\n+\n+ let mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\n+ tmpl,\n+ tmpl.getFrontMatterData()\n+ );\n+\n+ t.is(mergedFrontMatter.keymain, \"valuemain\");\n+ t.is(mergedFrontMatter.keylayout, \"valuelayout\");\n+});\n+\n+test(\"One Layout (layouts disabled)\", async t => {\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ let tmpl = new Template(\n+ \"./test/stubs/templateWithLayoutContent.ejs\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\n+\n+ tmpl.setWrapWithLayouts(false);\n+\n+ t.is(tmpl.frontMatter.data[config.keys.layout], \"defaultLayoutLayoutContent\");\n+\n+ let data = await tmpl.getData();\n+ t.is(data[config.keys.layout], \"defaultLayoutLayoutContent\");\n+\n+ t.is(cleanHtml(await tmpl.render(data)), `<p>Hello.</p>`);\n+\n+ let mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\n+ tmpl,\n+ tmpl.getFrontMatterData()\n+ );\n+\n+ t.is(mergedFrontMatter.keymain, \"valuemain\");\n+ t.is(mergedFrontMatter.keylayout, \"valuelayout\");\n+});\n+\ntest(\"One Layout (_layoutContent deprecated but supported)\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/_includes/defaultLayoutLayoutContent.ejs", "diff": "+---\n+keylayout: valuelayout\n+postRank: 4\n+daysPosted: 152\n+yearsPosted: 0.4\n+---\n+\n+<div id=\"layout\">\n+ <%- layoutContent %>\n+</div>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateWithLayoutContent.ejs", "diff": "+---\n+layout: defaultLayoutLayoutContent\n+keymain: valuemain\n+title: 'Font Aliasing, or How to Rename a Font in CSS'\n+permalink: /rename-font/\n+---\n+<p>Hello.</p>\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `templateContent` to template map for RSS feeds to output post content (without layout wraps).
699
14.01.2018 22:22:08
21,600
d4b40382cb26c94afef2f6eb3cb2d2893ad48d3e
More debugging for Template layouts.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -261,12 +261,20 @@ class Template {\ndata = await this.getRenderedData();\n}\n+ if (!this.wrapWithLayouts) {\n+ debug(\n+ \"Template.render is bypassing wrapping content in layouts for %o.\",\n+ this.inputPath\n+ );\n+ }\n+\nif (\nthis.wrapWithLayouts &&\n(data[this.config.keys.layout] || this.initialLayout)\n) {\nreturn this.renderLayout(this, data, this.initialLayout);\n} else {\n+ debug(\"Template.render renderContent for %o\", this.inputPath);\nreturn this.renderContent(this.getPreRender(), data);\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
More debugging for Template layouts.
699
14.01.2018 22:25:45
21,600
8f6bf6578a4cb78b57e4c482e38ad6a852b528c5
There are two filters right now.
[ { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "@@ -15,7 +15,7 @@ test(\"Template Config local config overrides base config\", async t => {\nt.true(Object.keys(cfg.keys).length > 1);\nt.is(Object.keys(cfg.handlebarsHelpers).length, 0);\n- t.true(Object.keys(cfg.nunjucksFilters).length > 2);\n+ t.true(Object.keys(cfg.nunjucksFilters).length >= 2);\nt.true(Object.keys(cfg.filters).length >= 1);\n" } ]
JavaScript
MIT License
11ty/eleventy
There are two filters right now.
699
15.01.2018 13:22:43
21,600
bf9dc496a3d0e935dcaf0dc7ab124add99fce336
Add tests for circular `templateContent` references.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -256,6 +256,13 @@ class Template {\nreturn fn(data);\n}\n+ async renderWithoutLayouts(data) {\n+ this.setWrapWithLayouts(false);\n+ let ret = await this.render(data);\n+ this.setWrapWithLayouts(true);\n+ return ret;\n+ }\n+\nasync render(data) {\nif (!data) {\ndata = await this.getRenderedData();\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -26,6 +26,7 @@ class TemplateMap {\n}\nasync cache() {\n+ debug(\"Caching collections objects.\");\nthis.collectionsData = await this.getAllCollectionsData();\nawait this.populateDataInMap();\nthis.populateCollectionsWithContent();\n@@ -48,12 +49,14 @@ class TemplateMap {\nmap.template\n);\n}\n+ debug(\"Added this.map[...].data.collections\");\nfor (let map of this.map) {\nmap.template.setWrapWithLayouts(false);\nmap.templateContent = await map.template.getFinalContent(map.data);\nmap.template.setWrapWithLayouts(true);\n}\n+ debug(\"Added this.map[...].templateContent\");\n}\nasync createTemplateMapCopy(filteredMap) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -3,16 +3,25 @@ import Template from \"../src/Template\";\nimport TemplateMap from \"../src/TemplateMap\";\nlet tmpl1 = new Template(\n- \"./test/stubs/collection/test1.md\",\n+ \"./test/stubs/templateMapCollection/test1.md\",\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\nlet tmpl2 = new Template(\n- \"./test/stubs/collection/test2.md\",\n+ \"./test/stubs/templateMapCollection/test2.md\",\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\n+test(\"TemplateMap has collections added\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ t.is(tm.getMap().length, 2);\n+ t.is(tm.getCollection().getAll().length, 2);\n+});\n+\ntest(\"populating the collection twice should clear the previous values (--watch was making it cumulative)\", async t => {\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\n@@ -33,3 +42,87 @@ test(\"Active template flags are set properly by `assignActiveTemplate`\", async t\nt.true(collectionsData.all[0].active);\nt.false(collectionsData.all[1].active);\n});\n+\n+test(\"TemplateMap adds collections data and has templateContent values\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let map = tm.getMap();\n+ t.falsy(map[0].templateContent);\n+ t.falsy(map[1].templateContent);\n+ t.falsy(map[0].data.collections);\n+ t.falsy(map[1].data.collections);\n+\n+ await tm.cache();\n+ t.truthy(map[0].templateContent);\n+ t.truthy(map[1].templateContent);\n+ t.truthy(map[0].data.collections);\n+ t.truthy(map[1].data.collections);\n+ t.is(map[0].data.collections.post.length, 1);\n+ t.is(map[0].data.collections.all.length, 2);\n+ t.is(map[1].data.collections.post.length, 1);\n+ t.is(map[1].data.collections.all.length, 2);\n+\n+ t.is(\n+ await map[0].template.renderWithoutLayouts(map[0].data),\n+ map[0].templateContent\n+ );\n+ t.is(\n+ await map[1].template.renderWithoutLayouts(map[1].data),\n+ map[1].templateContent\n+ );\n+});\n+\n+test(\"TemplateMap circular references (map without templateContent)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(\n+ new Template(\n+ \"./test/stubs/templateMapCollection/test3.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ )\n+ );\n+\n+ let map = tm.getMap();\n+ t.falsy(map[0].templateContent);\n+ t.falsy(map[0].data.collections);\n+\n+ await tm.cache();\n+ t.truthy(map[0].templateContent);\n+ t.truthy(map[0].data.collections);\n+ t.is(map[0].data.collections.all.length, 1);\n+ t.is(\n+ await map[0].template.renderWithoutLayouts(map[0].data),\n+ map[0].templateContent\n+ );\n+});\n+\n+test(\"TemplateMap circular references (map.templateContent)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(\n+ new Template(\n+ \"./test/stubs/templateMapCollection/templateContent.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ )\n+ );\n+\n+ let map = tm.getMap();\n+ t.falsy(map[0].templateContent);\n+ t.falsy(map[0].data.collections);\n+\n+ await tm.cache();\n+ t.truthy(map[0].templateContent);\n+ t.truthy(map[0].data.collections);\n+ t.is(map[0].data.collections.all.length, 1);\n+\n+ // templateContent references are not available inside of templateContent strings\n+ t.is(map[0].templateContent.trim(), \"<h1>Test</h1>\");\n+\n+ // first cached templateContent is available to future render calls (but will not loop in any way).\n+ t.is(\n+ (await map[0].template.renderWithoutLayouts(map[0].data)).trim(),\n+ \"<h1>Test</h1>\\n<h1>Test</h1>\"\n+ );\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateMapCollection/templateContent.md", "diff": "+---\n+tags: circle\n+---\n+\n+# Test\n+\n+{{ collections.circle[0].templateContent }}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateMapCollection/test1.md", "diff": "+---\n+title: Test Title\n+tags:\n+ - post\n+ - dog\n+---\n+\n+# Test 1\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateMapCollection/test2.md", "diff": "+---\n+tags: cat\n+---\n+\n+# Test 2\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateMapCollection/test3.md", "diff": "+---\n+tags: circle\n+---\n+\n+# {{ collections.circle.length }}, {{ collections.circle[0].url }}\n" } ]
JavaScript
MIT License
11ty/eleventy
Add tests for circular `templateContent` references.
699
15.01.2018 13:23:11
21,600
d85cdecfccd3d02b30fa8bc4559877185d2e027b
New code coverage (and npm tasks)
[ { "change_type": "MODIFY", "old_path": "docs-src/.eleventy.docs.js", "new_path": "docs-src/.eleventy.docs.js", "diff": "const TemplatePath = require(\"../src/TemplatePath\");\n-console.log();\n+\nmodule.exports = {\ntemplateFormats: [\"njk\"],\ndir: {\n" }, { "change_type": "MODIFY", "old_path": "docs-src/_data/coverage.json", "new_path": "docs-src/_data/coverage.json", "diff": "{\n\"total\": {\n- \"lines\": { \"total\": 857, \"covered\": 733, \"skipped\": 0, \"pct\": 85.53 },\n- \"statements\": { \"total\": 857, \"covered\": 733, \"skipped\": 0, \"pct\": 85.53 },\n- \"functions\": { \"total\": 201, \"covered\": 160, \"skipped\": 0, \"pct\": 79.6 },\n- \"branches\": { \"total\": 225, \"covered\": 180, \"skipped\": 0, \"pct\": 80 }\n+ \"lines\": { \"total\": 1007, \"covered\": 874, \"skipped\": 0, \"pct\": 86.79 },\n+ \"statements\": { \"total\": 1007, \"covered\": 874, \"skipped\": 0, \"pct\": 86.79 },\n+ \"functions\": { \"total\": 230, \"covered\": 185, \"skipped\": 0, \"pct\": 80.43 },\n+ \"branches\": { \"total\": 269, \"covered\": 222, \"skipped\": 0, \"pct\": 82.53 }\n},\n\"/Users/zachleat/Code/eleventy/config.js\": {\n- \"lines\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 1, \"covered\": 1, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n+ \"lines\": { \"total\": 7, \"covered\": 4, \"skipped\": 0, \"pct\": 57.14 },\n+ \"functions\": { \"total\": 4, \"covered\": 1, \"skipped\": 0, \"pct\": 25 },\n+ \"statements\": { \"total\": 7, \"covered\": 4, \"skipped\": 0, \"pct\": 57.14 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Config.js\": {\n- \"lines\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 },\n+ \"lines\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\n- \"lines\": { \"total\": 86, \"covered\": 56, \"skipped\": 0, \"pct\": 65.12 },\n- \"functions\": { \"total\": 13, \"covered\": 6, \"skipped\": 0, \"pct\": 46.15 },\n- \"statements\": { \"total\": 86, \"covered\": 56, \"skipped\": 0, \"pct\": 65.12 },\n- \"branches\": { \"total\": 18, \"covered\": 8, \"skipped\": 0, \"pct\": 44.44 }\n+ \"lines\": { \"total\": 114, \"covered\": 72, \"skipped\": 0, \"pct\": 63.16 },\n+ \"functions\": { \"total\": 17, \"covered\": 7, \"skipped\": 0, \"pct\": 41.18 },\n+ \"statements\": { \"total\": 114, \"covered\": 72, \"skipped\": 0, \"pct\": 63.16 },\n+ \"branches\": { \"total\": 22, \"covered\": 10, \"skipped\": 0, \"pct\": 45.45 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\n- \"lines\": { \"total\": 11, \"covered\": 11, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 5, \"covered\": 5, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 11, \"covered\": 11, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 15, \"covered\": 14, \"skipped\": 0, \"pct\": 93.33 },\n+ \"functions\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 },\n+ \"statements\": { \"total\": 15, \"covered\": 14, \"skipped\": 0, \"pct\": 93.33 },\n+ \"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyError.js\": {\n\"lines\": { \"total\": 13, \"covered\": 1, \"skipped\": 0, \"pct\": 7.69 },\n\"branches\": { \"total\": 2, \"covered\": 0, \"skipped\": 0, \"pct\": 0 }\n},\n\"/Users/zachleat/Code/eleventy/src/Template.js\": {\n- \"lines\": { \"total\": 157, \"covered\": 123, \"skipped\": 0, \"pct\": 78.34 },\n- \"functions\": { \"total\": 34, \"covered\": 25, \"skipped\": 0, \"pct\": 73.53 },\n- \"statements\": { \"total\": 157, \"covered\": 123, \"skipped\": 0, \"pct\": 78.34 },\n- \"branches\": { \"total\": 55, \"covered\": 38, \"skipped\": 0, \"pct\": 69.09 }\n+ \"lines\": { \"total\": 180, \"covered\": 154, \"skipped\": 0, \"pct\": 85.56 },\n+ \"functions\": { \"total\": 39, \"covered\": 32, \"skipped\": 0, \"pct\": 82.05 },\n+ \"statements\": { \"total\": 180, \"covered\": 154, \"skipped\": 0, \"pct\": 85.56 },\n+ \"branches\": { \"total\": 66, \"covered\": 52, \"skipped\": 0, \"pct\": 78.79 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\n- \"lines\": { \"total\": 14, \"covered\": 13, \"skipped\": 0, \"pct\": 92.86 },\n- \"functions\": { \"total\": 8, \"covered\": 7, \"skipped\": 0, \"pct\": 87.5 },\n- \"statements\": { \"total\": 14, \"covered\": 13, \"skipped\": 0, \"pct\": 92.86 },\n- \"branches\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 13, \"covered\": 11, \"skipped\": 0, \"pct\": 84.62 },\n+ \"functions\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 },\n+ \"statements\": { \"total\": 13, \"covered\": 11, \"skipped\": 0, \"pct\": 84.62 },\n+ \"branches\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\n- \"lines\": { \"total\": 25, \"covered\": 25, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 25, \"covered\": 25, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 26, \"covered\": 24, \"skipped\": 0, \"pct\": 92.31 },\n+ \"functions\": { \"total\": 4, \"covered\": 3, \"skipped\": 0, \"pct\": 75 },\n+ \"statements\": { \"total\": 26, \"covered\": 24, \"skipped\": 0, \"pct\": 92.31 },\n+ \"branches\": { \"total\": 8, \"covered\": 8, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\n- \"lines\": { \"total\": 64, \"covered\": 63, \"skipped\": 0, \"pct\": 98.44 },\n- \"functions\": { \"total\": 12, \"covered\": 12, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 64, \"covered\": 63, \"skipped\": 0, \"pct\": 98.44 },\n+ \"lines\": { \"total\": 70, \"covered\": 69, \"skipped\": 0, \"pct\": 98.57 },\n+ \"functions\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 70, \"covered\": 69, \"skipped\": 0, \"pct\": 98.57 },\n\"branches\": { \"total\": 12, \"covered\": 9, \"skipped\": 0, \"pct\": 75 }\n},\n+ \"/Users/zachleat/Code/eleventy/src/TemplateGlob.js\": {\n+ \"lines\": { \"total\": 16, \"covered\": 15, \"skipped\": 0, \"pct\": 93.75 },\n+ \"functions\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 16, \"covered\": 15, \"skipped\": 0, \"pct\": 93.75 },\n+ \"branches\": { \"total\": 8, \"covered\": 7, \"skipped\": 0, \"pct\": 87.5 }\n+ },\n\"/Users/zachleat/Code/eleventy/src/TemplateLayout.js\": {\n- \"lines\": { \"total\": 23, \"covered\": 22, \"skipped\": 0, \"pct\": 95.65 },\n+ \"lines\": { \"total\": 24, \"covered\": 23, \"skipped\": 0, \"pct\": 95.83 },\n\"functions\": { \"total\": 5, \"covered\": 5, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 23, \"covered\": 22, \"skipped\": 0, \"pct\": 95.65 },\n+ \"statements\": { \"total\": 24, \"covered\": 23, \"skipped\": 0, \"pct\": 95.83 },\n\"branches\": { \"total\": 10, \"covered\": 9, \"skipped\": 0, \"pct\": 90 }\n},\n+ \"/Users/zachleat/Code/eleventy/src/TemplateMap.js\": {\n+ \"lines\": { \"total\": 68, \"covered\": 66, \"skipped\": 0, \"pct\": 97.06 },\n+ \"functions\": { \"total\": 13, \"covered\": 12, \"skipped\": 0, \"pct\": 92.31 },\n+ \"statements\": { \"total\": 68, \"covered\": 66, \"skipped\": 0, \"pct\": 97.06 },\n+ \"branches\": { \"total\": 12, \"covered\": 11, \"skipped\": 0, \"pct\": 91.67 }\n+ },\n\"/Users/zachleat/Code/eleventy/src/TemplatePath.js\": {\n\"lines\": { \"total\": 23, \"covered\": 23, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 8, \"covered\": 7, \"skipped\": 0, \"pct\": 87.5 },\n\"statements\": { \"total\": 23, \"covered\": 23, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 }\n+ \"branches\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplatePermalink.js\": {\n- \"lines\": { \"total\": 22, \"covered\": 22, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 22, \"covered\": 22, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 14, \"covered\": 14, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n+ \"functions\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n+ \"branches\": { \"total\": 18, \"covered\": 18, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\n- \"lines\": { \"total\": 33, \"covered\": 32, \"skipped\": 0, \"pct\": 96.97 },\n+ \"lines\": { \"total\": 36, \"covered\": 34, \"skipped\": 0, \"pct\": 94.44 },\n\"functions\": { \"total\": 9, \"covered\": 8, \"skipped\": 0, \"pct\": 88.89 },\n- \"statements\": { \"total\": 33, \"covered\": 32, \"skipped\": 0, \"pct\": 96.97 },\n- \"branches\": { \"total\": 12, \"covered\": 11, \"skipped\": 0, \"pct\": 91.67 }\n+ \"statements\": { \"total\": 36, \"covered\": 34, \"skipped\": 0, \"pct\": 94.44 },\n+ \"branches\": { \"total\": 14, \"covered\": 12, \"skipped\": 0, \"pct\": 85.71 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\n- \"lines\": { \"total\": 141, \"covered\": 115, \"skipped\": 0, \"pct\": 81.56 },\n- \"functions\": { \"total\": 24, \"covered\": 16, \"skipped\": 0, \"pct\": 66.67 },\n- \"statements\": { \"total\": 141, \"covered\": 115, \"skipped\": 0, \"pct\": 81.56 },\n- \"branches\": { \"total\": 26, \"covered\": 19, \"skipped\": 0, \"pct\": 73.08 }\n+ \"lines\": { \"total\": 124, \"covered\": 100, \"skipped\": 0, \"pct\": 80.65 },\n+ \"functions\": { \"total\": 23, \"covered\": 15, \"skipped\": 0, \"pct\": 65.22 },\n+ \"statements\": { \"total\": 124, \"covered\": 100, \"skipped\": 0, \"pct\": 80.65 },\n+ \"branches\": { \"total\": 24, \"covered\": 18, \"skipped\": 0, \"pct\": 75 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Ejs.js\": {\n\"lines\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Handlebars.js\": {\n- \"lines\": { \"total\": 14, \"covered\": 14, \"skipped\": 0, \"pct\": 100 },\n+ \"lines\": { \"total\": 15, \"covered\": 15, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 14, \"covered\": 14, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 15, \"covered\": 15, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Html.js\": {\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js\": {\n- \"lines\": { \"total\": 12, \"covered\": 12, \"skipped\": 0, \"pct\": 100 },\n+ \"lines\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 12, \"covered\": 12, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Pug.js\": {\n\"branches\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Plugins/Pagination.js\": {\n- \"lines\": { \"total\": 75, \"covered\": 66, \"skipped\": 0, \"pct\": 88 },\n- \"functions\": { \"total\": 11, \"covered\": 8, \"skipped\": 0, \"pct\": 72.73 },\n- \"statements\": { \"total\": 75, \"covered\": 66, \"skipped\": 0, \"pct\": 88 },\n+ \"lines\": { \"total\": 76, \"covered\": 71, \"skipped\": 0, \"pct\": 93.42 },\n+ \"functions\": { \"total\": 11, \"covered\": 11, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 76, \"covered\": 71, \"skipped\": 0, \"pct\": 93.42 },\n\"branches\": { \"total\": 24, \"covered\": 21, \"skipped\": 0, \"pct\": 87.5 }\n},\n\"/Users/zachleat/Code/eleventy/src/Util/Capitalize.js\": {\n" }, { "change_type": "MODIFY", "old_path": "docs-src/coverage.njk", "new_path": "docs-src/coverage.njk", "diff": "---\npermalink: coverage.md\n---\n-# Code Coverage\n+# Code Coverage for Eleventy v{{ pkg.version }}\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| --- | --- | --- | --- | --- |\n" }, { "change_type": "MODIFY", "old_path": "docs/coverage.md", "new_path": "docs/coverage.md", "diff": "-# Code Coverage\n+# Code Coverage for Eleventy v0.2.6\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------- | ------- | ------------ | ----------- | ---------- |\n-| `total` | 85.53% | 85.53% | 79.6% | 80% |\n-| `config.js` | 100% | 100% | 100% | 100% |\n+| `total` | 86.79% | 86.79% | 80.43% | 82.53% |\n+| `config.js` | 57.14% | 57.14% | 25% | 100% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 65.12% | 65.12% | 46.15% | 44.44% |\n-| `src/EleventyConfig.js` | 100% | 100% | 100% | 100% |\n+| `src/Eleventy.js` | 63.16% | 63.16% | 41.18% | 45.45% |\n+| `src/EleventyConfig.js` | 93.33% | 93.33% | 83.33% | 100% |\n| `src/EleventyError.js` | 7.69% | 7.69% | 0% | 0% |\n-| `src/Template.js` | 78.34% | 78.34% | 73.53% | 69.09% |\n-| `src/TemplateCollection.js` | 92.86% | 92.86% | 87.5% | 100% |\n-| `src/TemplateConfig.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateData.js` | 98.44% | 98.44% | 100% | 75% |\n-| `src/TemplateLayout.js` | 95.65% | 95.65% | 100% | 90% |\n+| `src/Template.js` | 85.56% | 85.56% | 82.05% | 78.79% |\n+| `src/TemplateCollection.js` | 84.62% | 84.62% | 83.33% | 83.33% |\n+| `src/TemplateConfig.js` | 92.31% | 92.31% | 75% | 100% |\n+| `src/TemplateData.js` | 98.57% | 98.57% | 100% | 75% |\n+| `src/TemplateGlob.js` | 93.75% | 93.75% | 100% | 87.5% |\n+| `src/TemplateLayout.js` | 95.83% | 95.83% | 100% | 90% |\n+| `src/TemplateMap.js` | 97.06% | 97.06% | 92.31% | 91.67% |\n| `src/TemplatePath.js` | 100% | 100% | 87.5% | 100% |\n| `src/TemplatePermalink.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateRender.js` | 96.97% | 96.97% | 88.89% | 91.67% |\n-| `src/TemplateWriter.js` | 81.56% | 81.56% | 66.67% | 73.08% |\n+| `src/TemplateRender.js` | 94.44% | 94.44% | 88.89% | 85.71% |\n+| `src/TemplateWriter.js` | 80.65% | 80.65% | 65.22% | 75% |\n| `src/Engines/Ejs.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Haml.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Handlebars.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Nunjucks.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Pug.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/TemplateEngine.js` | 91.67% | 91.67% | 85.71% | 100% |\n-| `src/Plugins/Pagination.js` | 88% | 88% | 72.73% | 87.5% |\n+| `src/Plugins/Pagination.js` | 93.42% | 93.42% | 100% | 87.5% |\n| `src/Util/Capitalize.js` | 100% | 100% | 100% | 100% |\n| `src/Util/Pluralize.js` | 100% | 100% | 100% | 100% |\n| `src/Util/Sortable.js` | 86.67% | 86.67% | 76.19% | 94.44% |\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"default\": \"cd playground && npx eleventy --input=. --output=_site\",\n\"test\": \"npx nyc ava\",\n\"coverage\":\n- \"npx nyc report --reporter=json-summary && cp coverage/coverage-summary.json docs-src/_data/coverage.json && npx eleventy --config=docs-src/.eleventy.docs.js\",\n+ \"npm run test && npx nyc report --reporter=json-summary && cp coverage/coverage-summary.json docs-src/_data/coverage.json && npx eleventy --config=docs-src/.eleventy.docs.js\",\n\"precommit\": \"lint-staged\",\n\"prepush\": \"npx ava\"\n},\n" } ]
JavaScript
MIT License
11ty/eleventy
New code coverage (and npm tasks)
699
15.01.2018 14:51:13
21,600
b6d25b4cc5f7f966c6cf4ea4200de89bf78ff1eb
Adds `page.url` to global data. Fixes Fixes
[ { "change_type": "MODIFY", "old_path": "docs/collections.md", "new_path": "docs/collections.md", "diff": "@@ -23,6 +23,18 @@ This will place this `mypost.md` into the `post` collection with all other piece\n</ul>\n```\n+### Example: Navigation Links with an `active` class added for on the current page\n+\n+Comapre the `post.url` and special Eleventy-provided `page.url` variable to find the current page. Building on the previous example:\n+\n+```\n+<ul>\n+{%- for post in collections.post -%}\n+ <li{% if page.url == post.url %} class=\"active\"{% endif %}>{{ post.data.title }}</li>\n+{%- endfor -%}\n+</ul>\n+```\n+\n## Tag Syntax\nYou can use a single tag, as in the above example OR you can use any number of tags for the content, using YAML syntax for a list.\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -210,8 +210,24 @@ class Template {\nreturn Object.assign({}, data, mergedLayoutData, mergedLocalData);\n}\n+ async addPageUrlToData(data) {\n+ if (\"page\" in data && \"url\" in data.page) {\n+ debug(\n+ \"Warning: data.page.url is in use by the application will be overwritten: %o\",\n+ data.page.url\n+ );\n+ }\n+ if (!(\"page\" in data)) {\n+ data.page = {};\n+ }\n+ data.page.url = await this.getOutputHref();\n+ }\n+\n+ // getData (with renderData and page.url added)\nasync getRenderedData() {\nlet data = await this.getData();\n+ await this.addPageUrlToData(data);\n+\nif (data.renderData) {\ndata.renderData = await this.mapDataAsRenderedTemplates(\ndata.renderData,\n@@ -432,7 +448,6 @@ class Template {\ndata: data\n};\n- // console.log( await this.render(data) );\nmap.date = await this.getMappedDate(data);\nreturn map;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -35,6 +35,7 @@ class TemplateMap {\ngetMapTemplateIndex(item) {\nlet inputPath = item.inputPath;\nfor (let j = 0, k = this.map.length; j < k; j++) {\n+ // inputPath should be unique (even with pagination?)\nif (this.map[j].inputPath === inputPath) {\nreturn j;\n}\n@@ -129,24 +130,11 @@ class TemplateMap {\n}\n}\n- async assignActiveTemplate(activeTemplate) {\n- if (activeTemplate) {\n- for (let collectionName in this.collectionsData) {\n- for (let item of this.collectionsData[collectionName]) {\n- // Assign active keys for all templates (both true and false)\n- item.active = await item.template.isEqual(activeTemplate);\n- }\n- }\n- }\n- }\n-\nasync getCollectionsDataForTemplate(template) {\nif (!this.collectionsData) {\nawait this.cache();\n}\n- await this.assignActiveTemplate(template);\n-\nreturn this.collectionsData;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -3,7 +3,6 @@ const fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\n-const TemplateRender = require(\"./TemplateRender\");\nconst TemplateMap = require(\"./TemplateMap\");\nconst EleventyError = require(\"./EleventyError\");\nconst Pagination = require(\"./Plugins/Pagination\");\n@@ -199,11 +198,11 @@ TemplateWriter.prototype._createTemplateMap = async function(paths) {\nreturn this.templateMap;\n};\n-TemplateWriter.prototype._writeTemplate = async function(\n- tmpl,\n- outputPath,\n- data\n-) {\n+TemplateWriter.prototype._writeTemplate = async function(mapEntry) {\n+ let outputPath = mapEntry.outputPath;\n+ let data = mapEntry.data;\n+ let tmpl = mapEntry.template;\n+ console.log(mapEntry.data.page.url);\ntry {\nawait tmpl.writeWithData(outputPath, data);\n} catch (e) {\n@@ -225,11 +224,7 @@ TemplateWriter.prototype.write = async function() {\nawait this._createTemplateMap(paths);\nfor (let mapEntry of this.templateMap.getMap()) {\n- await this._writeTemplate(\n- mapEntry.template,\n- mapEntry.outputPath,\n- mapEntry.data\n- );\n+ await this._writeTemplate(mapEntry);\n}\neleventyConfig.emit(\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -33,16 +33,6 @@ test(\"populating the collection twice should clear the previous values (--watch\nt.is(tm.getMap().length, 2);\n});\n-test(\"Active template flags are set properly by `assignActiveTemplate`\", async t => {\n- let tm = new TemplateMap();\n- await tm.add(tmpl1);\n- await tm.add(tmpl2);\n- let collectionsData = await tm.getCollectionsDataForTemplate(tmpl1);\n- t.is(collectionsData.all.length, 2);\n- t.true(collectionsData.all[0].active);\n- t.false(collectionsData.all[1].active);\n-});\n-\ntest(\"TemplateMap adds collections data and has templateContent values\", async t => {\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -571,3 +571,14 @@ test(\"getMappedDate (created date)\", async t => {\nt.true(date instanceof Date);\nt.truthy(date.getTime());\n});\n+\n+test(\"getRenderedData() has page.url\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await tmpl.getRenderedData();\n+\n+ t.truthy(data.page.url);\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `page.url` to global data. Fixes #22 Fixes #36
699
16.01.2018 07:29:47
21,600
4d800bf07333122d22f79b977e23d87bfb0f4c56
Adds CLI command to debug output.
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "#!/usr/bin/env node\nconst argv = require(\"minimist\")(process.argv.slice(2));\nconst EleventyNodeVersionCheck = require(\"./src/VersionCheck\");\n+const debug = require(\"debug\")(\"Eleventy-CLI\");\nEleventyNodeVersionCheck().then(function() {\nconst Eleventy = require(\"./src/Eleventy\");\n+ debug(\n+ \"command: eleventy\" +\n+ (argv.input ? \" --input=\" + argv.input : \"\") +\n+ (argv.output ? \" --output=\" + argv.output : \"\") +\n+ (argv.formats ? \" --formats=\" + arg.formats : \"\") +\n+ (argv.config ? \" --config=\" + arg.config : \"\") +\n+ (argv.quiet ? \" --quiet\" : \"\") +\n+ (argv.version ? \" --version\" : \"\") +\n+ (argv.watch ? \" --watch\" : \"\")\n+ );\nlet elev = new Eleventy(argv.input, argv.output);\nelev.setConfigPath(argv.config);\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds CLI command to debug output.
699
16.01.2018 08:01:30
21,600
247c9c7e48ac2c450f0df44d0295c8fee2f7d6f9
Fixes for `watch` and writeCount / times
[ { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -4,6 +4,7 @@ const parsePath = require(\"parse-filepath\");\nconst Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateMap = require(\"./TemplateMap\");\n+const TemplateEngine = require(\"./Engines/TemplateEngine\");\nconst EleventyError = require(\"./EleventyError\");\nconst Pagination = require(\"./Plugins/Pagination\");\nconst TemplateGlob = require(\"./TemplateGlob\");\n@@ -45,6 +46,11 @@ function TemplateWriter(inputPath, outputDir, extensions, templateData) {\nthis.templateMap;\n}\n+TemplateWriter.prototype.restart = function() {\n+ this.writeCount = 0;\n+ debug(\"Resetting writeCount to 0\");\n+};\n+\nTemplateWriter.prototype.getIncludesDir = function() {\nreturn this.includesDir;\n};\n@@ -189,9 +195,19 @@ TemplateWriter.prototype._getTemplate = function(path) {\nTemplateWriter.prototype._createTemplateMap = async function(paths) {\nthis.templateMap = new TemplateMap();\n+ // START HERE\n+ // this.copyFiles = new TemplateCopy();\n+\nfor (let path of paths) {\n+ let parsed = parsePath(path);\n+ if (TemplateEngine.hasEngine(parsed.ext.substr(1))) {\nawait this.templateMap.add(this._getTemplate(path));\ndebug(`Template for ${path} added to map.`);\n+ } else {\n+ debug(\n+ `${path} has no TemplateEngine engine and will just passthrough copy`\n+ );\n+ }\n}\nawait this.templateMap.cache();\n@@ -202,7 +218,7 @@ TemplateWriter.prototype._writeTemplate = async function(mapEntry) {\nlet outputPath = mapEntry.outputPath;\nlet data = mapEntry.data;\nlet tmpl = mapEntry.template;\n- console.log(mapEntry.data.page.url);\n+\ntry {\nawait tmpl.writeWithData(outputPath, data);\n} catch (e) {\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes for `watch` and writeCount / times
699
16.01.2018 08:20:10
21,600
bf7781bf1569af5e53e757e831019505a6840df0
Minor cleanup to TemplateEngine and TemplateRender
[ { "change_type": "MODIFY", "old_path": "src/Engines/Mustache.js", "new_path": "src/Engines/Mustache.js", "diff": "@@ -2,6 +2,12 @@ const MustacheLib = require(\"mustache\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Mustache extends TemplateEngine {\n+ constructor(name, inputDir) {\n+ super(name, inputDir);\n+\n+ super.getPartials();\n+ }\n+\nasync compile(str) {\nlet partials = super.getPartials();\nreturn function(data) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateRender.js", "new_path": "src/TemplateRender.js", "diff": "@@ -2,6 +2,7 @@ const parsePath = require(\"parse-filepath\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateEngine = require(\"./Engines/TemplateEngine\");\nconst config = require(\"./Config\");\n+const debug = require(\"debug\")(\"TemplateRender\");\n// works with full path names or short engine name\nfunction TemplateRender(tmplPath, inputDir) {\n@@ -14,22 +15,26 @@ function TemplateRender(tmplPath, inputDir) {\nthis.config = config.getConfig();\nthis.path = tmplPath;\n- this.parsed = tmplPath ? parsePath(tmplPath) : undefined;\n- this.engineName =\n- this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : tmplPath;\n+ // if( inputDir ) {\n+ // debug(\"New TemplateRender, tmplPath: %o, inputDir: %o\", tmplPath, inputDir);\n+ // }\n+\n+ this.engineName = TemplateRender.cleanupEngineName(tmplPath);\nthis.inputDir = this._normalizeInputDir(inputDir);\nthis.engine = TemplateEngine.getEngine(this.engineName, this.inputDir);\n- this.defaultMarkdownEngine = this.config.markdownTemplateEngine;\n- this.defaultHtmlEngine = this.config.htmlTemplateEngine;\n}\n-TemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\n- this.defaultMarkdownEngine = markdownEngine;\n+TemplateRender.cleanupEngineName = function(tmplPath) {\n+ tmplPath = tmplPath.toLowerCase();\n+\n+ let parsed = tmplPath ? parsePath(tmplPath) : undefined;\n+ return parsed && parsed.ext ? parsed.ext.substr(1) : tmplPath;\n};\n-TemplateRender.prototype.setDefaultHtmlEngine = function(htmlEngine) {\n- this.defaultHtmlEngine = htmlEngine;\n+TemplateRender.hasEngine = function(tmplPath) {\n+ let name = TemplateRender.cleanupEngineName(tmplPath);\n+ return name in TemplateEngine.engineMap;\n};\nTemplateRender.prototype.getEngineName = function() {\n@@ -57,14 +62,14 @@ TemplateRender.prototype.render = async function(str, data) {\nTemplateRender.prototype.getCompiledTemplate = async function(str, options) {\noptions = Object.assign(\n{\n- parseMarkdownWith: this.defaultMarkdownEngine,\n- parseHtmlWith: this.defaultHtmlEngine,\n+ parseMarkdownWith: this.config.markdownTemplateEngine,\n+ parseHtmlWith: this.config.htmlTemplateEngine,\nbypassMarkdown: false\n},\noptions\n);\n- // TODO refactor better\n+ // TODO refactor better, move into TemplateEngine logic\nif (this.engineName === \"md\") {\nreturn this.engine.compile(\nstr,\n" } ]
JavaScript
MIT License
11ty/eleventy
Minor cleanup to TemplateEngine and TemplateRender
699
16.01.2018 09:03:12
21,600
ec67ef392e9ed3dcb2e68bd86ff7757200c32308
TemplatePassthrough and `config.passthroughFileCopy`
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -16,6 +16,7 @@ module.exports = {\nmarkdownTemplateEngine: \"liquid\",\nhtmlTemplateEngine: \"liquid\",\ndataTemplateEngine: \"liquid\",\n+ passthroughFileCopy: false,\nhtmlOutputSuffix: \"-o\",\nkeys: {\npackage: \"pkg\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/TemplatePassthrough.js", "diff": "+const fs = require(\"fs-extra\");\n+const TemplatePath = require(\"./TemplatePath\");\n+const debug = require(\"debug\")(\"Eleventy:TemplatePassthrough\");\n+\n+class TemplatePassthrough {\n+ constructor(inputPath, outputDir) {\n+ this.path = inputPath;\n+ this.outputDir = outputDir;\n+ }\n+\n+ getOutputPath() {\n+ return TemplatePath.normalize(this.outputDir, this.path);\n+ }\n+\n+ async write() {\n+ debug(\n+ `${this.path} has no TemplateEngine engine and will copy to ${\n+ this.outputDir\n+ }`\n+ );\n+\n+ return fs.copy(this.path, this.getOutputPath());\n+ }\n+}\n+\n+module.exports = TemplatePassthrough;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -4,7 +4,8 @@ const parsePath = require(\"parse-filepath\");\nconst Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateMap = require(\"./TemplateMap\");\n-const TemplateEngine = require(\"./Engines/TemplateEngine\");\n+const TemplateRender = require(\"./TemplateRender\");\n+const TemplatePassthrough = require(\"./TemplatePassthrough\");\nconst EleventyError = require(\"./EleventyError\");\nconst Pagination = require(\"./Plugins/Pagination\");\nconst TemplateGlob = require(\"./TemplateGlob\");\n@@ -193,20 +194,34 @@ TemplateWriter.prototype._getTemplate = function(path) {\nreturn tmpl;\n};\n+TemplateWriter.prototype._copyPassthroughs = async function(paths) {\n+ if (!this.config.passthroughFileCopy) {\n+ debug(\"`passthroughFileCopy` is disabled in config, bypassing.\");\n+ return;\n+ }\n+\n+ for (let path of paths) {\n+ if (!TemplateRender.hasEngine(path)) {\n+ let pass = new TemplatePassthrough(path, this.outputDir);\n+ try {\n+ await pass.write();\n+ } catch (e) {\n+ throw EleventyError.make(\n+ new Error(`Having trouble copying: ${path}`),\n+ e\n+ );\n+ }\n+ }\n+ }\n+};\n+\nTemplateWriter.prototype._createTemplateMap = async function(paths) {\nthis.templateMap = new TemplateMap();\n- // START HERE\n- // this.copyFiles = new TemplateCopy();\nfor (let path of paths) {\n- let parsed = parsePath(path);\n- if (TemplateEngine.hasEngine(parsed.ext.substr(1))) {\n+ if (TemplateRender.hasEngine(path)) {\nawait this.templateMap.add(this._getTemplate(path));\ndebug(`Template for ${path} added to map.`);\n- } else {\n- debug(\n- `${path} has no TemplateEngine engine and will just passthrough copy`\n- );\n}\n}\n@@ -237,6 +252,7 @@ TemplateWriter.prototype.write = async function() {\nlet paths = await this._getAllPaths();\ndebug(\"Found: %o\", paths);\n+ await this._copyPassthroughs(paths);\nawait this._createTemplateMap(paths);\nfor (let mapEntry of this.templateMap.getMap()) {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplatePassthroughTest.js", "diff": "+import test from \"ava\";\n+import TemplatePassthrough from \"../src/TemplatePassthrough\";\n+\n+test(\"Constructor\", t => {\n+ let pass = new TemplatePassthrough(\"avatar.png\", \"_site\");\n+ t.truthy(pass);\n+ t.is(pass.getOutputPath(), \"_site/avatar.png\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePassthrough and `config.passthroughFileCopy`
699
16.01.2018 09:30:42
21,600
90c43df9e05d09a0af09685cc45e394c0c2e1f21
Change default to true for passthroughFileCopy
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -16,7 +16,7 @@ module.exports = {\nmarkdownTemplateEngine: \"liquid\",\nhtmlTemplateEngine: \"liquid\",\ndataTemplateEngine: \"liquid\",\n- passthroughFileCopy: false,\n+ passthroughFileCopy: true,\nhtmlOutputSuffix: \"-o\",\nkeys: {\npackage: \"pkg\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Change default to true for passthroughFileCopy
699
16.01.2018 20:21:36
21,600
ca270d88df787a4e8cb3d24854c4caec511c26d5
Wrong variable names.
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -9,8 +9,8 @@ EleventyNodeVersionCheck().then(function() {\n\"command: eleventy\" +\n(argv.input ? \" --input=\" + argv.input : \"\") +\n(argv.output ? \" --output=\" + argv.output : \"\") +\n- (argv.formats ? \" --formats=\" + arg.formats : \"\") +\n- (argv.config ? \" --config=\" + arg.config : \"\") +\n+ (argv.formats ? \" --formats=\" + argv.formats : \"\") +\n+ (argv.config ? \" --config=\" + argv.config : \"\") +\n(argv.quiet ? \" --quiet\" : \"\") +\n(argv.version ? \" --version\" : \"\") +\n(argv.watch ? \" --watch\" : \"\")\n" } ]
JavaScript
MIT License
11ty/eleventy
Wrong variable names.
699
16.01.2018 20:21:54
21,600
be4ad8591011c02b4e9a2682005abe6a77531124
Code coverage for v0.2.7
[ { "change_type": "MODIFY", "old_path": "docs-src/_data/coverage.json", "new_path": "docs-src/_data/coverage.json", "diff": "{\n\"total\": {\n- \"lines\": { \"total\": 1007, \"covered\": 874, \"skipped\": 0, \"pct\": 86.79 },\n- \"statements\": { \"total\": 1007, \"covered\": 874, \"skipped\": 0, \"pct\": 86.79 },\n- \"functions\": { \"total\": 230, \"covered\": 185, \"skipped\": 0, \"pct\": 80.43 },\n- \"branches\": { \"total\": 269, \"covered\": 222, \"skipped\": 0, \"pct\": 82.53 }\n+ \"lines\": { \"total\": 1050, \"covered\": 900, \"skipped\": 0, \"pct\": 85.71 },\n+ \"statements\": { \"total\": 1050, \"covered\": 900, \"skipped\": 0, \"pct\": 85.71 },\n+ \"functions\": { \"total\": 236, \"covered\": 192, \"skipped\": 0, \"pct\": 81.36 },\n+ \"branches\": { \"total\": 281, \"covered\": 225, \"skipped\": 0, \"pct\": 80.07 }\n},\n\"/Users/zachleat/Code/eleventy/config.js\": {\n- \"lines\": { \"total\": 7, \"covered\": 4, \"skipped\": 0, \"pct\": 57.14 },\n- \"functions\": { \"total\": 4, \"covered\": 1, \"skipped\": 0, \"pct\": 25 },\n- \"statements\": { \"total\": 7, \"covered\": 4, \"skipped\": 0, \"pct\": 57.14 },\n+ \"lines\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n+ \"functions\": { \"total\": 1, \"covered\": 1, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Config.js\": {\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\n- \"lines\": { \"total\": 114, \"covered\": 72, \"skipped\": 0, \"pct\": 63.16 },\n- \"functions\": { \"total\": 17, \"covered\": 7, \"skipped\": 0, \"pct\": 41.18 },\n- \"statements\": { \"total\": 114, \"covered\": 72, \"skipped\": 0, \"pct\": 63.16 },\n+ \"lines\": { \"total\": 117, \"covered\": 73, \"skipped\": 0, \"pct\": 62.39 },\n+ \"functions\": { \"total\": 18, \"covered\": 7, \"skipped\": 0, \"pct\": 38.89 },\n+ \"statements\": { \"total\": 117, \"covered\": 73, \"skipped\": 0, \"pct\": 62.39 },\n\"branches\": { \"total\": 22, \"covered\": 10, \"skipped\": 0, \"pct\": 45.45 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\n- \"lines\": { \"total\": 15, \"covered\": 14, \"skipped\": 0, \"pct\": 93.33 },\n- \"functions\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 },\n- \"statements\": { \"total\": 15, \"covered\": 14, \"skipped\": 0, \"pct\": 93.33 },\n+ \"lines\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n+ \"functions\": { \"total\": 5, \"covered\": 5, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyError.js\": {\n\"branches\": { \"total\": 2, \"covered\": 0, \"skipped\": 0, \"pct\": 0 }\n},\n\"/Users/zachleat/Code/eleventy/src/Template.js\": {\n- \"lines\": { \"total\": 180, \"covered\": 154, \"skipped\": 0, \"pct\": 85.56 },\n- \"functions\": { \"total\": 39, \"covered\": 32, \"skipped\": 0, \"pct\": 82.05 },\n- \"statements\": { \"total\": 180, \"covered\": 154, \"skipped\": 0, \"pct\": 85.56 },\n- \"branches\": { \"total\": 66, \"covered\": 52, \"skipped\": 0, \"pct\": 78.79 }\n+ \"lines\": { \"total\": 190, \"covered\": 163, \"skipped\": 0, \"pct\": 85.79 },\n+ \"functions\": { \"total\": 41, \"covered\": 34, \"skipped\": 0, \"pct\": 82.93 },\n+ \"statements\": { \"total\": 190, \"covered\": 163, \"skipped\": 0, \"pct\": 85.79 },\n+ \"branches\": { \"total\": 72, \"covered\": 55, \"skipped\": 0, \"pct\": 76.39 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\n- \"lines\": { \"total\": 13, \"covered\": 11, \"skipped\": 0, \"pct\": 84.62 },\n- \"functions\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 },\n- \"statements\": { \"total\": 13, \"covered\": 11, \"skipped\": 0, \"pct\": 84.62 },\n+ \"lines\": { \"total\": 13, \"covered\": 12, \"skipped\": 0, \"pct\": 92.31 },\n+ \"functions\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 13, \"covered\": 12, \"skipped\": 0, \"pct\": 92.31 },\n\"branches\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\n\"branches\": { \"total\": 10, \"covered\": 9, \"skipped\": 0, \"pct\": 90 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateMap.js\": {\n- \"lines\": { \"total\": 68, \"covered\": 66, \"skipped\": 0, \"pct\": 97.06 },\n- \"functions\": { \"total\": 13, \"covered\": 12, \"skipped\": 0, \"pct\": 92.31 },\n- \"statements\": { \"total\": 68, \"covered\": 66, \"skipped\": 0, \"pct\": 97.06 },\n- \"branches\": { \"total\": 12, \"covered\": 11, \"skipped\": 0, \"pct\": 91.67 }\n+ \"lines\": { \"total\": 66, \"covered\": 64, \"skipped\": 0, \"pct\": 96.97 },\n+ \"functions\": { \"total\": 12, \"covered\": 12, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 66, \"covered\": 64, \"skipped\": 0, \"pct\": 96.97 },\n+ \"branches\": { \"total\": 10, \"covered\": 8, \"skipped\": 0, \"pct\": 80 }\n+ },\n+ \"/Users/zachleat/Code/eleventy/src/TemplatePassthrough.js\": {\n+ \"lines\": { \"total\": 9, \"covered\": 7, \"skipped\": 0, \"pct\": 77.78 },\n+ \"functions\": { \"total\": 3, \"covered\": 2, \"skipped\": 0, \"pct\": 66.67 },\n+ \"statements\": { \"total\": 9, \"covered\": 7, \"skipped\": 0, \"pct\": 77.78 },\n+ \"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplatePath.js\": {\n\"lines\": { \"total\": 23, \"covered\": 23, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 18, \"covered\": 18, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\n- \"lines\": { \"total\": 36, \"covered\": 34, \"skipped\": 0, \"pct\": 94.44 },\n+ \"lines\": { \"total\": 37, \"covered\": 35, \"skipped\": 0, \"pct\": 94.59 },\n\"functions\": { \"total\": 9, \"covered\": 8, \"skipped\": 0, \"pct\": 88.89 },\n- \"statements\": { \"total\": 36, \"covered\": 34, \"skipped\": 0, \"pct\": 94.44 },\n+ \"statements\": { \"total\": 37, \"covered\": 35, \"skipped\": 0, \"pct\": 94.59 },\n\"branches\": { \"total\": 14, \"covered\": 12, \"skipped\": 0, \"pct\": 85.71 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\n- \"lines\": { \"total\": 124, \"covered\": 100, \"skipped\": 0, \"pct\": 80.65 },\n- \"functions\": { \"total\": 23, \"covered\": 15, \"skipped\": 0, \"pct\": 65.22 },\n- \"statements\": { \"total\": 124, \"covered\": 100, \"skipped\": 0, \"pct\": 80.65 },\n- \"branches\": { \"total\": 24, \"covered\": 18, \"skipped\": 0, \"pct\": 75 }\n+ \"lines\": { \"total\": 143, \"covered\": 103, \"skipped\": 0, \"pct\": 72.03 },\n+ \"functions\": { \"total\": 25, \"covered\": 15, \"skipped\": 0, \"pct\": 60 },\n+ \"statements\": { \"total\": 143, \"covered\": 103, \"skipped\": 0, \"pct\": 72.03 },\n+ \"branches\": { \"total\": 30, \"covered\": 19, \"skipped\": 0, \"pct\": 63.33 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Ejs.js\": {\n\"lines\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Mustache.js\": {\n- \"lines\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n+ \"lines\": { \"total\": 8, \"covered\": 8, \"skipped\": 0, \"pct\": 100 },\n+ \"functions\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 8, \"covered\": 8, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js\": {\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/TemplateEngine.js\": {\n- \"lines\": { \"total\": 24, \"covered\": 22, \"skipped\": 0, \"pct\": 91.67 },\n- \"functions\": { \"total\": 7, \"covered\": 6, \"skipped\": 0, \"pct\": 85.71 },\n- \"statements\": { \"total\": 24, \"covered\": 22, \"skipped\": 0, \"pct\": 91.67 },\n- \"branches\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 31, \"covered\": 28, \"skipped\": 0, \"pct\": 90.32 },\n+ \"functions\": { \"total\": 9, \"covered\": 7, \"skipped\": 0, \"pct\": 77.78 },\n+ \"statements\": { \"total\": 31, \"covered\": 28, \"skipped\": 0, \"pct\": 90.32 },\n+ \"branches\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Plugins/Pagination.js\": {\n\"lines\": { \"total\": 76, \"covered\": 71, \"skipped\": 0, \"pct\": 93.42 },\n" }, { "change_type": "MODIFY", "old_path": "docs/coverage.md", "new_path": "docs/coverage.md", "diff": "-# Code Coverage for Eleventy v0.2.6\n+# Code Coverage for Eleventy v0.2.7\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------- | ------- | ------------ | ----------- | ---------- |\n-| `total` | 86.79% | 86.79% | 80.43% | 82.53% |\n-| `config.js` | 57.14% | 57.14% | 25% | 100% |\n+| `total` | 85.71% | 85.71% | 81.36% | 80.07% |\n+| `config.js` | 100% | 100% | 100% | 100% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 63.16% | 63.16% | 41.18% | 45.45% |\n-| `src/EleventyConfig.js` | 93.33% | 93.33% | 83.33% | 100% |\n+| `src/Eleventy.js` | 62.39% | 62.39% | 38.89% | 45.45% |\n+| `src/EleventyConfig.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyError.js` | 7.69% | 7.69% | 0% | 0% |\n-| `src/Template.js` | 85.56% | 85.56% | 82.05% | 78.79% |\n-| `src/TemplateCollection.js` | 84.62% | 84.62% | 83.33% | 83.33% |\n+| `src/Template.js` | 85.79% | 85.79% | 82.93% | 76.39% |\n+| `src/TemplateCollection.js` | 92.31% | 92.31% | 100% | 83.33% |\n| `src/TemplateConfig.js` | 92.31% | 92.31% | 75% | 100% |\n| `src/TemplateData.js` | 98.57% | 98.57% | 100% | 75% |\n| `src/TemplateGlob.js` | 93.75% | 93.75% | 100% | 87.5% |\n| `src/TemplateLayout.js` | 95.83% | 95.83% | 100% | 90% |\n-| `src/TemplateMap.js` | 97.06% | 97.06% | 92.31% | 91.67% |\n+| `src/TemplateMap.js` | 96.97% | 96.97% | 100% | 80% |\n+| `src/TemplatePassthrough.js` | 77.78% | 77.78% | 66.67% | 100% |\n| `src/TemplatePath.js` | 100% | 100% | 87.5% | 100% |\n| `src/TemplatePermalink.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateRender.js` | 94.44% | 94.44% | 88.89% | 85.71% |\n-| `src/TemplateWriter.js` | 80.65% | 80.65% | 65.22% | 75% |\n+| `src/TemplateRender.js` | 94.59% | 94.59% | 88.89% | 85.71% |\n+| `src/TemplateWriter.js` | 72.03% | 72.03% | 60% | 63.33% |\n| `src/Engines/Ejs.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Haml.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Handlebars.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Mustache.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Nunjucks.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Pug.js` | 100% | 100% | 100% | 100% |\n-| `src/Engines/TemplateEngine.js` | 91.67% | 91.67% | 85.71% | 100% |\n+| `src/Engines/TemplateEngine.js` | 90.32% | 90.32% | 77.78% | 100% |\n| `src/Plugins/Pagination.js` | 93.42% | 93.42% | 100% | 87.5% |\n| `src/Util/Capitalize.js` | 100% | 100% | 100% | 100% |\n| `src/Util/Pluralize.js` | 100% | 100% | 100% | 100% |\n" } ]
JavaScript
MIT License
11ty/eleventy
Code coverage for v0.2.7
699
18.01.2018 21:55:21
21,600
6f292f42a48e55d38b8f7314ff8d2458365e727f
Move the TemplateRender engine tests into their own files
[ { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateRenderEJSTest.js", "diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+import path from \"path\";\n+\n+// EJS\n+test(\"EJS\", t => {\n+ t.is(new TemplateRender(\"ejs\").getEngineName(), \"ejs\");\n+});\n+\n+test(\"EJS Render\", async t => {\n+ let fn = await new TemplateRender(\"ejs\").getCompiledTemplate(\n+ \"<p><%= name %></p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+});\n+\n+test(\"EJS Render Include Preprocessor Directive\", async t => {\n+ t.is(path.resolve(undefined, \"/included\"), \"/included\");\n+\n+ let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+ \"<p><% include /included %></p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"EJS Render Include, New Style no Data\", async t => {\n+ let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+ \"<p><%- include('/included') %></p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"EJS Render Include, New Style\", async t => {\n+ let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+ \"<p><%- include('/included', {}) %></p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"EJS Render Include, New Style with Data\", async t => {\n+ let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+ \"<p><%- include('/includedvar', { name: 'Bill' }) %></p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an Bill.</p>\");\n+});\n+\n+// test(\"EJS Render Include Preprocessor Directive Relative\", async t => {\n+\n+// let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+// \"<p><% include included %></p>\"\n+// );\n+// t.is(await fn(), \"<p>This is an include.</p>\");\n+// });\n+\n+// test(\"EJS Render Include, Relative Path New Style\", async t => {\n+// let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+// \"<p><%- include('stubs/includedrelative', {}) %></p>\"\n+// );\n+\n+// t.is(await fn(), \"<p>This is a relative include.</p>\");\n+// });\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateRenderHamlTest.js", "diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+import path from \"path\";\n+\n+// Haml\n+test(\"Haml\", t => {\n+ t.is(new TemplateRender(\"haml\").getEngineName(), \"haml\");\n+});\n+\n+test(\"Haml Render\", async t => {\n+ let fn = await new TemplateRender(\"haml\").getCompiledTemplate(\"%p= name\");\n+ t.is((await fn({ name: \"Zach\" })).trim(), \"<p>Zach</p>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateRenderHandlebarsTest.js", "diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+import path from \"path\";\n+\n+// Handlebars\n+test(\"Handlebars\", t => {\n+ t.is(new TemplateRender(\"hbs\").getEngineName(), \"hbs\");\n+});\n+\n+test(\"Handlebars Render\", async t => {\n+ let fn = await new TemplateRender(\"hbs\").getCompiledTemplate(\n+ \"<p>{{name}}</p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+});\n+\n+test(\"Handlebars Render Partial\", async t => {\n+ let fn = await new TemplateRender(\"hbs\", \"./test/stubs/\").getCompiledTemplate(\n+ \"<p>{{> included}}</p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Handlebars Render Partial\", async t => {\n+ let fn = await new TemplateRender(\"hbs\", \"./test/stubs/\").getCompiledTemplate(\n+ \"<p>{{> includedvar}}</p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>This is a Zach.</p>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateRenderLiquidTest.js", "diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+import path from \"path\";\n+\n+// Liquid\n+test(\"Liquid\", t => {\n+ t.is(new TemplateRender(\"liquid\").getEngineName(), \"liquid\");\n+});\n+\n+test(\"Liquid Render (with Helper)\", async t => {\n+ let fn = await new TemplateRender(\"liquid\").getCompiledTemplate(\n+ \"<p>{{name | capitalize}}</p>\"\n+ );\n+ t.is(await fn({ name: \"tim\" }), \"<p>Tim</p>\");\n+});\n+\n+test(\"Liquid Render Include\", async t => {\n+ t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{% include included %}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include with Liquid Suffix\", async t => {\n+ t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{% include included.liquid %}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include with HTML Suffix\", async t => {\n+ t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{% include included.html %}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+// This is an upstream limitation of the Liquid implementation\n+// test(\"Liquid Render Include No Quotes\", async t => {\n+// t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+// let fn = await new TemplateRender(\n+// \"liquid\",\n+// \"./test/stubs/\"\n+// ).getCompiledTemplate(\"<p>{% include included.liquid %}</p>\");\n+// t.is(await fn(), \"<p>This is an include.</p>\");\n+// });\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateRenderMustacheTest.js", "diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+import path from \"path\";\n+\n+// Mustache\n+test(\"Mustache\", async t => {\n+ t.is(new TemplateRender(\"mustache\").getEngineName(), \"mustache\");\n+});\n+\n+test(\"Mustache Render\", async t => {\n+ let fn = await new TemplateRender(\"mustache\").getCompiledTemplate(\n+ \"<p>{{name}}</p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+});\n+\n+test(\"Mustache Render Partial\", async t => {\n+ let fn = await new TemplateRender(\n+ \"mustache\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{{> included}}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Mustache Render Partial\", async t => {\n+ let fn = await new TemplateRender(\n+ \"mustache\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{{> includedvar}}</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>This is a Zach.</p>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateRenderNunjucksTest.js", "diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+import path from \"path\";\n+\n+// Nunjucks\n+test(\"Nunjucks\", t => {\n+ t.is(new TemplateRender(\"njk\").getEngineName(), \"njk\");\n+});\n+\n+test(\"Nunjucks Render\", async t => {\n+ let fn = await new TemplateRender(\"njk\").getCompiledTemplate(\n+ \"<p>{{ name }}</p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+});\n+\n+test(\"Nunjucks Render Extends\", async t => {\n+ let fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n+ \"{% extends 'base.njk' %}{% block content %}This is a child.{% endblock %}\"\n+ );\n+ t.is(await fn(), \"<p>This is a child.</p>\");\n+});\n+\n+test(\"Nunjucks Render Include\", async t => {\n+ let fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n+ \"<p>{% include 'included.njk' %}</p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Nunjucks Render Imports\", async t => {\n+ let fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n+ \"{% import 'imports.njk' as forms %}<div>{{ forms.label('Name') }}</div>\"\n+ );\n+ t.is(await fn(), \"<div><label>Name</label></div>\");\n+});\n+\n+test(\"Nunjucks Render Imports From\", async t => {\n+ let fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n+ \"{% from 'imports.njk' import label %}<div>{{ label('Name') }}</div>\"\n+ );\n+ t.is(await fn(), \"<div><label>Name</label></div>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateRenderPugTest.js", "diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+import path from \"path\";\n+\n+// Pug\n+test(\"Pug\", t => {\n+ t.is(new TemplateRender(\"pug\").getEngineName(), \"pug\");\n+});\n+\n+test(\"Pug Render\", async t => {\n+ let fn = await new TemplateRender(\"pug\").getCompiledTemplate(\"p= name\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+});\n+\n+test(\"Pug Render Include\", async t => {\n+ let fn = await new TemplateRender(\"pug\", \"./test/stubs/\")\n+ .getCompiledTemplate(`p\n+ include /included.pug`);\n+ t.is(await fn({ name: \"Zach\" }), \"<p><span>This is an include.</span></p>\");\n+});\n+\n+test(\"Pug Render Include with Data\", async t => {\n+ let fn = await new TemplateRender(\"pug\", \"./test/stubs/\")\n+ .getCompiledTemplate(`p\n+ include /includedvar.pug`);\n+ t.is(await fn({ name: \"Zach\" }), \"<p><span>This is Zach.</span></p>\");\n+});\n+\n+test(\"Pug Render Include with Data, inline var overrides data\", async t => {\n+ let fn = await new TemplateRender(\"pug\", \"./test/stubs/\")\n+ .getCompiledTemplate(`\n+- var name = \"Bill\";\n+p\n+ include /includedvar.pug`);\n+ t.is(await fn({ name: \"Zach\" }), \"<p><span>This is Bill.</span></p>\");\n+});\n+\n+test(\"Pug Render Extends (Layouts)\", async t => {\n+ let fn = await new TemplateRender(\"pug\", \"./test/stubs/\")\n+ .getCompiledTemplate(`extends /layout.pug\n+block content\n+ h1= name`);\n+ t.is(await fn({ name: \"Zach\" }), \"<html><body><h1>Zach</h1></body></html>\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Move the TemplateRender engine tests into their own files
699
19.01.2018 09:34:57
21,600
4920e3bf257292ea5eec8a72c5e1e9d65469566d
Adds (working) config api stuff for filters/tags/etc.
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "const slugify = require(\"slugify\");\n-module.exports = {\n+module.exports = function(config) {\n+ // universal filter\n+ config.addFilter(\"slug\", str => {\n+ return slugify(str, {\n+ replacement: \"-\",\n+ lower: true\n+ });\n+ });\n+\n+ return {\ntemplateFormats: [\n\"liquid\",\n\"ejs\",\n@@ -31,13 +40,9 @@ module.exports = {\noutput: \"_site\"\n},\nfilters: {},\n+ // deprecated, use config.addHandlebarsHelper\nhandlebarsHelpers: {},\n- nunjucksFilters: {\n- slug: str => {\n- return slugify(str, {\n- replacement: \"-\",\n- lower: true\n- });\n- }\n- }\n+ // deprecated, use config.addNunjucksFilter\n+ nunjucksFilters: {}\n+ };\n};\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyConfigTest.js", "new_path": "test/EleventyConfigTest.js", "diff": "@@ -21,6 +21,7 @@ test(\"Add Collections throws error on key collision\", t => {\neleventyConfig.addCollection(\"myCollectionCollision\", function(\ncollection\n) {});\n+\nt.throws(() => {\neleventyConfig.addCollection(\"myCollectionCollision\", function(\ncollection\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "import test from \"ava\";\nimport TemplateConfig from \"../src/TemplateConfig\";\n+// import eleventyConfig from \"../src/EleventyConfig\";\ntest(\"Template Config local config overrides base config\", async t => {\nlet templateCfg = new TemplateConfig(\n@@ -13,14 +14,16 @@ test(\"Template Config local config overrides base config\", async t => {\n// merged, not overwritten\nt.true(Object.keys(cfg.keys).length > 1);\n+ t.is(Object.keys(cfg.handlebarsHelpers).length, 1);\n+ t.is(Object.keys(cfg.nunjucksFilters).length, 2);\n- t.is(Object.keys(cfg.handlebarsHelpers).length, 0);\n- t.true(Object.keys(cfg.nunjucksFilters).length >= 2);\n-\n- t.true(Object.keys(cfg.filters).length >= 1);\n+ t.is(Object.keys(cfg.filters).length, 1);\nt.is(\n- cfg.filters.prettyHtml(`<html><body><div></div></body></html>`),\n+ cfg.filters.prettyHtml(\n+ `<html><body><div></div></body></html>`,\n+ \"test.html\"\n+ ),\n`<html>\n<body>\n<div></div>\n@@ -28,3 +31,14 @@ test(\"Template Config local config overrides base config\", async t => {\n</html>`\n);\n});\n+\n+// test(\"Add liquid tag\", t => {\n+// let templateCfg = new TemplateConfig(\n+// require(\"../config.js\"),\n+// \"./test/stubs/config.js\"\n+// );\n+// eleventyConfig.addLiquidTag(\"myTagName\", function() {}, function() {});\n+\n+// let cfg = templateCfg.getConfig();\n+// t.true(Object.keys(cfg.liquidTags).length > 1);\n+// });\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds (working) config api stuff for filters/tags/etc.
699
19.01.2018 09:35:40
21,600
bb3e9ec0b8c6cdfe75bc3ea743a6bc245afb7594
Only output pretty html for html output.
[ { "change_type": "MODIFY", "old_path": "test/stubs/config.js", "new_path": "test/stubs/config.js", "diff": "@@ -27,8 +27,11 @@ module.exports = function(config) {\n},\nfilters: {\nprettyHtml: function(str, outputPath) {\n- // todo check if HTML output before transforming\n+ if (outputPath.split(\".\").pop() === \"html\") {\nreturn pretty(str, { ocd: true });\n+ } else {\n+ return str;\n+ }\n}\n},\nnunjucksFilters: {\n" } ]
JavaScript
MIT License
11ty/eleventy
Only output pretty html for html output.
699
19.01.2018 20:36:56
21,600
f6700d86957480d3678b915b7b56b89105ca86d0
Adds filter tests for config api
[ { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "import test from \"ava\";\nimport TemplateConfig from \"../src/TemplateConfig\";\n-// import eleventyConfig from \"../src/EleventyConfig\";\n+import eleventyConfig from \"../src/EleventyConfig\";\ntest(\"Template Config local config overrides base config\", async t => {\nlet templateCfg = new TemplateConfig(\n@@ -32,13 +32,63 @@ test(\"Template Config local config overrides base config\", async t => {\n);\n});\n-// test(\"Add liquid tag\", t => {\n-// let templateCfg = new TemplateConfig(\n-// require(\"../config.js\"),\n-// \"./test/stubs/config.js\"\n-// );\n-// eleventyConfig.addLiquidTag(\"myTagName\", function() {}, function() {});\n+test(\"Add liquid tag\", t => {\n+ eleventyConfig.addLiquidTag(\"myTagName\", function() {}, function() {});\n-// let cfg = templateCfg.getConfig();\n-// t.true(Object.keys(cfg.liquidTags).length > 1);\n-// });\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.liquidTags).indexOf(\"myTagName\"), -1);\n+});\n+\n+test(\"Add liquid filter\", t => {\n+ eleventyConfig.addLiquidFilter(\"myFilterName\", function() {}, function() {});\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.liquidFilters).indexOf(\"myFilterName\"), -1);\n+});\n+\n+test(\"Add handlebars helper\", t => {\n+ eleventyConfig.addHandlebarsHelper(\"myHelperName\", function() {});\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.handlebarsHelpers).indexOf(\"myHelperName\"), -1);\n+});\n+\n+test(\"Add nunjucks filter\", t => {\n+ eleventyConfig.addNunjucksFilter(\n+ \"myFilterName\",\n+ function() {},\n+ function() {}\n+ );\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.nunjucksFilters).indexOf(\"myFilterName\"), -1);\n+});\n+\n+test(\"Add universal filter\", t => {\n+ eleventyConfig.addFilter(\"myFilterName\", function() {}, function() {});\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.liquidFilters).indexOf(\"myFilterName\"), -1);\n+ t.not(Object.keys(cfg.handlebarsHelpers).indexOf(\"myFilterName\"), -1);\n+ t.not(Object.keys(cfg.nunjucksFilters).indexOf(\"myFilterName\"), -1);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/config.js", "new_path": "test/stubs/config.js", "diff": "@@ -13,11 +13,6 @@ module.exports = function(config) {\ndata,\ndate\n} */\n- config.addCollection(\"postDescendingByDate\", function(collection) {\n- return collection.getFilteredByTag(\"post\").sort(function(a, b) {\n- return a.date - b.date;\n- });\n- });\nreturn {\nmarkdownTemplateEngine: \"ejs\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds filter tests for config api
699
21.01.2018 21:56:05
21,600
93d09428baec4608f20a5ac957eb94034a83ee1f
Debug an error message if local project config has an error inside of it.
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "+const chalk = require(\"chalk\");\nconst fs = require(\"fs-extra\");\nconst lodashMerge = require(\"lodash.merge\");\nconst TemplatePath = require(\"./TemplatePath\");\n@@ -15,7 +16,9 @@ class TemplateConfig {\nif (typeof this.rootConfig === \"function\") {\nthis.rootConfig = this.rootConfig(eleventyConfig);\n+ // debug( \"rootConfig is a function, after calling, eleventyConfig is %o\", eleventyConfig );\n}\n+ debug(\"rootConfig %o\", this.rootConfig);\nthis.config = this.mergeConfig(this.projectConfigPath);\n}\n@@ -31,27 +34,33 @@ class TemplateConfig {\n}\nmergeConfig(projectConfigPath) {\n- debug(`Merging config with ${projectConfigPath}`);\nlet localConfig;\nlet path = TemplatePath.normalize(\nTemplatePath.getWorkingDir() + \"/\" + projectConfigPath\n);\n+ debug(`Merging config with ${path}`);\ntry {\nlocalConfig = require(path);\n- } catch (e) {\n+ // debug( \"localConfig require return value: %o\", localConfig );\n+ } catch (err) {\n+ // TODO if file does exist, rethrow the error or console.log the error (file has syntax problem)\n+\n// if file does not exist, return empty obj\nlocalConfig = {};\n+ debug(chalk.red(\"Problem getting localConfig file, %o\"), err);\n}\nif (typeof localConfig === \"function\") {\nlocalConfig = localConfig(eleventyConfig);\n+ // debug( \"localConfig is a function, after calling, eleventyConfig is %o\", eleventyConfig );\n}\nlocalConfig = lodashMerge(\nlocalConfig,\neleventyConfig.getMergingConfigObject()\n);\n- debug(\"localConfig: %O\", localConfig);\n+ // debug(\"eleventyConfig.getMergingConfigObject: %o\", eleventyConfig.getMergingConfigObject());\n+ debug(\"localConfig: %o\", localConfig);\n// Object assign overrides original values (good only for templateFormats) but not good for anything else\nlet merged = lodashMerge({}, this.rootConfig, localConfig);\n" } ]
JavaScript
MIT License
11ty/eleventy
Debug an error message if local project config has an error inside of it.
699
21.01.2018 21:56:49
21,600
a6e0573cc5099c9ce9df3c3223e02f08c07f93e9
Moderate improvements to custom liquid tag API.
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -67,14 +67,16 @@ test(\"Liquid Custom Filter\", async t => {\ntest(\"Liquid Custom Tag prefixWithZach\", async t => {\nlet tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.addTag(\"prefixWithZach\", {\n+ tr.engine.addTag(\"prefixWithZach\", function(liquidEngine) {\n+ return {\nparse: function(tagToken, remainTokens) {\nthis.str = tagToken.args; // name\n},\nrender: function(scope, hash) {\n- var str = LiquidLib.evalValue(this.str, scope); // 'alice'\n+ var str = liquidEngine.evalValue(this.str, scope); // 'alice'\nreturn Promise.resolve(\"Zach\" + str); // 'Alice'\n}\n+ };\n});\nt.is(\n@@ -85,14 +87,16 @@ test(\"Liquid Custom Tag prefixWithZach\", async t => {\ntest(\"Liquid Custom Tag postfixWithZach\", async t => {\nlet tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n- tr.engine.addTag(\"postfixWithZach\", {\n+ tr.engine.addTag(\"postfixWithZach\", function(liquidEngine) {\n+ return {\nparse: function(tagToken, remainTokens) {\nthis.str = tagToken.args;\n},\nrender: function(scope, hash) {\n- var str = LiquidLib.evalValue(this.str, scope);\n+ var str = liquidEngine.evalValue(this.str, scope);\nreturn Promise.resolve(str + \"Zach\");\n}\n+ };\n});\nt.is(\n" } ]
JavaScript
MIT License
11ty/eleventy
Moderate improvements to custom liquid tag API.
699
21.01.2018 21:57:03
21,600
e87fab46823b6858bd0476df8d06190cd5d51b76
Permalink tests
[ { "change_type": "MODIFY", "old_path": "test/TemplatePermalinkTest.js", "new_path": "test/TemplatePermalinkTest.js", "diff": "@@ -36,6 +36,10 @@ test(\"Permalink without filename\", t => {\nnew TemplatePermalink(\"./permalinksubfolder/\").toString(),\n\"permalinksubfolder/index.html\"\n);\n+ t.is(\n+ new TemplatePermalink(\"/permalinksubfolder/\").toString(),\n+ \"/permalinksubfolder/index.html\"\n+ );\nt.is(\nnew TemplatePermalink(\"permalinksubfolder/\").toHref(),\n@@ -45,6 +49,10 @@ test(\"Permalink without filename\", t => {\nnew TemplatePermalink(\"./permalinksubfolder/\").toHref(),\n\"permalinksubfolder/\"\n);\n+ t.is(\n+ new TemplatePermalink(\"/permalinksubfolder/\").toHref(),\n+ \"/permalinksubfolder/\"\n+ );\n});\ntest(\"Permalink with pagination subdir\", t => {\n" } ]
JavaScript
MIT License
11ty/eleventy
Permalink tests
699
22.01.2018 22:02:09
21,600
ddb8d0da68d2ff8ef78b2d2044865ed2c6203a47
Superfluous debug statements for Adds "commonmark" markdown standards.
[ { "change_type": "MODIFY", "old_path": "src/Engines/Markdown.js", "new_path": "src/Engines/Markdown.js", "diff": "-const mdlib = require(\"markdown-it\")({\n- html: true\n-});\n+const mdlib = require(\"markdown-it\")(\"commonmark\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n+const debug = require(\"debug\")(\"Eleventy:Markdown\");\nclass Markdown extends TemplateEngine {\nasync compile(str, preTemplateEngine, bypassMarkdown) {\n@@ -18,11 +17,13 @@ class Markdown extends TemplateEngine {\n};\n} else {\nreturn async function(data) {\n- return mdlib.render(await fn(data));\n+ let preTemplateEngineRender = await fn(data);\n+ let finishedRender = mdlib.render(preTemplateEngineRender);\n+ return finishedRender;\n};\n}\n} else {\n- return function(data) {\n+ return function() {\n// throw away data if preTemplateEngine is falsy\nreturn mdlib.render(str);\n};\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -80,7 +80,7 @@ class Template {\nlet permalink = this.getFrontMatterData()[this.config.keys.permalink];\nif (permalink) {\nlet data = await this.getData();\n- debug(\"Rendering permalink for %o\", this.inputPath);\n+ // debug(\"Rendering permalink for %o\", this.inputPath);\nlet perm = new TemplatePermalink(\n// render variables inside permalink front matter\nawait this.renderContent(permalink, data, {\n@@ -138,11 +138,11 @@ class Template {\ngetLayoutTemplate(layoutPath) {\nlet path = new TemplateLayout(layoutPath, this.layoutsDir).getFullPath();\n- debug(\n- \"creating new Template %o in getLayoutTemplate for %o\",\n- path,\n- this.inputPath\n- );\n+ // debug(\n+ // \"creating new Template %o in getLayoutTemplate for %o\",\n+ // path,\n+ // this.inputPath\n+ // );\nreturn new Template(path, this.inputDir, this.outputDir);\n}\n@@ -190,7 +190,7 @@ class Template {\n}\nreturn obj;\n} else if (typeof data === \"string\") {\n- debug(\"rendering renderData variables for %o\", this.inputPath);\n+ debug(\"rendering data.renderData for %o\", this.inputPath);\nlet str = await this.renderContent(data, templateData, {\nbypassMarkdown: true\n});\n@@ -247,13 +247,13 @@ class Template {\n}\nasync renderLayout(tmpl, tmplData, forcedLayoutPath) {\n- debug(`${tmpl.inputPath} renderLayout()`);\n+ // debug(`${tmpl.inputPath} renderLayout()`);\nlet layoutPath = forcedLayoutPath || tmplData[tmpl.config.keys.layout];\n// debug(\"Template %o is using layout: %o\", this.inputPath, layoutPath);\nif (!this.initialLayout) {\nthis.initialLayout = tmplData[tmpl.config.keys.layout];\n- debug(\"Saved layout: %o for %o\", this.initialLayout, this.inputPath);\n+ // debug(\"Saved layout: %o for %o\", this.initialLayout, this.inputPath);\n}\n// TODO make layout key to be available to templates (without it causing issues with merge below)\ndelete tmplData[tmpl.config.keys.layout];\n@@ -262,9 +262,9 @@ class Template {\nlet layoutData = await layout.getData(tmplData);\n// debug(\"layoutData: %O\", layoutData)\n// debug(\"tmplData (passed to layoutContent = renderContent(): %O\", tmplData);\n- debug(\"renderLayout -> renderContent(%o)\", tmpl.getPreRender());\n+ // debug(\"renderLayout -> renderContent(%o)\", tmpl.getPreRender());\nlet layoutContent = await tmpl.renderContent(tmpl.getPreRender(), tmplData);\n- debug(\"renderLayout -> layoutContent %o\", layoutContent);\n+ // debug(\"renderLayout -> layoutContent %o\", layoutContent);\nlayoutData.content = layoutContent;\nlayoutData.layoutContent = layoutContent;\n// Deprecated\n@@ -291,9 +291,10 @@ class Template {\nthis.templateRender.engineName\n}`\n);\n- if (data.layoutContent) {\n- debug(\"renderContent -> layoutContent %o\", data.layoutContent);\n- }\n+\n+ // if (data.layoutContent) {\n+ // debug(\"renderContent -> layoutContent %o\", data.layoutContent);\n+ // }\nlet fn = await this.templateRender.getCompiledTemplate(str, options);\nreturn fn(data);\n}\n@@ -306,7 +307,7 @@ class Template {\n}\nasync render(data) {\n- debug(`${this.inputPath} render()`);\n+ // debug(`${this.inputPath} render()`);\nif (!data) {\ndata = await this.getRenderedData();\n}\n@@ -324,7 +325,7 @@ class Template {\n) {\nreturn this.renderLayout(this, data, this.initialLayout);\n} else {\n- debug(\"Template.render renderContent for %o\", this.inputPath);\n+ // debug(\"Template.render renderContent for %o\", this.inputPath);\nreturn this.renderContent(this.getPreRender(), data);\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Superfluous debug statements for #44. Adds "commonmark" markdown standards.
699
22.01.2018 22:44:51
21,600
48896c4d7da1a15a3c23f97c62e753eb3b8935ce
Adds `urlPrefix` config option and universal `url` filter for links. Fixes
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "const slugify = require(\"slugify\");\n+const TemplatePath = require(\"./src/TemplatePath\");\nmodule.exports = function(config) {\n// universal filter\n@@ -9,6 +10,24 @@ module.exports = function(config) {\n});\n});\n+ config.addFilter(\"url\", function(url, urlPrefix) {\n+ if (!urlPrefix || typeof urlPrefix !== \"string\") {\n+ let projectConfig = require(\"./src/Config\").getConfig();\n+ urlPrefix = projectConfig.urlPrefix;\n+ }\n+\n+ let rootDir = urlPrefix;\n+\n+ if (!url || url === rootDir) {\n+ return TemplatePath.normalize(rootDir);\n+ // absolute or relative url\n+ } else if (url.charAt(0) === \"/\" || url.indexOf(\"../\") === 0) {\n+ return TemplatePath.normalize(url);\n+ }\n+\n+ return TemplatePath.normalize(rootDir, url);\n+ });\n+\nreturn {\ntemplateFormats: [\n\"liquid\",\n@@ -22,6 +41,8 @@ module.exports = function(config) {\n\"html\",\n\"jstl\"\n],\n+ // if your site lives in a subdirectory, change this\n+ urlPrefix: \"/\",\nmarkdownTemplateEngine: \"liquid\",\nhtmlTemplateEngine: \"liquid\",\ndataTemplateEngine: \"liquid\",\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -249,12 +249,13 @@ class Template {\nasync renderLayout(tmpl, tmplData, forcedLayoutPath) {\n// debug(`${tmpl.inputPath} renderLayout()`);\nlet layoutPath = forcedLayoutPath || tmplData[tmpl.config.keys.layout];\n- // debug(\"Template %o is using layout: %o\", this.inputPath, layoutPath);\n+ debug(\"Template %o is using layout: %o\", this.inputPath, layoutPath);\nif (!this.initialLayout) {\nthis.initialLayout = tmplData[tmpl.config.keys.layout];\n- // debug(\"Saved layout: %o for %o\", this.initialLayout, this.inputPath);\n+ debug(\"Saved layout: %o for %o\", this.initialLayout, this.inputPath);\n}\n+\n// TODO make layout key to be available to templates (without it causing issues with merge below)\ndelete tmplData[tmpl.config.keys.layout];\n@@ -265,6 +266,7 @@ class Template {\n// debug(\"renderLayout -> renderContent(%o)\", tmpl.getPreRender());\nlet layoutContent = await tmpl.renderContent(tmpl.getPreRender(), tmplData);\n// debug(\"renderLayout -> layoutContent %o\", layoutContent);\n+\nlayoutData.content = layoutContent;\nlayoutData.layoutContent = layoutContent;\n// Deprecated\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "@@ -14,8 +14,8 @@ test(\"Template Config local config overrides base config\", async t => {\n// merged, not overwritten\nt.true(Object.keys(cfg.keys).length > 1);\n- t.is(Object.keys(cfg.handlebarsHelpers).length, 1);\n- t.is(Object.keys(cfg.nunjucksFilters).length, 2);\n+ t.truthy(Object.keys(cfg.handlebarsHelpers).length);\n+ t.truthy(Object.keys(cfg.nunjucksFilters).length);\nt.is(Object.keys(cfg.filters).length, 1);\n@@ -92,3 +92,23 @@ 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+\n+test(\"Test url universal filter\", t => {\n+ eleventyConfig.addFilter(\"myFilterName\", function() {}, function() {});\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+\n+ t.is(cfg.liquidFilters.url(\"/\", cfg.urlPrefix), \"/\");\n+ t.is(cfg.liquidFilters.url(\"//\", cfg.urlPrefix), \"/\");\n+ t.is(cfg.liquidFilters.url(\"/test\", cfg.urlPrefix), \"/test\");\n+ t.is(cfg.liquidFilters.url(\"//test\", cfg.urlPrefix), \"/test\");\n+ t.is(cfg.liquidFilters.url(\"../test\", cfg.urlPrefix), \"../test\");\n+\n+ // Prefix with rootDir\n+ t.is(cfg.liquidFilters.url(\"./test\", cfg.urlPrefix), \"/testdir/test\");\n+ t.is(cfg.liquidFilters.url(\"test\", cfg.urlPrefix), \"/testdir/test\");\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/config.js", "new_path": "test/stubs/config.js", "diff": "@@ -17,6 +17,9 @@ module.exports = function(config) {\nreturn {\nmarkdownTemplateEngine: \"ejs\",\ntemplateFormats: [\"md\", \"njk\"],\n+\n+ urlPrefix: \"/testdir\",\n+\nkeys: {\npackage: \"pkg2\"\n},\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `urlPrefix` config option and universal `url` filter for links. Fixes #45
699
22.01.2018 22:45:32
21,600
b6a641fc9dcb6a36b160801f25e4fe947f7de4a2
Adds more docs. Fixes
[ { "change_type": "ADD", "old_path": null, "new_path": "docs/filters.md", "diff": "+# Filters, Tags, etc.\n+\n+Various template engines can be extended with custom `filters` or custom tags.\n+\n+_Experimental._ Eleventy provides a few universal filters that can be used in supported template types (currently Nunjucks, Liquid, and Handlebars).\n+\n+More information:\n+\n+* [Nunjucks Filters](https://mozilla.github.io/nunjucks/templating.html#filters)\n+* [Handlebars Helpers](http://handlebarsjs.com/#helpers)\n+* [Liquid Filters](https://github.com/harttle/liquidjs#register-filters)\n+* [Liquid Tags](https://github.com/harttle/liquidjs#register-tags)\n+\n+## Url\n+\n+Works with the `urlPrefix` configuration option to properly normalize relative and absolute paths to your content.\n+\n+```\n+<a href=\"{{ post.url | url }}\">Liquid or Nunjucks Link</a>\n+```\n+\n+## Slug\n+\n+Uses the `slugify` package to convert a string into a URL slug. Can be used in pagination or permalinks.\n+\n+```\n+{{ \"My Title\" | slug }} -> `my-title`\n+```\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds more docs. Fixes #42
699
22.01.2018 23:00:21
21,600
a2fa7a8e801156816b997d4d87624f32c2379f66
v0.2.8, 199 tests, 86.3% code coverage
[ { "change_type": "MODIFY", "old_path": "docs-src/_data/coverage.json", "new_path": "docs-src/_data/coverage.json", "diff": "{\n\"total\": {\n- \"lines\": { \"total\": 1050, \"covered\": 900, \"skipped\": 0, \"pct\": 85.71 },\n- \"statements\": { \"total\": 1050, \"covered\": 900, \"skipped\": 0, \"pct\": 85.71 },\n- \"functions\": { \"total\": 236, \"covered\": 192, \"skipped\": 0, \"pct\": 81.36 },\n- \"branches\": { \"total\": 281, \"covered\": 225, \"skipped\": 0, \"pct\": 80.07 }\n+ \"lines\": { \"total\": 1131, \"covered\": 976, \"skipped\": 0, \"pct\": 86.3 },\n+ \"statements\": { \"total\": 1131, \"covered\": 976, \"skipped\": 0, \"pct\": 86.3 },\n+ \"functions\": { \"total\": 253, \"covered\": 209, \"skipped\": 0, \"pct\": 82.61 },\n+ \"branches\": { \"total\": 309, \"covered\": 248, \"skipped\": 0, \"pct\": 80.26 }\n},\n\"/Users/zachleat/Code/eleventy/config.js\": {\n- \"lines\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 1, \"covered\": 1, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 16, \"covered\": 13, \"skipped\": 0, \"pct\": 81.25 },\n+ \"functions\": { \"total\": 3, \"covered\": 3, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 16, \"covered\": 13, \"skipped\": 0, \"pct\": 81.25 },\n+ \"branches\": { \"total\": 12, \"covered\": 10, \"skipped\": 0, \"pct\": 83.33 }\n},\n\"/Users/zachleat/Code/eleventy/src/Config.js\": {\n\"lines\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 22, \"covered\": 10, \"skipped\": 0, \"pct\": 45.45 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\n- \"lines\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 5, \"covered\": 5, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 33, \"covered\": 30, \"skipped\": 0, \"pct\": 90.91 },\n+ \"functions\": { \"total\": 13, \"covered\": 11, \"skipped\": 0, \"pct\": 84.62 },\n+ \"statements\": { \"total\": 33, \"covered\": 30, \"skipped\": 0, \"pct\": 90.91 },\n+ \"branches\": { \"total\": 4, \"covered\": 3, \"skipped\": 0, \"pct\": 75 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyError.js\": {\n\"lines\": { \"total\": 13, \"covered\": 1, \"skipped\": 0, \"pct\": 7.69 },\n\"branches\": { \"total\": 2, \"covered\": 0, \"skipped\": 0, \"pct\": 0 }\n},\n\"/Users/zachleat/Code/eleventy/src/Template.js\": {\n- \"lines\": { \"total\": 190, \"covered\": 163, \"skipped\": 0, \"pct\": 85.79 },\n+ \"lines\": { \"total\": 195, \"covered\": 168, \"skipped\": 0, \"pct\": 86.15 },\n\"functions\": { \"total\": 41, \"covered\": 34, \"skipped\": 0, \"pct\": 82.93 },\n- \"statements\": { \"total\": 190, \"covered\": 163, \"skipped\": 0, \"pct\": 85.79 },\n- \"branches\": { \"total\": 72, \"covered\": 55, \"skipped\": 0, \"pct\": 76.39 }\n+ \"statements\": { \"total\": 195, \"covered\": 168, \"skipped\": 0, \"pct\": 86.15 },\n+ \"branches\": { \"total\": 74, \"covered\": 57, \"skipped\": 0, \"pct\": 77.03 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\n\"lines\": { \"total\": 13, \"covered\": 12, \"skipped\": 0, \"pct\": 92.31 },\n\"branches\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\n- \"lines\": { \"total\": 26, \"covered\": 24, \"skipped\": 0, \"pct\": 92.31 },\n+ \"lines\": { \"total\": 35, \"covered\": 33, \"skipped\": 0, \"pct\": 94.29 },\n\"functions\": { \"total\": 4, \"covered\": 3, \"skipped\": 0, \"pct\": 75 },\n- \"statements\": { \"total\": 26, \"covered\": 24, \"skipped\": 0, \"pct\": 92.31 },\n- \"branches\": { \"total\": 8, \"covered\": 8, \"skipped\": 0, \"pct\": 100 }\n+ \"statements\": { \"total\": 35, \"covered\": 33, \"skipped\": 0, \"pct\": 94.29 },\n+ \"branches\": { \"total\": 12, \"covered\": 11, \"skipped\": 0, \"pct\": 91.67 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\n\"lines\": { \"total\": 70, \"covered\": 69, \"skipped\": 0, \"pct\": 98.57 },\n\"branches\": { \"total\": 8, \"covered\": 7, \"skipped\": 0, \"pct\": 87.5 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateLayout.js\": {\n- \"lines\": { \"total\": 24, \"covered\": 23, \"skipped\": 0, \"pct\": 95.83 },\n- \"functions\": { \"total\": 5, \"covered\": 5, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 24, \"covered\": 23, \"skipped\": 0, \"pct\": 95.83 },\n- \"branches\": { \"total\": 10, \"covered\": 9, \"skipped\": 0, \"pct\": 90 }\n+ \"lines\": { \"total\": 39, \"covered\": 38, \"skipped\": 0, \"pct\": 97.44 },\n+ \"functions\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 39, \"covered\": 38, \"skipped\": 0, \"pct\": 97.44 },\n+ \"branches\": { \"total\": 16, \"covered\": 15, \"skipped\": 0, \"pct\": 93.75 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateMap.js\": {\n\"lines\": { \"total\": 66, \"covered\": 64, \"skipped\": 0, \"pct\": 96.97 },\n\"branches\": { \"total\": 18, \"covered\": 18, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\n- \"lines\": { \"total\": 37, \"covered\": 35, \"skipped\": 0, \"pct\": 94.59 },\n- \"functions\": { \"total\": 9, \"covered\": 8, \"skipped\": 0, \"pct\": 88.89 },\n- \"statements\": { \"total\": 37, \"covered\": 35, \"skipped\": 0, \"pct\": 94.59 },\n+ \"lines\": { \"total\": 37, \"covered\": 36, \"skipped\": 0, \"pct\": 97.3 },\n+ \"functions\": { \"total\": 9, \"covered\": 9, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 37, \"covered\": 36, \"skipped\": 0, \"pct\": 97.3 },\n\"branches\": { \"total\": 14, \"covered\": 12, \"skipped\": 0, \"pct\": 85.71 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\n\"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Liquid.js\": {\n- \"lines\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 23, \"covered\": 21, \"skipped\": 0, \"pct\": 91.3 },\n+ \"functions\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 23, \"covered\": 21, \"skipped\": 0, \"pct\": 91.3 },\n+ \"branches\": { \"total\": 2, \"covered\": 1, \"skipped\": 0, \"pct\": 50 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Markdown.js\": {\n- \"lines\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n+ \"lines\": { \"total\": 16, \"covered\": 16, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 16, \"covered\": 16, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Mustache.js\": {\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/TemplateEngine.js\": {\n- \"lines\": { \"total\": 31, \"covered\": 28, \"skipped\": 0, \"pct\": 90.32 },\n- \"functions\": { \"total\": 9, \"covered\": 7, \"skipped\": 0, \"pct\": 77.78 },\n- \"statements\": { \"total\": 31, \"covered\": 28, \"skipped\": 0, \"pct\": 90.32 },\n+ \"lines\": { \"total\": 31, \"covered\": 30, \"skipped\": 0, \"pct\": 96.77 },\n+ \"functions\": { \"total\": 9, \"covered\": 8, \"skipped\": 0, \"pct\": 88.89 },\n+ \"statements\": { \"total\": 31, \"covered\": 30, \"skipped\": 0, \"pct\": 96.77 },\n\"branches\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Plugins/Pagination.js\": {\n" }, { "change_type": "MODIFY", "old_path": "docs/coverage.md", "new_path": "docs/coverage.md", "diff": "-# Code Coverage for Eleventy v0.2.7\n+# Code Coverage for Eleventy v0.2.8\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------- | ------- | ------------ | ----------- | ---------- |\n-| `total` | 85.71% | 85.71% | 81.36% | 80.07% |\n-| `config.js` | 100% | 100% | 100% | 100% |\n+| `total` | 86.3% | 86.3% | 82.61% | 80.26% |\n+| `config.js` | 81.25% | 81.25% | 100% | 83.33% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n| `src/Eleventy.js` | 62.39% | 62.39% | 38.89% | 45.45% |\n-| `src/EleventyConfig.js` | 100% | 100% | 100% | 100% |\n+| `src/EleventyConfig.js` | 90.91% | 90.91% | 84.62% | 75% |\n| `src/EleventyError.js` | 7.69% | 7.69% | 0% | 0% |\n-| `src/Template.js` | 85.79% | 85.79% | 82.93% | 76.39% |\n+| `src/Template.js` | 86.15% | 86.15% | 82.93% | 77.03% |\n| `src/TemplateCollection.js` | 92.31% | 92.31% | 100% | 83.33% |\n-| `src/TemplateConfig.js` | 92.31% | 92.31% | 75% | 100% |\n+| `src/TemplateConfig.js` | 94.29% | 94.29% | 75% | 91.67% |\n| `src/TemplateData.js` | 98.57% | 98.57% | 100% | 75% |\n| `src/TemplateGlob.js` | 93.75% | 93.75% | 100% | 87.5% |\n-| `src/TemplateLayout.js` | 95.83% | 95.83% | 100% | 90% |\n+| `src/TemplateLayout.js` | 97.44% | 97.44% | 100% | 93.75% |\n| `src/TemplateMap.js` | 96.97% | 96.97% | 100% | 80% |\n| `src/TemplatePassthrough.js` | 77.78% | 77.78% | 66.67% | 100% |\n| `src/TemplatePath.js` | 100% | 100% | 87.5% | 100% |\n| `src/TemplatePermalink.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateRender.js` | 94.59% | 94.59% | 88.89% | 85.71% |\n+| `src/TemplateRender.js` | 97.3% | 97.3% | 100% | 85.71% |\n| `src/TemplateWriter.js` | 72.03% | 72.03% | 60% | 63.33% |\n| `src/Engines/Ejs.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Haml.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Handlebars.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Html.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/JavaScript.js` | 93.33% | 93.33% | 100% | 100% |\n-| `src/Engines/Liquid.js` | 100% | 100% | 100% | 100% |\n+| `src/Engines/Liquid.js` | 91.3% | 91.3% | 100% | 50% |\n| `src/Engines/Markdown.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Mustache.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Nunjucks.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Pug.js` | 100% | 100% | 100% | 100% |\n-| `src/Engines/TemplateEngine.js` | 90.32% | 90.32% | 77.78% | 100% |\n+| `src/Engines/TemplateEngine.js` | 96.77% | 96.77% | 88.89% | 100% |\n| `src/Plugins/Pagination.js` | 93.42% | 93.42% | 100% | 87.5% |\n| `src/Util/Capitalize.js` | 100% | 100% | 100% | 100% |\n| `src/Util/Pluralize.js` | 100% | 100% | 100% | 100% |\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"0.2.7\",\n+ \"version\": \"0.2.8\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n" } ]
JavaScript
MIT License
11ty/eleventy
v0.2.8, 199 tests, 86.3% code coverage
690
24.01.2018 10:16:09
-3,600
95b01c2209a6987f98dc5db02617f1dd11731120
Fix read more links in README.md
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -291,12 +291,12 @@ npm run test\n## Read more\n-* [docs/collections.md](Collections)\n-* [docs/pitfalls.md](Common Pitfalls)\n-* [docs/filters.md](Custom Filters and Tags)\n-* [docs/install-local.md](Install eleventy into a specific project)\n-* [docs/pagination.md](Pagination, splitting content across multiple files)\n-* [docs/copy.md](Pass-through file copy) for images, JS, CSS.\n-* [docs/permalinks.md](Permalinks, remapping content to a new output location)\n-* [docs/data.md](Template Data Files)\n-* [docs/layouts.md](Template Layouts)\n+* [Collections](docs/collections.md)\n+* [Common Pitfalls](docs/pitfalls.md)\n+* [Custom Filters and Tags](docs/filters.md)\n+* [Install eleventy into a specific project](docs/install-local.md)\n+* [Pagination, splitting content across multiple files](docs/pagination.md)\n+* [Pass-through file copy](docs/copy.md) for images, JS, CSS.\n+* [Permalinks, remapping content to a new output location](docs/permalinks.md)\n+* [Template Data Files](docs/data.md)\n+* [Template Layouts](docs/layouts.md)\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix read more links in README.md
699
25.01.2018 20:36:08
21,600
bb01a01c395698563c44684379b77c121abd4f17
Adds --pathprefix to set the config.pathPrefix configuration at runtime, added to make eleventy-base-blog work with both Netlify and GitHub pages on the same repo.
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -11,6 +11,7 @@ EleventyNodeVersionCheck().then(function() {\n(argv.output ? \" --output=\" + argv.output : \"\") +\n(argv.formats ? \" --formats=\" + argv.formats : \"\") +\n(argv.config ? \" --config=\" + argv.config : \"\") +\n+ (argv.config ? \" --pathprefix=\" + argv.pathprefix : \"\") +\n(argv.quiet ? \" --quiet\" : \"\") +\n(argv.version ? \" --version\" : \"\") +\n(argv.watch ? \" --watch\" : \"\")\n@@ -18,6 +19,7 @@ EleventyNodeVersionCheck().then(function() {\nlet elev = new Eleventy(argv.input, argv.output);\nelev.setConfigPath(argv.config);\n+ elev.setPathPrefix(argv.pathprefix);\nelev.setFormats(argv.formats);\nif (process.env.DEBUG) {\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds --pathprefix to set the config.pathPrefix configuration at runtime, added to make eleventy-base-blog work with both Netlify and GitHub pages on the same repo.
699
25.01.2018 20:45:52
21,600
01890bb2879dd834ecfe56817f637e4c177081eb
Move url tests to their own file.
[ { "change_type": "MODIFY", "old_path": "src/Filters/Url.js", "new_path": "src/Filters/Url.js", "diff": "@@ -2,11 +2,6 @@ const validUrl = require(\"valid-url\");\nconst TemplatePath = require(\"../TemplatePath\");\nmodule.exports = function(url, pathPrefix) {\n- if (pathPrefix === undefined || typeof pathPrefix !== \"string\") {\n- let projectConfig = require(\"../Config\").getConfig();\n- pathPrefix = projectConfig.pathPrefix;\n- }\n-\nif (\nvalidUrl.isUri(url) ||\nurl.indexOf(\"http://\") === 0 ||\n@@ -15,6 +10,11 @@ module.exports = function(url, pathPrefix) {\nreturn url;\n}\n+ if (pathPrefix === undefined || typeof pathPrefix !== \"string\") {\n+ let projectConfig = require(\"../Config\").getConfig();\n+ pathPrefix = projectConfig.pathPrefix;\n+ }\n+\nlet normUrl = TemplatePath.normalizeUrlPath(url);\nlet normRootDir = TemplatePath.normalizeUrlPath(\"/\", pathPrefix);\nlet normFull = TemplatePath.normalizeUrlPath(\"/\", pathPrefix, url);\n" } ]
JavaScript
MIT License
11ty/eleventy
Move url tests to their own file.
699
25.01.2018 20:56:06
21,600
bd402150f44312f9a4eac4f044cbd50426e43905
Tests for EleventyError
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -205,7 +205,9 @@ I want to hear it! Open an issue: https://github.com/11ty/eleventy/issues/new`);\nconsole.log(\"\\n\" + chalk.red(\"Problem writing eleventy templates: \"));\nif (e instanceof EleventyError) {\nconsole.log(chalk.red(e.log()));\n- console.log(\"\\n\" + e.dump());\n+ for (let err of e.getAll()) {\n+ debug(\"%o\", err);\n+ }\n} else {\nconsole.log(e);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyError.js", "new_path": "src/EleventyError.js", "diff": "@@ -17,10 +17,8 @@ class EleventyError {\nthis.errors.push(errorObj);\n}\n- dump() {\n- for (let err of this.errors) {\n- console.log(err);\n- }\n+ getAll() {\n+ return this.errors;\n}\nlog() {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/EleventyErrorTest.js", "diff": "+import test from \"ava\";\n+import EleventyError from \"../src/EleventyError\";\n+\n+test(\"Constructor\", t => {\n+ let oldError = new Error();\n+ let newError = new Error();\n+ let ee = new EleventyError(newError, oldError);\n+\n+ t.is(ee.errors.length, 2);\n+});\n+\n+test(\"Static Constructor\", t => {\n+ let oldError = new Error();\n+ let newError = new Error();\n+ let ee = EleventyError.make(newError, oldError);\n+\n+ t.is(ee.errors.length, 2);\n+});\n+\n+test(\"Static Constructor with already existing EleventyError\", t => {\n+ let oldError = new Error();\n+ let newError = new Error();\n+ let ee1 = EleventyError.make(newError, oldError);\n+\n+ let newError2 = new Error();\n+ let ee2 = EleventyError.make(newError2, ee1);\n+\n+ t.is(ee1.errors.length, 3);\n+ t.is(ee2.errors.length, 3);\n+});\n+\n+test(\"getAll\", t => {\n+ let oldError = new Error();\n+ let newError = new Error();\n+ let ee = EleventyError.make(newError, oldError);\n+\n+ t.is(ee.getAll().length, 2);\n+});\n+\n+test(\"log\", t => {\n+ let oldError = new Error();\n+ let newError = new Error();\n+ let ee = EleventyError.make(newError, oldError);\n+\n+ t.truthy(ee.log());\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Tests for EleventyError
699
27.01.2018 23:13:19
21,600
715ae24f9ddbd749f75fa6c4ebdb72fb83312f0f
Debug for collection dates
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -428,6 +428,11 @@ class Template {\n// should we use Luxon dates everywhere? Right now using built-in `Date`\nif (\"date\" in data) {\n+ debug(\n+ \"getMappedDate: using a date in the data for %o of %o\",\n+ this.inputPath,\n+ data.date\n+ );\nif (data.date instanceof Date) {\n// YAML does its own date parsing\nreturn data.date;\n@@ -454,11 +459,23 @@ class Template {\n} else {\nlet filenameRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\nif (filenameRegex !== null) {\n+ debug(\n+ \"getMappedDate: using filename regex time for %o of %o\",\n+ this.inputPath,\n+ filenameRegex[1]\n+ );\nreturn DateTime.fromISO(filenameRegex[1]).toJSDate();\n}\n+ let createdDate = new Date(stat.birthtimeMs);\n+ debug(\n+ \"getMappedDate: using file created time for %o of %o\",\n+ this.inputPath,\n+ createdDate\n+ );\n+\n// CREATED\n- return new Date(stat.birthtimeMs);\n+ return createdDate;\n}\nreturn date;\n" } ]
JavaScript
MIT License
11ty/eleventy
Debug for collection dates
699
28.01.2018 21:31:10
21,600
9fc21264c94a8252ed82390baae39b6eb40ecb15
Adds yellow chalk warnings if tags or filters get overwritten
[ { "change_type": "MODIFY", "old_path": "src/EleventyConfig.js", "new_path": "src/EleventyConfig.js", "diff": "const EventEmitter = require(\"events\");\nconst lodashget = require(\"lodash.get\");\nconst Sortable = require(\"./Util/Sortable\");\n+const chalk = require(\"chalk\");\nconst debug = require(\"debug\")(\"Eleventy:EleventyConfig\");\n// API to expose configuration options in config file\n@@ -37,27 +38,71 @@ class EleventyConfig {\n);\n}\n+ if (this.liquidTags[name]) {\n+ debug(\n+ chalk.yellow(\n+ \"Warning, overwriting a Liquid tag with `addLiquidTag(%o)`\"\n+ ),\n+ name\n+ );\n+ }\nthis.liquidTags[name] = tagFn;\n}\naddLiquidFilter(name, callback) {\n+ if (this.liquidFilters[name]) {\n+ debug(\n+ chalk.yellow(\n+ \"Warning, overwriting a Liquid filter with `addLiquidFilter(%o)`\"\n+ ),\n+ name\n+ );\n+ }\n+\nthis.liquidFilters[name] = callback;\n}\naddNunjucksAsyncFilter(name, callback) {\n+ if (this.nunjucksAsyncFilters[name]) {\n+ debug(\n+ chalk.yellow(\n+ \"Warning, overwriting a Nunjucks filter with `addNunjucksAsyncFilter(%o)`\"\n+ ),\n+ name\n+ );\n+ }\n+\nthis.nunjucksAsyncFilters[name] = callback;\n}\n// Support the nunjucks style syntax for asynchronous filter add\naddNunjucksFilter(name, callback, isAsync) {\nif (isAsync) {\n- this.nunjucksAsyncFilters[name] = callback;\n+ this.addNunjucksAsyncFilter(name, callback);\n} else {\n+ if (this.nunjucksFilters[name]) {\n+ debug(\n+ chalk.yellow(\n+ \"Warning, overwriting a Nunjucks filter with `addNunjucksFilter(%o)`\"\n+ ),\n+ name\n+ );\n+ }\n+\nthis.nunjucksFilters[name] = callback;\n}\n}\naddHandlebarsHelper(name, callback) {\n+ if (this.handlebarsHelpers[name]) {\n+ debug(\n+ chalk.yellow(\n+ \"Warning, overwriting a Handlebars helper with `addHandlebarsHelper(%o)`\"\n+ ),\n+ name\n+ );\n+ }\n+\nthis.handlebarsHelpers[name] = callback;\n}\n@@ -109,6 +154,12 @@ class EleventyConfig {\n}\naddPlugin(pluginCallback) {\n+ if (typeof pluginCallback !== \"function\") {\n+ throw new Error(\n+ \"EleventyConfig.addPlugin expects the first argument to be a function.\"\n+ );\n+ }\n+\npluginCallback(this);\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds yellow chalk warnings if tags or filters get overwritten
699
28.01.2018 21:43:21
21,600
dd8229d8e8c86f8f91499853a87df79298042943
Add plugins docs.
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -239,6 +239,10 @@ module.exports = function(eleventyConfig) {\nRead more about this on the [Collections documentation: Advanced Custom Filtering and Sorting](collections.md#advanced-custom-filtering-and-sorting).\n+#### Add official or third-party plugins\n+\n+Read more about [Plugins](docs/plugins.md).\n+\n## Template Engine Features\nHere are the features tested with each template engine that use external files and thus are subject to setup and scaffolding.\n@@ -285,9 +289,9 @@ npm run test\n* [x] Pagination\n* [x] Tagging of content\n+* [x] Plugin system\n* [ ] Extensibility with system-wide content mapping **IN PROGRESS**\n* [ ] Components system for development reusability\n-* [ ] Plugin system\n## Read more\n@@ -297,6 +301,7 @@ npm run test\n* [Install eleventy into a specific project](docs/install-local.md)\n* [Pagination, splitting content across multiple files](docs/pagination.md)\n* [Pass-through file copy](docs/copy.md) for images, JS, CSS.\n+* [Plugins](docs/plugins.md)\n* [Permalinks, remapping content to a new output location](docs/permalinks.md)\n* [Template Data Files](docs/data.md)\n* [Template Layouts](docs/layouts.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/plugins.md", "diff": "+# Plugins\n+\n+_New in Eleventy v0.2.13_ Plugins are custom code that Eleventy can import into a project from an external repository.\n+\n+## List of Available Plugins:\n+\n+* [`eleventy-plugin-rss`](https://github.com/11ty/eleventy-plugin-rss) is a collection of Nunjucks filters for RSS/Atom feed templates.\n+* [`eleventy-plugin-syntaxhighlight`](https://github.com/11ty/eleventy-plugin-syntaxhighlight) for custom syntax highlighting Liquid tags.\n+\n+## Adding a plugin.\n+\n+### Install the plugin through npm.\n+\n+```\n+npm install @11ty/eleventy-plugin-rss --save\n+```\n+\n+### Add the plugin to Eleventy in your config file\n+\n+Your config file is probably named `.eleventy.js`.\n+\n+```\n+const pluginRss = require(\"@11ty/eleventy-plugin-rss\");\n+module.exports = function(eleventyConfig) {\n+ eleventyConfig.addPlugin(pluginRss);\n+};\n+```\n" } ]
JavaScript
MIT License
11ty/eleventy
Add plugins docs.
699
31.01.2018 07:34:28
21,600
a3d9cb9731f509208d8c9255a43cf5071d365e82
Adds liquid test for includes that pass in data (albeit not with the variables scoped to `include` convention that Jekyll uses)
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -45,6 +45,18 @@ test(\"Liquid Render Include with HTML Suffix\", async t => {\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n+test(\"Liquid Render Include with HTML Suffix and Data Pass in\", async t => {\n+ t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\n+ \"{% include included-data.html, myVariable: 'myValue' %}\"\n+ );\n+ t.is((await fn()).trim(), \"This is an include. myValue\");\n+});\n+\n// This is an upstream limitation of the Liquid implementation\n// test(\"Liquid Render Include No Quotes\", async t => {\n// t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/_includes/included-data.html", "diff": "+This is an include. {{ myVariable }}\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds liquid test for includes that pass in data (albeit not with the variables scoped to `include` convention that Jekyll uses)
699
03.02.2018 00:21:32
21,600
2999e19f41d0c795003fd7959d8e13563436a0c2
Adds copy count to console log output
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -77,7 +77,15 @@ Eleventy.prototype.logFinished = function() {\nlet ret = [];\nlet writeCount = this.writer.getWriteCount();\n- ret.push(`Wrote ${writeCount} ${simplePlural(writeCount, \"file\", \"files\")}`);\n+ let copyCount = this.writer.getCopyCount();\n+ if (copyCount) {\n+ ret.push(\n+ `Copied ${copyCount} ${simplePlural(copyCount, \"file\", \"files\")} and`\n+ );\n+ }\n+ ret.push(\n+ `Processed ${writeCount} ${simplePlural(writeCount, \"file\", \"files\")}`\n+ );\nlet time = ((new Date() - this.start) / 1000).toFixed(2);\nret.push(`in ${time} ${simplePlural(time, \"second\", \"seconds\")}`);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -23,6 +23,7 @@ function TemplateWriter(inputPath, outputDir, extensions, templateData) {\nthis.templateData = templateData;\nthis.isVerbose = true;\nthis.writeCount = 0;\n+ this.copyCount = 0;\nthis.includesDir = this.inputDir + \"/\" + this.config.dir.includes;\n// Duplicated with TemplateData.getDataDir();\n@@ -49,7 +50,8 @@ function TemplateWriter(inputPath, outputDir, extensions, templateData) {\nTemplateWriter.prototype.restart = function() {\nthis.writeCount = 0;\n- debug(\"Resetting writeCount to 0\");\n+ this.copyCount = 0;\n+ debug(\"Resetting counts to 0\");\n};\nTemplateWriter.prototype.getIncludesDir = function() {\n@@ -200,8 +202,11 @@ TemplateWriter.prototype._copyPassthroughs = async function(paths) {\nreturn;\n}\n+ let count = 0;\n+ debug(\"TemplatePassthrough copy started.\");\nfor (let path of paths) {\nif (!TemplateRender.hasEngine(path)) {\n+ count++;\nlet pass = new TemplatePassthrough(path, this.outputDir);\ntry {\nawait pass.write();\n@@ -213,6 +218,9 @@ TemplateWriter.prototype._copyPassthroughs = async function(paths) {\n}\n}\n}\n+\n+ this.copyCount += count;\n+ debug(`TemplatePassthrough copied ${count} file${count !== 1 ? \"s\" : \"\"}.`);\n};\nTemplateWriter.prototype._createTemplateMap = async function(paths) {\n@@ -235,7 +243,7 @@ TemplateWriter.prototype._writeTemplate = async function(mapEntry) {\nlet tmpl = mapEntry.template;\ntry {\n- await tmpl.writeWithData(outputPath, data);\n+ await tmpl.write(outputPath, data);\n} catch (e) {\nthrow EleventyError.make(\nnew Error(`Having trouble writing template: ${outputPath}`),\n@@ -270,6 +278,10 @@ TemplateWriter.prototype.setVerboseOutput = function(isVerbose) {\nthis.isVerbose = isVerbose;\n};\n+TemplateWriter.prototype.getCopyCount = function() {\n+ return this.copyCount;\n+};\n+\nTemplateWriter.prototype.getWriteCount = function() {\nreturn this.writeCount;\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds copy count to console log output
699
03.02.2018 00:23:14
21,600
71e0c4ec2098999c3f1a666bbde9acd0bac0b543
Simplifying some of the debug output
[ { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "@@ -18,11 +18,11 @@ TemplateLayout.prototype.init = function() {\n// debug(\"Current layout aliases: %o\", this.aliases);\nif (this.path in this.aliases) {\n- debug(\n- \"Substituting layout: %o maps to %o\",\n- this.path,\n- this.aliases[this.path]\n- );\n+ // debug(\n+ // \"Substituting layout: %o maps to %o\",\n+ // this.path,\n+ // this.aliases[this.path]\n+ // );\nthis.path = this.aliases[this.path];\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePassthrough.js", "new_path": "src/TemplatePassthrough.js", "diff": "@@ -13,11 +13,11 @@ class TemplatePassthrough {\n}\nasync write() {\n- debug(\n- `${this.path} has no TemplateEngine engine and will copy to ${\n- this.outputDir\n- }`\n- );\n+ // debug(\n+ // `${this.path} has no TemplateEngine engine and will copy to ${\n+ // this.outputDir\n+ // }`\n+ // );\nreturn fs.copy(this.path, this.getOutputPath());\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Simplifying some of the debug output
699
03.02.2018 00:23:49
21,600
5f8b934b3622d9a0a850716c74724bf0d237b5c9
Markdown support for `strikethrough`, notably this switches away from the super strict commonmark parsing mode
[ { "change_type": "MODIFY", "old_path": "src/Engines/Markdown.js", "new_path": "src/Engines/Markdown.js", "diff": "-const mdlib = require(\"markdown-it\")(\"commonmark\");\n+const mdlib = require(\"markdown-it\")({\n+ html: true,\n+ langPrefix: \"language-\"\n+});\nconst TemplateEngine = require(\"./TemplateEngine\");\nconst debug = require(\"debug\")(\"Eleventy:Markdown\");\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderMarkdownTest.js", "new_path": "test/TemplateRenderMarkdownTest.js", "diff": "@@ -74,3 +74,13 @@ test(\"Markdown Render: Pass in an override (liquid)\", async t => {\nt.is((await fn({ title: \"My Title\" })).trim(), \"<h1>My Title</h1>\");\n});\n+\n+test(\"Markdown Render: Strikethrough\", async t => {\n+ let fn = await new TemplateRender(\"md\").getCompiledTemplate(\"~~No~~\");\n+ t.is((await fn()).trim(), \"<p><s>No</s></p>\");\n+});\n+\n+test(\"Markdown Render: Strikethrough in a Header\", async t => {\n+ let fn = await new TemplateRender(\"md\").getCompiledTemplate(\"# ~~No~~\");\n+ t.is((await fn()).trim(), \"<h1><s>No</s></h1>\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Markdown support for `strikethrough`, notably this switches away from the super strict commonmark parsing mode
699
03.02.2018 13:17:12
21,600
e5a159a3306c57125a4acdf1d5cf9d8dfd52341e
Adds `time-require` for perf debugging
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "#!/usr/bin/env node\n+if (process.env.DEBUG) {\n+ require(\"time-require\");\n+}\n+\nconst argv = require(\"minimist\")(process.argv.slice(2));\nconst EleventyNodeVersionCheck = require(\"./src/VersionCheck\");\nconst debug = require(\"debug\")(\"Eleventy-CLI\");\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"pretty\": \"^2.0.0\",\n\"pug\": \"^2.0.0-rc.4\",\n\"slugify\": \"^1.2.7\",\n+ \"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `time-require` for perf debugging
699
03.02.2018 13:23:38
21,600
70a4d0c6c36965c4134a87ec4817f8e452561932
Adds `addPassthroughCopy` option to Config API to allow devs to copy directories to the output automatically.
[ { "change_type": "MODIFY", "old_path": "src/EleventyConfig.js", "new_path": "src/EleventyConfig.js", "diff": "@@ -15,6 +15,7 @@ class EleventyConfig {\nthis.nunjucksFilters = {};\nthis.nunjucksAsyncFilters = {};\nthis.handlebarsHelpers = {};\n+ this.passthroughCopies = {};\nthis.layoutAliases = {};\n@@ -149,7 +150,8 @@ class EleventyConfig {\nnunjucksAsyncFilters: this.nunjucksAsyncFilters,\nhandlebarsHelpers: this.handlebarsHelpers,\nfilters: this.filters,\n- layoutAliases: this.layoutAliases\n+ layoutAliases: this.layoutAliases,\n+ passthroughCopies: this.passthroughCopies\n};\n}\n@@ -162,6 +164,10 @@ class EleventyConfig {\npluginCallback(this);\n}\n+\n+ addPassthroughCopy(fileOrDir) {\n+ this.passthroughCopies[fileOrDir] = true;\n+ }\n}\nlet config = new EleventyConfig();\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -276,7 +276,7 @@ class Template {\nif (!this.initialLayout) {\nthis.initialLayout = tmplData[tmpl.config.keys.layout];\ndebugDev(\n- \"No layout cached, saving layout: %o for %o\",\n+ \"No layout name saved, saving: %o for %o\",\nthis.initialLayout,\nthis.inputPath\n);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -3,6 +3,7 @@ const Template = require(\"./Template\");\nconst TemplateCollection = require(\"./TemplateCollection\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateMap\");\n+const debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateMap\");\nclass TemplateMap {\nconstructor() {\n@@ -50,14 +51,14 @@ class TemplateMap {\nmap.template\n);\n}\n- debug(\"Added this.map[...].data.collections\");\n+ debugDev(\"Added this.map[...].data.collections\");\nfor (let map of this.map) {\nmap.template.setWrapWithLayouts(false);\nmap.templateContent = await map.template.getFinalContent(map.data);\nmap.template.setWrapWithLayouts(true);\n}\n- debug(\"Added this.map[...].templateContent\");\n+ debugDev(\"Added this.map[...].templateContent\");\n}\nasync createTemplateMapCopy(filteredMap) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -13,6 +13,7 @@ const pkg = require(\"../package.json\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateWriter\");\n+const debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateWriter\");\nfunction TemplateWriter(inputPath, outputDir, extensions, templateData) {\nthis.config = config.getConfig();\n@@ -196,6 +197,16 @@ TemplateWriter.prototype._getTemplate = function(path) {\nreturn tmpl;\n};\n+TemplateWriter.prototype._copyPass = async function(path) {\n+ let pass = new TemplatePassthrough(path, this.outputDir);\n+ try {\n+ await pass.write();\n+ debugDev(\"Copied %o\", path);\n+ } catch (e) {\n+ throw EleventyError.make(new Error(`Having trouble copying: ${path}`), e);\n+ }\n+};\n+\nTemplateWriter.prototype._copyPassthroughs = async function(paths) {\nif (!this.config.passthroughFileCopy) {\ndebug(\"`passthroughFileCopy` is disabled in config, bypassing.\");\n@@ -203,24 +214,22 @@ TemplateWriter.prototype._copyPassthroughs = async function(paths) {\n}\nlet count = 0;\n+\ndebug(\"TemplatePassthrough copy started.\");\n+ for (let cfgPath in this.config.passthroughCopies) {\n+ count++;\n+ this._copyPass(cfgPath);\n+ }\n+\nfor (let path of paths) {\nif (!TemplateRender.hasEngine(path)) {\ncount++;\n- let pass = new TemplatePassthrough(path, this.outputDir);\n- try {\n- await pass.write();\n- } catch (e) {\n- throw EleventyError.make(\n- new Error(`Having trouble copying: ${path}`),\n- e\n- );\n- }\n+ this._copyPass(path);\n}\n}\nthis.copyCount += count;\n- debug(`TemplatePassthrough copied ${count} file${count !== 1 ? \"s\" : \"\"}.`);\n+ debug(`TemplatePassthrough copied ${count} item${count !== 1 ? \"s\" : \"\"}.`);\n};\nTemplateWriter.prototype._createTemplateMap = async function(paths) {\n@@ -234,6 +243,7 @@ TemplateWriter.prototype._createTemplateMap = async function(paths) {\n}\nawait this.templateMap.cache();\n+ debugDev(`TemplateMap cache complete.`);\nreturn this.templateMap;\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `addPassthroughCopy` option to Config API to allow devs to copy directories to the output automatically.
699
03.02.2018 13:58:47
21,600
86ba494e041f839759474980e876798e94ef630a
Ignore `node_modules` by default ONLY IF `.gitignore` does not exist. Fixes
[ { "change_type": "MODIFY", "old_path": "src/TemplateWriter.js", "new_path": "src/TemplateWriter.js", "diff": "@@ -91,14 +91,17 @@ TemplateWriter.prototype.getFiles = function() {\nreturn this.files;\n};\n-TemplateWriter.getFileIgnores = function(ignoreFile) {\n+TemplateWriter.getFileIgnores = function(\n+ ignoreFile,\n+ defaultIfFileDoesNotExist\n+) {\nlet dir = parsePath(ignoreFile).dir || \".\";\nlet ignorePath = TemplatePath.normalize(ignoreFile);\nlet ignoreContent;\ntry {\nignoreContent = fs.readFileSync(ignorePath, \"utf-8\");\n} catch (e) {\n- ignoreContent = \"\";\n+ ignoreContent = defaultIfFileDoesNotExist || \"\";\n}\nlet ignores = [];\n@@ -132,10 +135,13 @@ TemplateWriter.getFileIgnores = function(ignoreFile) {\n};\nTemplateWriter.prototype.addIgnores = function(inputDir, files) {\n+ files = files.concat(\n+ TemplateWriter.getFileIgnores(\".gitignore\", \"node_modules/\")\n+ );\n+\nfiles = files.concat(\nTemplateWriter.getFileIgnores(inputDir + \"/.eleventyignore\")\n);\n- files = files.concat(TemplateWriter.getFileIgnores(\".gitignore\"));\nfiles = files.concat(TemplateGlob.map(\"!\" + this.outputDir + \"/**\"));\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -71,6 +71,15 @@ test(\".eleventyignore parsing\", t => {\nt.is(ignores[1], \"!./test/stubs/ignoredFolder/ignored.md\");\n});\n+test(\"defaults if .gitignore does not exist\", t => {\n+ let ignores = new TemplateWriter.getFileIgnores(\n+ \".thisfiledoesnotexist\",\n+ \"node_modules/\"\n+ );\n+ t.truthy(ignores.length);\n+ t.is(ignores[0], \"!./node_modules/**\");\n+});\n+\ntest(\".eleventyignore files\", async t => {\nlet tw = new TemplateWriter(\"test/stubs\", \"test/stubs/_site\", [\"ejs\", \"md\"]);\nlet ignoredFiles = await globby(\"test/stubs/ignoredFolder/*.md\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Ignore `node_modules` by default ONLY IF `.gitignore` does not exist. Fixes #54
699
03.02.2018 22:09:58
21,600
57ea109c15070294a62adf042eb18354ba7cd656
clear template cache on rewatch
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -3,6 +3,7 @@ const chalk = require(\"chalk\");\nconst parsePath = require(\"parse-filepath\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateWriter = require(\"./TemplateWriter\");\n+const templateCache = require(\"./TemplateCache\");\nconst EleventyError = require(\"./EleventyError\");\nconst simplePlural = require(\"./Util/Pluralize\");\nconst config = require(\"./Config\");\n@@ -59,6 +60,7 @@ Eleventy.prototype.restart = function() {\ndebug(\"Restarting\");\nthis.start = new Date();\nthis.writer.restart();\n+ templateCache.clear();\n};\nEleventy.prototype.finish = function() {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -71,7 +71,7 @@ test(\".eleventyignore parsing\", t => {\nt.is(ignores[1], \"!./test/stubs/ignoredFolder/ignored.md\");\n});\n-test(\"defaults if .gitignore does not exist\", t => {\n+test(\"defaults if passed file name does not exist\", t => {\nlet ignores = new TemplateWriter.getFileIgnores(\n\".thisfiledoesnotexist\",\n\"node_modules/\"\n" } ]
JavaScript
MIT License
11ty/eleventy
clear template cache on rewatch
699
03.02.2018 22:45:20
21,600
8b9bb7eb820b182b48598344abc152a9c16a2150
Adds `getFilteredByGlob` to collection API. Accepts either a glob string or array of glob strings.
[ { "change_type": "MODIFY", "old_path": "docs/collections.md", "new_path": "docs/collections.md", "diff": "@@ -195,6 +195,16 @@ eleventyConfig.addCollection(\"onlyMarkdown\", function(collection) {\n});\n});\n+// Filter source file names using a glob (new in Eleventy v0.2.14)\n+eleventyConfig.addCollection(\"onlyMarkdown\", function(collection) {\n+ return collection.getFilteredByGlob(\"**/*.md\");\n+});\n+\n+// Filter source file names using a glob (new in Eleventy v0.2.14)\n+eleventyConfig.addCollection(\"posts\", function(collection) {\n+ return collection.getFilteredByGlob(\"_posts/*.md\");\n+});\n+\n// Sort with `Array.sort`\neleventyConfig.addCollection(\"myCustomSort\", function(collection) {\nreturn collection.getAll().sort(function(a, b) {\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"luxon\": \"^0.2.12\",\n\"markdown-it\": \"^8.4.0\",\n\"minimist\": \"^1.2.0\",\n+ \"multimatch\": \"^2.1.0\",\n\"mustache\": \"^2.3.0\",\n\"normalize-path\": \"^2.1.1\",\n\"nunjucks\": \"^3.0.1\",\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "+const multimatch = require(\"multimatch\");\nconst Sortable = require(\"./Util/Sortable\");\n+const TemplatePath = require(\"./TemplatePath\");\nclass TemplateCollection extends Sortable {\nconstructor() {\nsuper();\n}\n+ // right now this is only used by the tests\nasync addTemplate(template) {\nlet templateMap = await template.getMapped();\nsuper.add(templateMap);\n@@ -18,6 +21,26 @@ class TemplateCollection extends Sortable {\nreturn this.sort(Sortable.sortFunctionDateInputPath);\n}\n+ getSortedByDate() {\n+ return this.sort(Sortable.sortFunctionDate);\n+ }\n+\n+ getFilteredByGlob(globs) {\n+ if (typeof globs === \"string\") {\n+ globs = [globs];\n+ }\n+\n+ globs = globs.map(glob => TemplatePath.addLeadingDotSlash(glob));\n+\n+ return this.getAllSorted().filter(item => {\n+ if (multimatch([item.inputPath], globs).length) {\n+ return true;\n+ }\n+\n+ return false;\n+ });\n+ }\n+\ngetFilteredByTag(tagName) {\nreturn this.getAllSorted().filter(function(item) {\nif (!tagName) {\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Sortable.js", "new_path": "src/Util/Sortable.js", "diff": "@@ -94,8 +94,18 @@ class Sortable {\nreturn Sortable.sortFunctionAscending(b, a);\n}\n+ static sortFunctionDate(mapA, mapB) {\n+ return Sortable.sortFunctionNumericAscending(\n+ mapA.date.getTime(),\n+ mapB.date.getTime()\n+ );\n+ }\n+\nstatic sortFunctionDateInputPath(mapA, mapB) {\n- let sortDate = Sortable.sortFunctionNumericAscending(mapA.date, mapB.date);\n+ let sortDate = Sortable.sortFunctionNumericAscending(\n+ mapA.date.getTime(),\n+ mapB.date.getTime()\n+ );\nif (sortDate === 0) {\nreturn Sortable.sortFunctionAlphabeticAscending(\nmapA.inputPath,\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateCollectionTest.js", "new_path": "test/TemplateCollectionTest.js", "diff": "@@ -28,6 +28,16 @@ let tmpl5 = new Template(\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\n+let tmpl6 = new Template(\n+ \"./test/stubs/collection/test6.html\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+);\n+let tmpl7 = new Template(\n+ \"./test/stubs/collection/test7.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+);\ntest(\"Basic setup\", async t => {\nlet c = new Collection();\n@@ -91,3 +101,30 @@ test(\"getFilteredByTag (added out of order, sorted)\", async t => {\nt.truthy(dogs.length);\nt.deepEqual(dogs[0].template, tmpl1);\n});\n+\n+test(\"getFilteredByGlob\", async t => {\n+ let c = new Collection();\n+ await c.addTemplate(tmpl1);\n+ await c.addTemplate(tmpl6);\n+ await c.addTemplate(tmpl7);\n+\n+ let markdowns = c.getFilteredByGlob(\"./**/*.md\");\n+ t.is(markdowns.length, 1);\n+ t.deepEqual(markdowns[0].template, tmpl1);\n+});\n+\n+test(\"getFilteredByGlob no dash dot\", async t => {\n+ let c = new Collection();\n+ await c.addTemplate(tmpl1);\n+ await c.addTemplate(tmpl6);\n+ await c.addTemplate(tmpl7);\n+\n+ let markdowns = c.getFilteredByGlob(\"**/*.md\");\n+ t.is(markdowns.length, 1);\n+ t.deepEqual(markdowns[0].template, tmpl1);\n+\n+ let htmls = c.getFilteredByGlob(\"**/*.{html,njk}\");\n+ t.is(htmls.length, 2);\n+ t.deepEqual(htmls[0].template, tmpl6);\n+ t.deepEqual(htmls[1].template, tmpl7);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/collection/test6.html", "diff": "+# Test 6\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/collection/test7.njk", "diff": "+# Test 7\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `getFilteredByGlob` to collection API. Accepts either a glob string or array of glob strings.