unpack-whenwe-json.js - tweak to serialise lists of things as JSON
Which should work in YAML
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
/*
|
||||||
|
Reads in the Drupal node dump of WhenWe data from ./whenwe.json
|
||||||
|
Writes it converted to markdown with frontmatter, organised in subdirectories, in out/
|
||||||
|
*/
|
||||||
const data = require('./whenwe.json');
|
const data = require('./whenwe.json');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
@@ -8,7 +12,7 @@ const nhm = new NodeHtmlMarkdown({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function toYaml(data, body) {
|
function toYaml(data, body) {
|
||||||
const frontmatter = Object.keys(data).sort().map(key => key+': '+(data[key] ? '"'+data[key]+'"' : '')).join("\n");
|
const frontmatter = Object.keys(data).sort().map(key => key+': '+(data[key] ? JSON.stringify(data[key]) : '')).join("\n");
|
||||||
return "---\n" + frontmatter + "\n---\n" + nhm.translate(body);
|
return "---\n" + frontmatter + "\n---\n" + nhm.translate(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user