18 lines
323 B
JavaScript
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,
|
|
};
|