reinstate allPosts, as it is needed for OG images

This commit is contained in:
madrilene 2025-01-23 07:21:28 +01:00
parent b120a88cad
commit 37cdc1915b
4 changed files with 10 additions and 4 deletions

View file

@ -18,7 +18,7 @@ dotenv.config();
import yaml from 'js-yaml';
// config import
import {showInSitemap, tagList} from './src/_config/collections.js';
import {getAllPosts, showInSitemap, tagList} from './src/_config/collections.js';
import events from './src/_config/events.js';
import filters from './src/_config/filters.js';
import plugins from './src/_config/plugins.js';
@ -35,6 +35,7 @@ export default async function (eleventyConfig) {
eleventyConfig.addLayoutAlias('tags', 'tags.njk');
// --------------------- Collections
eleventyConfig.addCollection('allPosts', getAllPosts);
eleventyConfig.addCollection('showInSitemap', showInSitemap);
eleventyConfig.addCollection('tagList', tagList);

View file

@ -1,4 +1,9 @@
/** All markdown files as a collection for sitemap.xml */
/** All blog posts as a collection. */
export const getAllPosts = collection => {
return collection.getFilteredByGlob('./src/posts/**/*.md').reverse();
};
/** All relevant pages as a collection for sitemap.xml */
export const showInSitemap = collection => {
return collection.getFilteredByGlob('./src/**/*.{md,njk}');
};

View file

@ -5,7 +5,7 @@ background: '#FBBE25'
text: '#161616'
siteUrl: 'eleventy-excellent.netlify.app'
pagination:
data: collections.posts
data: collections.allPosts
size: 1
alias: post
permalink: '/assets/og-images/{{ post.data.title | slugify }}-preview.svg'

View file

@ -3,7 +3,7 @@ layout: base
title: Blog
description: 'All blog posts can be found here'
pagination:
data: collections.posts
data: collections.allPosts
size: 8
permalink: 'blog/{% if pagination.pageNumber >=1 %}page-{{ pagination.pageNumber + 1 }}/{% endif %}index.html'
---