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 {
getRelativeURL = (from, to) => {
const extension = this.props.config.cleanUrl ? '' : '.html';
const relativeHref =
path
.relative(from, to)
.replace('\\', '/')
.replace(/^\.\.\//, '') + extension;
const relativeHref = path
.relative(`${from}.html`, `${to}.html`)
.replace('\\', '/')
.replace(/^\.\.\//, '')
.replace(/\.html$/, extension);
return url.resolve(
`${this.props.config.baseUrl}${this.props.metadata.permalink}`,
relativeHref,