Update posts by tag, fix ul styling
This commit is contained in:
23
src/scripts/getTags.js
Normal file
23
src/scripts/getTags.js
Normal file
@@ -0,0 +1,23 @@
|
||||
export default function getTags(posts) {
|
||||
// Get tags from all posts
|
||||
const allTags = posts
|
||||
.map((post) => {
|
||||
const postTags = post.frontmatter.tags;
|
||||
let allTags = [];
|
||||
|
||||
if (postTags.length > 0) {
|
||||
postTags.forEach((tag) => {
|
||||
if (allTags.indexOf(tag) === -1) {
|
||||
allTags.push(tag);
|
||||
}
|
||||
});
|
||||
}
|
||||
return allTags;
|
||||
})
|
||||
.flat(1);
|
||||
|
||||
// Make the tags unique
|
||||
let tags = [...new Set(allTags)];
|
||||
|
||||
return tags;
|
||||
}
|
||||
Reference in New Issue
Block a user