Fix: sitemap adds css/js files

This commit is contained in:
madrilene 2023-09-11 14:57:53 +02:00
parent 379c7936ed
commit ab9df8fa77
3 changed files with 12 additions and 4 deletions

View file

@ -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);

View file

@ -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
};

View file

@ -5,7 +5,7 @@ excludeFromSitemap: true
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% 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 %}