Skip to content

Commit

Permalink
Use absoluteURL instead of relativeURL for next/prev links (#783)
Browse files Browse the repository at this point in the history
* Remove trailing slash for docs url

* undo remove trailing slash & use absoluteURL for next/prev links

* use baseUrl instead of hardcoded slash
  • Loading branch information
endiliey committed Jun 17, 2018
1 parent 3755522 commit 0f01eac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/core/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
};

Expand Down

0 comments on commit 0f01eac

Please sign in to comment.