Skip to content

Commit

Permalink
Remove redundant promises
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Nov 22, 2020
1 parent 575ee6d commit 93f3621
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/slightly.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ import MarkdownIt from "markdown-it";
};
let matches = md.match(/^(?:---\r?\n\r?(.*)\r?\n\r?---\r?\n\r?)?(.*)/su);
if (!matches)
return Promise.reject(new Error(`Invalid content document: ${mdPath}`));
throw new Error(`Invalid content document: ${mdPath}`);
if (matches[1]) {
let yaml = jsyaml.safeLoad(matches[1]);
for (let key in config) {
Expand All @@ -190,7 +190,7 @@ import MarkdownIt from "markdown-it";
let html = new MarkdownIt({ html: true, typographer: true }).render(matches[2]);
let content = new DOMParser().parseFromString(html, "text/html");
let toc = this.toc(content.body);
return Promise.resolve({ config, content, toc });
return { config, content, toc };
})
.catch(err => console.log(err))
.catch(err => Promise.reject(new Error(`Unable to fetch content: ${mdPath}`)));
Expand Down

0 comments on commit 93f3621

Please sign in to comment.