Implement image galleries
This commit is contained in:
@ -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,
|
||||
);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user