From 2d16c3df0518a1fec11e5b2b81f2bc9d9e53c33a Mon Sep 17 00:00:00 2001 From: Ben Ledbury Date: Wed, 9 Feb 2022 11:13:50 +0000 Subject: [PATCH] Allow inclusion of markdown from files --- app/lib/gruntConfig.js | 2 ++ app/lib/loadYaml.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/lib/gruntConfig.js b/app/lib/gruntConfig.js index 5385a5d6..9ea62422 100644 --- a/app/lib/gruntConfig.js +++ b/app/lib/gruntConfig.js @@ -189,6 +189,8 @@ module.exports = function(grunt, options, spec) { templates: { files: [ options.specFile, + path.dirname(options.specFile) + '/**/*.md', + options.appDir + '/views/**/*.hbs', options.appDir + '/views/**/*.hbs', options.appDir + '/helpers/**/*.js', options.appDir + '/lib/**/*.js' diff --git a/app/lib/loadYaml.js b/app/lib/loadYaml.js index 3bae679e..10b84d7c 100644 --- a/app/lib/loadYaml.js +++ b/app/lib/loadYaml.js @@ -1,7 +1,14 @@ const fs = require('fs') -const yaml = require('js-yaml') +const p = require('path'); +const yaml = require('js-yaml'); + module.exports = function (path) { + const extendedSchema = yaml.DEFAULT_SCHEMA.extend({ + explicit: [ + new yaml.Type('!file', { kind: 'scalar', construct: function (relPath) { console.log(relPath); return fs.readFileSync(p.join(p.dirname(path), relPath), "utf8") }}) + ] + }); const fileContent = fs.readFileSync(path, "utf8") - return yaml.load(fileContent) + return yaml.load(fileContent, { schema: extendedSchema, filename: path }) } \ No newline at end of file