From c2cb27d0f0bf642c362b30b050b39fdd1665c358 Mon Sep 17 00:00:00 2001 From: Nick Stokoe Date: Tue, 9 May 2023 12:24:36 +0100 Subject: [PATCH] unpack-whenwe-json.js - tweak to serialise lists of things as JSON Which should work in YAML --- unpack-whenwe-json.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unpack-whenwe-json.js b/unpack-whenwe-json.js index 7992ea1..b1a54ab 100644 --- a/unpack-whenwe-json.js +++ b/unpack-whenwe-json.js @@ -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 fs = require('fs'); const path = require('path'); @@ -8,7 +12,7 @@ const nhm = new NodeHtmlMarkdown({ }); 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); }