diff --git a/assets/javascripts/lib/page.coffee b/assets/javascripts/lib/page.coffee index 7a5329f6a8..b8baef0195 100644 --- a/assets/javascripts/lib/page.coffee +++ b/assets/javascripts/lib/page.coffee @@ -179,15 +179,21 @@ onclick = (event) -> link = link.parentNode while link and link.tagName isnt 'A' if link and not link.target and isSameOrigin(link.href) - event.preventDefault() - path = link.pathname + link.search + link.hash - path = path.replace /^\/\/+/, '/' # IE11 bug - page.show(path) + + if link.className.match('_list-item') or not isSameOriginDifferentDoc(link) + event.preventDefault() + path = link.pathname + link.search + link.hash + path = path.replace /^\/\/+/, '/' # IE11 bug + page.show(path) + return isSameOrigin = (url) -> url.indexOf("#{location.protocol}//#{location.hostname}") is 0 +isSameOriginDifferentDoc = (url) -> + url.pathname.split('/')[1] != location.pathname.split('/')[1] + updateCanonicalLink = -> @canonicalLink ||= document.head.querySelector('link[rel="canonical"]') @canonicalLink.setAttribute('href', "https://#{location.host}#{location.pathname}") diff --git a/docs/filter-reference.md b/docs/filter-reference.md index 6c1387710b..bd654f1968 100644 --- a/docs/filter-reference.md +++ b/docs/filter-reference.md @@ -84,6 +84,7 @@ The `call` method must return either `doc` or `html`, depending on the type of f * [`AttributionFilter`](https://github.com/freeCodeCamp/devdocs/blob/master/lib/docs/filters/core/attribution.rb) — appends the license info and link to the original document * [`TitleFilter`](https://github.com/freeCodeCamp/devdocs/blob/master/lib/docs/filters/core/title.rb) — prepends the document with a title (disabled by default) * [`EntriesFilter`](https://github.com/freeCodeCamp/devdocs/blob/master/lib/docs/filters/core/entries.rb) — abstract filter for extracting the page's metadata +* [`ExternalUrlsFilter`](https://github.com/freeCodeCamp/devdocs/blob/master/lib/docs/filters/core/external_urls.rb) — replaces external URLs for relative URLs of existant devdocs documentation. ## Custom filters diff --git a/docs/scraper-reference.md b/docs/scraper-reference.md index fc00876d0d..e48fbe0f65 100644 --- a/docs/scraper-reference.md +++ b/docs/scraper-reference.md @@ -115,6 +115,7 @@ Additionally: * [`TitleFilter`](https://github.com/freeCodeCamp/devdocs/blob/master/lib/docs/filters/core/title.rb) is a core HTML filter, disabled by default, which prepends the document with a title (`