From ab9df8fa777450a8a6b57f3729eed3270343a6a5 Mon Sep 17 00:00:00 2001 From: madrilene Date: Mon, 11 Sep 2023 14:57:53 +0200 Subject: [PATCH] Fix: sitemap adds css/js files --- .eleventy.js | 2 ++ config/collections/index.js | 12 +++++++++--- src/assets/helperfiles/sitemap.njk | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 67ea7ca..8818cad 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -40,6 +40,7 @@ const { // module import collections const {getAllPosts} = require('./config/collections/index.js'); +const {onlyMarkdown} = require('./config/collections/index.js'); // module import events const {svgToJpeg} = require('./config/events/index.js'); @@ -102,6 +103,7 @@ module.exports = eleventyConfig => { // --------------------- Custom collections ----------------------- eleventyConfig.addCollection('posts', getAllPosts); + eleventyConfig.addCollection('onlyMarkdown', onlyMarkdown); // --------------------- Events --------------------- eleventyConfig.on('afterBuild', svgToJpeg); diff --git a/config/collections/index.js b/config/collections/index.js index 0db5bc4..8e6fd21 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -1,9 +1,15 @@ -/** Returns all blog posts as a collection. */ +/** All blog posts as a collection. */ const getAllPosts = collection => { const projects = collection.getFilteredByGlob('./src/posts/*.md'); return projects.reverse(); }; -module.exports = { - getAllPosts +/** All markdown files as a collection for sitemap.xml */ +const onlyMarkdown = collection => { + return collection.getFilteredByGlob('./src/**/*.md'); +}; + +module.exports = { + getAllPosts, + onlyMarkdown }; diff --git a/src/assets/helperfiles/sitemap.njk b/src/assets/helperfiles/sitemap.njk index 94d2acb..bd0c9ff 100644 --- a/src/assets/helperfiles/sitemap.njk +++ b/src/assets/helperfiles/sitemap.njk @@ -5,7 +5,7 @@ excludeFromSitemap: true --- - {% for page in collections.all %} + {% for page in collections.onlyMarkdown %} {% if page.url and page.data.excludeFromSitemap != true %} {% if page.data.lastUpdated %}{% set lastmod = page.data.lastUpdated %}