Skip to content

Commit

Permalink
make import scripts more stable
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 69d5a84 commit 48d9499
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ function ensureFolder(dir) {
}
}

function dump(data) {
return safeDump(data, { skipInvalid: true });
}

module.exports = {
name: 'empress-blog:import',
description: 'Imports data from other blog systems',
Expand Down Expand Up @@ -38,7 +42,7 @@ module.exports = {

data.tags.forEach((tag) => {
writeFileSync(`tag/${tag.id}.md`, `---
${safeDump({
${dump({
name: tag.name,
image: '',
})}---
Expand All @@ -51,7 +55,7 @@ ${tag.description}`)

data.authors.forEach((author) => {
writeFileSync(`author/${author.id}.md`, `---
${safeDump({
${dump({
name: author.name,
id: author.id,
image: author.image,
Expand All @@ -70,7 +74,7 @@ ${author.bio}`)

data.content.forEach((content) => {
writeFileSync(`content/${content.id}.md`, `---
${safeDump({
${dump({
title: content.title,
image: content.image,
authors: content.authors,
Expand Down

0 comments on commit 48d9499

Please sign in to comment.