fix: wrong url in next/prev button in some cases (#1488)

This commit is contained in:
Hongarc 2019-05-18 13:29:13 +07:00 committed by Endi
parent 084a49819f
commit 1587810e8f

View file

@ -24,11 +24,11 @@ const {idx, getGitLastUpdatedTime, getGitLastUpdatedBy} = require('./utils.js');
class DocsLayout extends React.Component { class DocsLayout extends React.Component {
getRelativeURL = (from, to) => { getRelativeURL = (from, to) => {
const extension = this.props.config.cleanUrl ? '' : '.html'; const extension = this.props.config.cleanUrl ? '' : '.html';
const relativeHref = const relativeHref = path
path .relative(`${from}.html`, `${to}.html`)
.relative(from, to)
.replace('\\', '/') .replace('\\', '/')
.replace(/^\.\.\//, '') + extension; .replace(/^\.\.\//, '')
.replace(/\.html$/, extension);
return url.resolve( return url.resolve(
`${this.props.config.baseUrl}${this.props.metadata.permalink}`, `${this.props.config.baseUrl}${this.props.metadata.permalink}`,
relativeHref, relativeHref,