Merge pull request #42 from stanlemon/date-categories-tags

Add time to post date, add categories & tags
This commit is contained in:
Will Boyd
2020-12-22 10:17:34 -05:00
committed by GitHub
2 changed files with 25 additions and 4 deletions
+21 -2
View File
@@ -48,7 +48,9 @@ function collectPosts(data, config) {
},
frontmatter: {
title: getPostTitle(post),
date: getPostDate(post)
date: getPostDate(post),
categories: getCategories(post),
tags: getTags(post),
},
content: translator.getPostContent(post, turndownService, config)
}));
@@ -80,7 +82,24 @@ function getPostTitle(post) {
}
function getPostDate(post) {
return luxon.DateTime.fromRFC2822(post.pubDate[0], { zone: 'utc' }).toISODate();
return luxon.DateTime.fromRFC2822(post.pubDate[0], { zone: 'utc' }).toISO();
}
function getCategories(post) {
return processCategoryTags(post, "category");
}
function getTags(post) {
return processCategoryTags(post, "post_tag");
}
function processCategoryTags(post, domain) {
if (!post.category) {
return [];
}
return post.category
.filter(c => c["$"].domain === domain)
.map(({ $: c }) => c.nicename);
}
function collectAttachedImages(data) {