fix: docs asset links should follow specified docsUrl (#1204)

This commit is contained in:
Marvin Chin 2019-01-29 01:20:00 +08:00 committed by Yangshun Tay
parent 1888e0fb92
commit 487fd573e5
2 changed files with 5 additions and 2 deletions

View file

@ -111,7 +111,10 @@ function getMarkup(rawContent, mdToHtml, metadata) {
content = mdToHtmlify(content, mdToHtml, metadata); content = mdToHtmlify(content, mdToHtml, metadata);
// replace any relative links to static assets (not in fenced code blocks) to absolute links // replace any relative links to static assets (not in fenced code blocks) to absolute links
content = replaceAssetsLink(content, `${siteConfig.baseUrl}docs`); const docsAssetsLocation = siteConfig.docsUrl
? `${siteConfig.baseUrl}${siteConfig.docsUrl}`
: siteConfig.baseUrl.substring(0, siteConfig.baseUrl.length - 1);
content = replaceAssetsLink(content, docsAssetsLocation);
const DocsLayout = require('../core/DocsLayout.js'); const DocsLayout = require('../core/DocsLayout.js');
return renderToStaticMarkupWithDoctype( return renderToStaticMarkupWithDoctype(

View file

@ -101,7 +101,7 @@ async function execute() {
if (fs.existsSync(join(CWD, '..', readMetadata.getDocsPath(), 'assets'))) { if (fs.existsSync(join(CWD, '..', readMetadata.getDocsPath(), 'assets'))) {
fs.copySync( fs.copySync(
join(CWD, '..', readMetadata.getDocsPath(), 'assets'), join(CWD, '..', readMetadata.getDocsPath(), 'assets'),
join(buildDir, 'docs', 'assets'), join(buildDir, siteConfig.docsUrl, 'assets'),
); );
} }