From 0f01eace8be1be273a63089a14d1e3ea2d2cae57 Mon Sep 17 00:00:00 2001 From: Endilie Yacop Sucipto Date: Sun, 17 Jun 2018 11:35:05 +0800 Subject: [PATCH] Use absoluteURL instead of relativeURL for next/prev links (#783) * Remove trailing slash for docs url * undo remove trailing slash & use absoluteURL for next/prev links * use baseUrl instead of hardcoded slash --- lib/core/DocsLayout.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 ); };