wonderfulfrog.com/config/collections/index.js
2024-02-17 00:10:43 -08:00

18 lines
323 B
JavaScript

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;
};
module.exports = {
postsByTag,
};