Skip to content

Commit

Permalink
Merge pull request #241 from cagov/fix-readability
Browse files Browse the repository at this point in the history
Change how we make allFiles.json
  • Loading branch information
xjensen authored Dec 29, 2023
2 parents 26072b6 + 1c3e9da commit 81746eb
Show file tree
Hide file tree
Showing 6 changed files with 2,263 additions and 2,140 deletions.
26 changes: 13 additions & 13 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ module.exports = function (eleventyConfig) {
return `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`;
});

let fileList = [];

//Process wordpress posts
eleventyConfig.addCollection("wordpressposts", function (collection) {
const FolderNamePosts = "wordpress-posts";
Expand Down Expand Up @@ -167,19 +165,8 @@ module.exports = function (eleventyConfig) {
}
}

let newFile = {};
newFile.outputPath = item.outputPath;
newFile.inputPath = item.inputPath;
fileList.push(newFile);

});

// /blog/index.html is a generated page, remove it from the list
let abbrevFileList = fileList.filter(item => { return item.outputPath != "_site/blog/index.html";})

// store file list in build gen files directory
fs.writeFileSync('./_site_dist/allFiles.json',JSON.stringify(abbrevFileList),'utf8');

return output;
});

Expand Down Expand Up @@ -254,6 +241,19 @@ module.exports = function (eleventyConfig) {
}
});

eleventyConfig.on("eleventy.after", async ({ results }) => {
// Generate map of all HTML files for tests.
const files = results.map((r) => {
const { content, ...paths } = r;
return paths;
});

const htmlFiles = files.filter((p) => p?.outputPath?.endsWith(".html"));
const htmlFileJson = JSON.stringify(htmlFiles, null, 2);

fs.writeFileSync("./_site_dist/allFiles.json", htmlFileJson, "utf8");
});

return {
htmlTemplateEngine: "njk",
markdownTemplateEngine: "md",
Expand Down
Loading

0 comments on commit 81746eb

Please sign in to comment.