diff --git a/lib/page.js b/lib/page.js index 12771be..d8b6381 100644 --- a/lib/page.js +++ b/lib/page.js @@ -1,5 +1,5 @@ let { repr } = require("faucet-pipeline-core/lib/util"); -let colonParse = require("metacolon"); +let metacolon = import("metacolon"); module.exports = class Page { constructor(slug, sourcePath, children, { language, title, description, meta }, dataPath) { @@ -19,19 +19,21 @@ module.exports = class Page { return Promise.resolve(this); } - let { headers, body } = await colonParse(this.sourcePath); + let { colonParse } = await metacolon; + let { headers, body } = await colonParse(this.sourcePath, { trim: true }); if(this.dataPath) { this.data = require(this.dataPath); } - this.language = headers.language || this.config.language; - this.heading = headers.title; - this.title = [headers.title, this.config.title].filter(x => x).join(" | "); - this.description = headers.description || this.config.description; + let title = headers.get("title"); + this.language = headers.get("language") || this.config.language; + this.heading = title; + this.title = [title, this.config.title].filter(x => x).join(" | "); + this.description = headers.get("description") || this.config.description; this.meta = this.buildMeta(); - this.status = headers.status; - this.version = headers.version; - this.tags = headers.tags; - this.body = body; + this.status = headers.get("status"); + this.version = headers.get("version"); + this.tags = headers.get("tags"); + this.body = body.trim(); return this; } diff --git a/package.json b/package.json index 17ce905..6fa459e 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "faucet-pipeline-sass": "^1.7.0", "faucet-pipeline-static": "^2.0.0", "handlebars": "^4.7.7", - "metacolon": "^1.1.1", + "metacolon": "^2.0.2", "minimist": "^1.2.5", "mkdirp": "^3.0.1", "parse5": "^7.1.2",