Skip to content

Commit

Permalink
feat: Implement tumblr tags & authors import; Nicer URLs (slugs)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bryxí authored and mansona committed Apr 27, 2021
1 parent 48d9499 commit 9564c3a
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions lib/importers/tumblr.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ module.exports = async function tumblrImport(fileContents) {

let channel = data.tumblr.posts[0];

let authors = [];
let tags = [];
let allAuthors = [];
let allTags = [];

let content = _.chain(channel.post)
let allContent = _.chain(channel.post)
.map(post => {
let postType = post.$.type;
let id = post.$.id;
let id = post.$.slug;
let date = new Date(post.$.date);
let author = post.$.tumblelog;
let tag = post.$.type;
let title, content;

switch (postType) {
Expand All @@ -31,19 +32,27 @@ module.exports = async function tumblrImport(fileContents) {
break;
}

if (!authors.find(existingAuthor => existingAuthor.id === author)) {
authors.push({
if (!allAuthors.find(existingAuthor => existingAuthor.id === author)) {
allAuthors.push({
id: author,
name: author
});
}

if (!allTags.find(existingTag => existingTag.id === tag)) {
allTags.push({
id: tag,
name: tag
});
}


let result = {
id,
title,
authors,
authors: [author],
date,
tags,
tags: [tag],
content
};

Expand All @@ -53,8 +62,8 @@ module.exports = async function tumblrImport(fileContents) {
.value();

return {
tags,
authors,
content
tags: allTags,
authors: allAuthors,
content: allContent
};
};

0 comments on commit 9564c3a

Please sign in to comment.