mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Fix broken link in markdown compilation (#2162)
* handle links to fleetdm.com * Update build-static-content.js * Update build-static-content.js * update comment
This commit is contained in:
parent
0b7ff6cd38
commit
c1a795cff8
8
website/scripts/build-static-content.js
vendored
8
website/scripts/build-static-content.js
vendored
@ -226,13 +226,19 @@ module.exports = {
|
||||
// to some page on the destination site where this will be hosted, like `(*.)?fleetdm.com`.
|
||||
// If external, add target="_blank" so the link will open in a new tab.
|
||||
let isExternal = ! hrefString.match(/^href=\"https?:\/\/([^\.]+\.)*fleetdm\.com/g);// « FUTURE: make this smarter with sails.config.baseUrl + _.escapeRegExp()
|
||||
// Check if this link is to fleetdm.com or www.fleetdm.com.
|
||||
let isBaseUrl = hrefString.match(/^(href="https?:\/\/)([^\.]+\.)*fleetdm\.com"$/g);
|
||||
if (isExternal) {
|
||||
return hrefString.replace(/(href="https?:\/\/([^"]+)")/g, '$1 target="_blank"');
|
||||
} else {
|
||||
// Otherwise, change the link to be web root relative.
|
||||
// (e.g. 'href="http://sailsjs.com/documentation/concepts"'' becomes simply 'href="/documentation/concepts"'')
|
||||
// > Note: See the Git version history of "compile-markdown-content.js" in the sailsjs.com website repo for examples of ways this can work across versioned subdomains.
|
||||
return hrefString.replace(/href="https?:\/\//, '').replace(/^fleetdm\.com/, 'href="');
|
||||
if (isBaseUrl) {
|
||||
return hrefString.replace(/href="https?:\/\//, '').replace(/([^\.]+\.)*fleetdm\.com/, 'href="/');
|
||||
} else {
|
||||
return hrefString.replace(/href="https?:\/\//, '').replace(/^fleetdm\.com/, 'href="');
|
||||
}
|
||||
}
|
||||
|
||||
});//∞
|
||||
|
Loading…
Reference in New Issue
Block a user