From 88525aa3e5408587bb364dc11399c990458e237a Mon Sep 17 00:00:00 2001 From: Mathias Schopmans Date: Thu, 6 Apr 2017 17:25:03 +0200 Subject: [PATCH] Fixes #5 - Support target blank for external links in markdown articles --- common/radar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/radar.js b/common/radar.js index bb3465a..f03c1c5 100644 --- a/common/radar.js +++ b/common/radar.js @@ -47,12 +47,17 @@ const createRevisionsFromFiles = (fileNames) => ( const fm = frontmatter(data); // prepend subfolder to links 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); resolve({ ...itemInfoFromFilename(fileName), ...fm.attributes, fileName, - body: marked(fm.body), + body: html }); } });