Open spekulatius opened 2 years ago
@spekulatius,
I'm not sure I understood your requirement, but you can combine content from multiple folders like this:
module.exports = (coll) => {
const posts = [...coll.getFilteredByGlob('./posts/*.md', './myfolder/*.md', './anotherfolder/*.md')];
return posts.reverse();
};
@spekulatius,
Otherwise you can try something like this:
function fromEntries (iterable) {
return [...iterable].reduce((obj, [key, val]) => {
obj[key] = val;
return obj;
}, {});
}
module.exports = (coll) => {
const posts = require('./posts')(coll);
const events = require('./events')(coll);
const postsAndEvents = posts.concat(events);
const tagListArr = postsAndEvents
.reduce((tags, post) => {
if ('tags' in post.data) {
tags = tags.concat(post.data.tags);
}
return [...new Set(tags)];
}, [])
.map((tag) => ([
tag,
coll.getFilteredByTag(tag).length
]))
.sort((a, b) => b[1] - a[1]);
return fromEntries(tagListArr);
};
Hello @dafiulh,
Cool template, thank you for building it!
I've got a number of folders with pages and each page with it's own tags. I was wondering if you know: how I can get tags from non-
posts/
pages working easily?Cheers!