Add time to post date, add categories & tags

This commit is contained in:
Stan Lemon
2020-06-23 22:25:12 -04:00
parent 4bff3c785c
commit b7aef9302b
+19 -2
View File
@@ -48,7 +48,9 @@ function collectPosts(data, config) {
}, },
frontmatter: { frontmatter: {
title: getPostTitle(post), title: getPostTitle(post),
date: getPostDate(post) date: getPostDate(post),
categories: getCategories(post),
tags: getTags(post),
}, },
content: translator.getPostContent(post, turndownService, config) content: translator.getPostContent(post, turndownService, config)
})); }));
@@ -80,7 +82,22 @@ function getPostTitle(post) {
} }
function getPostDate(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) {
return post.category
.filter(c => c["$"].domain === domain)
.map(({ $: c }) => c.nicename)
.join(", ");
} }
function collectAttachedImages(data) { function collectAttachedImages(data) {