From 9b5b23047ee23551ce1dfc40640d378b0ecf51e9 Mon Sep 17 00:00:00 2001 From: Jon Jensen Date: Tue, 9 Jan 2024 10:45:50 -0800 Subject: [PATCH] Add eleventyNavigation --- .eleventy.js | 5 +-- package-lock.json | 13 +++++++ package.json | 1 + pages/_data/fileids.js | 16 --------- pages/_includes/breadcrumb.njk | 17 +++++++++ pages/_includes/content.njk | 13 ++----- pages/_includes/single-column-conditional.njk | 13 ++----- pages/_includes/single-column.njk | 13 ++----- .../wordpress-pages.11tydata.js | 35 +++++++++++-------- 9 files changed, 60 insertions(+), 66 deletions(-) delete mode 100644 pages/_data/fileids.js create mode 100644 pages/_includes/breadcrumb.njk diff --git a/.eleventy.js b/.eleventy.js index c3f1e0ec..056a7c35 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,12 +1,15 @@ const cagovBuildSystem = require("@cagov/11ty-build-system"); const linkedom = require("linkedom"); const pluginRss = require("@11ty/eleventy-plugin-rss"); +const eleventyNavigationPlugin = require("@11ty/eleventy-navigation"); const fs = require('fs'); module.exports = function (eleventyConfig) { eleventyConfig.htmlTemplateEngine = "njk"; const wordpressImagePath = "img/wordpress"; + eleventyConfig.addPlugin(pluginRss); + eleventyConfig.addPlugin(eleventyNavigationPlugin); eleventyConfig.addPlugin(cagovBuildSystem, { processors: { sass: { @@ -65,8 +68,6 @@ module.exports = function (eleventyConfig) { .reverse(); }); - eleventyConfig.addPlugin(pluginRss); - eleventyConfig.addFilter("dateformat", function (dateString) { const d = new Date(dateString); return `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`; diff --git a/package-lock.json b/package-lock.json index 43a0fd51..fc578e5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@11ty/eleventy": "^2.0.1", + "@11ty/eleventy-navigation": "^0.3.5", "@11ty/eleventy-plugin-rss": "^1.1.2", "@cagov/11ty-build-system": "^1.0.0-beta.3", "@cagov/ds-accordion": "^2.0.0", @@ -173,6 +174,18 @@ } } }, + "node_modules/@11ty/eleventy-navigation": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@11ty/eleventy-navigation/-/eleventy-navigation-0.3.5.tgz", + "integrity": "sha512-4aKW5aIQDFed8xs1G1pWcEiFPcDSwZtA4IH1eERtoJ+Xy+/fsoe0pzbDmw84bHZ9ACny5jblENhfZhcCxklqQw==", + "dependencies": { + "dependency-graph": "^0.11.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } + }, "node_modules/@11ty/eleventy-plugin-rss": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-1.1.2.tgz", diff --git a/package.json b/package.json index 99fc7319..08bcf3e2 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@11ty/eleventy": "^2.0.1", + "@11ty/eleventy-navigation": "^0.3.5", "@11ty/eleventy-plugin-rss": "^1.1.2", "@cagov/11ty-build-system": "^1.0.0-beta.3", "@cagov/ds-accordion": "^2.0.0", diff --git a/pages/_data/fileids.js b/pages/_data/fileids.js deleted file mode 100644 index f7504a26..00000000 --- a/pages/_data/fileids.js +++ /dev/null @@ -1,16 +0,0 @@ -const fs = require("fs"); - -module.exports = function () { - return new Promise((resolve, reject) => { - let idObject = {}; - fs.readdir("./pages/wordpress-pages/", (err, files) => { - files.forEach((file) => { - if (file.indexOf(".json") > -1) { - let fileData = JSON.parse(fs.readFileSync("./pages/wordpress-pages/" + file, "utf8")); - idObject[fileData.data.id] = fileData.data.title - } - }); - resolve(idObject); - }); - }); -}; \ No newline at end of file diff --git a/pages/_includes/breadcrumb.njk b/pages/_includes/breadcrumb.njk new file mode 100644 index 00000000..7d7b29ae --- /dev/null +++ b/pages/_includes/breadcrumb.njk @@ -0,0 +1,17 @@ +{% macro breadcrumb(articleId, articleTitle, collections) %} + +{% endmacro %} \ No newline at end of file diff --git a/pages/_includes/content.njk b/pages/_includes/content.njk index 6a961fc0..bec7ccc3 100644 --- a/pages/_includes/content.njk +++ b/pages/_includes/content.njk @@ -1,19 +1,10 @@ {% extends "base-layout.njk" %} +{% from "breadcrumb.njk" import breadcrumb %} {% block content %}
- + {{ breadcrumb(id, title, collections) }}