Fixes #5 - Support target blank for external links in markdown articles

This commit is contained in:
Mathias Schopmans
2017-04-06 17:25:03 +02:00
parent 12294f0daa
commit 88525aa3e5

View File

@@ -47,12 +47,17 @@ const createRevisionsFromFiles = (fileNames) => (
const fm = frontmatter(data); const fm = frontmatter(data);
// prepend subfolder to links // prepend subfolder to links
fm.body = fm.body.replace(/\]\(\//g, '](/techradar/') fm.body = fm.body.replace(/\]\(\//g, '](/techradar/')
// add target attribute to external links
let html = marked(fm.body);
html = html.replace(/a href="http/g, 'a target="_blank" href="http')
checkAttributes(fileName, fm.attributes); checkAttributes(fileName, fm.attributes);
resolve({ resolve({
...itemInfoFromFilename(fileName), ...itemInfoFromFilename(fileName),
...fm.attributes, ...fm.attributes,
fileName, fileName,
body: marked(fm.body), body: html
}); });
} }
}); });