diff --git a/config/collections/index.js b/config/collections/index.js index cbb0a2a..f7fb72f 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -1,20 +1,3 @@ -import dayjs from "dayjs"; - -export const postsByTag = (collection) => { - const posts = collection.getFilteredByTag("post"); - - const postsByTag = {}; - - for (const post of posts) { - for (const tag of post.data.tags) { - postsByTag[tag] ??= []; - postsByTag[tag].push(post); - } - } - - return postsByTag; -}; - export const collectionByTag = (collection, collectionName) => { const items = collection.getFilteredByTag(collectionName); @@ -29,19 +12,3 @@ export const collectionByTag = (collection, collectionName) => { return itemsByTag; }; - -export const catalogueByType = (collection) => { - const allItems = collection.getFilteredByTag("catalogue"); - - const catalogueByType = {}; - - for (const item of allItems) { - const type = item.data.tags[1]; - if (!type) continue; - - catalogueByType[type] ??= []; - catalogueByType[type].push(item); - } - - return catalogueByType; -}; diff --git a/eleventy.config.js b/eleventy.config.js index 6a9e71b..075aa9e 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,7 +1,7 @@ import pluginNoRobots from "eleventy-plugin-no-robots"; import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"; -import { collectionByTag, postsByTag } from "./config/collections/index.js"; +import { collectionByTag } from "./config/collections/index.js"; import filters from "./config/filters/index.js"; import markdown from "./config/plugins/markdown.js"; @@ -17,7 +17,9 @@ export default function (eleventyConfig) { eleventyConfig.addPlugin(pluginNoRobots); // --------------------- Custom Collections ----------------------- - eleventyConfig.addCollection("postsByTag", postsByTag); + eleventyConfig.addCollection("postsByTag", (collection) => + collectionByTag(collection, "post"), + ); eleventyConfig.addCollection("booksByTag", (collection) => collectionByTag(collection, "book"), );