diff --git a/.eleventy.js b/.eleventy.js index 5801bc9..e36af01 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,7 +1,4 @@ -const fs = require("fs"); - const { DateTime } = require("luxon"); -const markdownIt = require("markdown-it"); const markdownItAnchor = require("markdown-it-anchor"); const pluginRss = require("@11ty/eleventy-plugin-rss"); @@ -44,54 +41,35 @@ module.exports = function(eleventyConfig) { return Math.min.apply(null, numbers); }); - function filterTagList(tags) { - return (tags || []).filter(tag => ["all", "nav", "post", "posts"].indexOf(tag) === -1); - } - - eleventyConfig.addFilter("filterTagList", filterTagList) - - // Create an array of all tags - eleventyConfig.addCollection("tagList", function(collection) { + // Return all the tags used in a collection + eleventyConfig.addFilter("getAllTags", collection => { let tagSet = new Set(); - collection.getAll().forEach(item => { + for(let item of collection) { (item.data.tags || []).forEach(tag => tagSet.add(tag)); - }); + } + return Array.from(tagSet); + }); - return filterTagList([...tagSet]); + eleventyConfig.addFilter("filterTagList", function filterTagList(tags) { + return (tags || []).filter(tag => ["all", "nav", "post", "posts"].indexOf(tag) === -1); }); // Customize Markdown library and settings: - let markdownLibrary = markdownIt({ - html: true, - breaks: true, - linkify: true - }).use(markdownItAnchor, { - permalink: markdownItAnchor.permalink.ariaHidden({ - placement: "after", - class: "direct-link", - symbol: "#", - level: [1,2,3,4], - }), - slugify: eleventyConfig.getFilter("slug") + eleventyConfig.amendLibrary("md", mdLib => { + mdLib.use(markdownItAnchor, { + permalink: markdownItAnchor.permalink.ariaHidden({ + placement: "after", + class: "direct-link", + symbol: "#", + level: [1,2,3,4], + }), + slugify: eleventyConfig.getFilter("slug") + }); }); - eleventyConfig.setLibrary("md", markdownLibrary); - // Override Browsersync defaults (used only with --serve) - eleventyConfig.setBrowserSyncConfig({ - callbacks: { - ready: function(err, browserSync) { - const content_404 = fs.readFileSync('_site/404.html'); - - browserSync.addMiddleware("*", (req, res) => { - // Provides the 404 content without redirect. - res.writeHead(404, {"Content-Type": "text/html; charset=UTF-8"}); - res.write(content_404); - res.end(); - }); - }, - }, - ui: false, - ghostMode: false + // Override @11ty/eleventy-dev-server defaults (used only with --serve) + eleventyConfig.setServerOptions({ + showVersion: true, }); return { diff --git a/package.json b/package.json index 8984142..73f19a0 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "bench": "DEBUG=Eleventy:Benchmark* npx @11ty/eleventy", "watch": "npx @11ty/eleventy --watch", "serve": "npx @11ty/eleventy --serve", - "start": "npx @11ty/eleventy --serve", - "debug": "DEBUG=* npx @11ty/eleventy" + "start": "npx @11ty/eleventy --serve --quiet", + "debug": "DEBUG=Eleventy* npx @11ty/eleventy" }, "repository": { "type": "git", @@ -25,12 +25,11 @@ }, "homepage": "https://github.com/11ty/eleventy-base-blog#readme", "dependencies": { - "@11ty/eleventy": "^1.0.1", + "@11ty/eleventy": "^2.0.0-canary.12", "@11ty/eleventy-navigation": "^0.3.3", - "@11ty/eleventy-plugin-rss": "^1.1.2", + "@11ty/eleventy-plugin-rss": "^1.2.0", "@11ty/eleventy-plugin-syntaxhighlight": "^4.0.0", "luxon": "^2.4.0", - "markdown-it": "^13.0.1", "markdown-it-anchor": "^8.6.4" } } diff --git a/tags-list.njk b/tags-list.njk index 2553860..340da11 100644 --- a/tags-list.njk +++ b/tags-list.njk @@ -4,7 +4,7 @@ layout: layouts/home.njk ---