From b7aef9302b4460ad2a5aed47f93c3985f3ca2c4a Mon Sep 17 00:00:00 2001 From: Stan Lemon Date: Tue, 23 Jun 2020 22:25:12 -0400 Subject: [PATCH] Add time to post date, add categories & tags --- src/parser.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/parser.js b/src/parser.js index 56504fb..ae8d152 100644 --- a/src/parser.js +++ b/src/parser.js @@ -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,22 @@ 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) { + return post.category + .filter(c => c["$"].domain === domain) + .map(({ $: c }) => c.nicename) + .join(", "); } function collectAttachedImages(data) {