Implement image galleries

This commit is contained in:
2024-12-02 17:42:20 -06:00
parent 51a1693265
commit 686239ea03
47 changed files with 420 additions and 15 deletions

View File

@ -29,6 +29,24 @@ export default async function (eleventyConfig) {
return newText;
};
// Collections
eleventyConfig.addCollection("galleryImages", (collection) => {
const galleries = collection.getAll()[0].data.galleries;
let galleryImages = [];
galleries.forEach((gallery) => {
gallery.pictures.forEach((picture, i, arr) => {
picture.containingGallery = `${gallery.title}`;
picture.baseUrl = `${gallery.url}`;
i ? (picture.previousImage = arr[i - 1].filename) : null;
i + 1 != arr.length ? (picture.nextImage = arr[i + 1].filename) : null;
galleryImages.push(picture);
});
});
return galleryImages;
});
// Transforms
eleventyConfig.addTransform("prettier", function (content, outputPath) {
if (outputPath && outputPath.endsWith(".html")) {
@ -180,7 +198,7 @@ export default async function (eleventyConfig) {
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
return (tags || []).filter(
(tag) => ["all", "nav", "post", "posts"].indexOf(tag) === -1,
(tag) => ["all", "nav", "post", "posts", "gallery"].indexOf(tag) === -1,
);
});