diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 6314d3ba4426..9aa428eb9354 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -13,16 +13,20 @@ const OnPageNav = require('./nav/OnPageNav.js'); const Site = require('./Site.js'); const translation = require('../server/translation.js'); const path = require('path'); +const url = require('url'); // component used to generate whole webpage for docs, including sidebar/header/footer class DocsLayout extends React.Component { getRelativeURL = (from, to) => { const extension = this.props.config.cleanUrl ? '' : '.html'; - return ( + const relativeHref = path .relative(from, to) .replace('\\', '/') - .replace(/^\.\.\//, '') + extension + .replace(/^\.\.\//, '') + extension; + return url.resolve( + `${this.props.config.baseUrl}${this.props.metadata.permalink}`, + relativeHref ); };