From fec73bdbd728fa5e71be0922ca44639e1739c58f Mon Sep 17 00:00:00 2001 From: NicolasRoehm Date: Wed, 27 Jan 2021 12:10:45 +0100 Subject: [PATCH 1/2] [Fix] parseMarkdown startDelimiter --- src/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.js b/src/utils.js index 1c11773..5704d2b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -107,19 +107,19 @@ function parseMarkdownWithFrontMatter(string) { let frontMatterTypes = [ { type: 'yaml', - startDelimiter: '---\n', + startDelimiter: '---', endDelimiter: '\n---', parse: (string) => yaml.safeLoad(string, {schema: yaml.JSON_SCHEMA}) }, { type: 'toml', - startDelimiter: '+++\n', + startDelimiter: '+++', endDelimiter: '\n+++', parse: (string) => toml.parse(string) }, { type: 'json', - startDelimiter: '{\n', + startDelimiter: '{', endDelimiter: '\n}', parse: (string) => JSON.parse(string) } From 49108eafea15febe44a4fe57f599d30f0d093bde Mon Sep 17 00:00:00 2001 From: Nicolas Roehm Date: Fri, 21 May 2021 15:58:00 +0200 Subject: [PATCH 2/2] [Fix] windows end of line & path separator --- src/unibit.js | 4 ++-- src/utils.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/unibit.js b/src/unibit.js index 81332ab..8a07762 100644 --- a/src/unibit.js +++ b/src/unibit.js @@ -352,9 +352,9 @@ module.exports = class Unibit { const urlPathParts = _.split(urlPath, '/'); return _.filter(context.site.pages, page => { // find all pages that have same prefix as folder path, but not the root page of that folder, e.g.: {urlPath}/index.html - let pageUrl = _.trim(_.get(page, 'url'), '/'); + let pageUrl = _.trim(_.get(page, 'url'), path.sep); pageUrl = prettyUrl(pageUrl); - const pageUrlParts = _.split(pageUrl, '/'); + const pageUrlParts = _.split(pageUrl, path.sep); return pageUrlParts.length > urlPathParts.length && _.isEqual(pageUrlParts.slice(0, urlPathParts.length), urlPathParts); }); } diff --git a/src/utils.js b/src/utils.js index 5704d2b..2d72665 100644 --- a/src/utils.js +++ b/src/utils.js @@ -3,7 +3,7 @@ const path = require('path'); const _ = require('lodash'); const yaml = require('js-yaml'); const toml = require('@iarna/toml'); - +const { EOL } = require('os'); module.exports = { forEachPromise, @@ -107,20 +107,20 @@ function parseMarkdownWithFrontMatter(string) { let frontMatterTypes = [ { type: 'yaml', - startDelimiter: '---', - endDelimiter: '\n---', + startDelimiter: `---${EOL}`, + endDelimiter: `${EOL}---`, parse: (string) => yaml.safeLoad(string, {schema: yaml.JSON_SCHEMA}) }, { type: 'toml', - startDelimiter: '+++', - endDelimiter: '\n+++', + startDelimiter: `+++${EOL}`, + endDelimiter: `${EOL}+++`, parse: (string) => toml.parse(string) }, { type: 'json', - startDelimiter: '{', - endDelimiter: '\n}', + startDelimiter: `{${EOL}`, + endDelimiter: `${EOL}}`, parse: (string) => JSON.parse(string) } ];