Skip to content

Commit

Permalink
fix: fix relative urls to index slug
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Sep 17, 2021
1 parent ea9219e commit 900e727
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-typedoc/package.json
Expand Up @@ -29,7 +29,7 @@
"build-and-test": "yarn run build && yarn run test",
"test:init": "rm -rf test/site && npx @docusaurus/init@latest init test/site classic",
"test:demo:start": "yarn run build && cd test/site && yarn run clear && yarn run start",
"test:demo:build": "yarn run build && cd test/site && yarn run clear && yarn run serve",
"test:demo:build": "yarn run build && cd test/site && yarn run clear && yarn run build && yarn run serve",
"test": "jest --colors"
},
"author": "Thomas Grey",
Expand Down
8 changes: 6 additions & 2 deletions packages/docusaurus-plugin-typedoc/src/theme.ts
Expand Up @@ -47,7 +47,11 @@ export class DocusaurusTheme extends MarkdownTheme {
}

getRelativeUrl(url: string) {
return super.getRelativeUrl(url).replace(/.md/g, '');
const relativeUrl = super.getRelativeUrl(url).replace(/.md/g, '');
if (path.basename(relativeUrl).startsWith('index')) {
return relativeUrl.replace('index', '')
}
return relativeUrl;
}

onPageEnd(page: PageEvent<DeclarationReflection>) {
Expand Down Expand Up @@ -92,7 +96,7 @@ export class DocusaurusTheme extends MarkdownTheme {
if (page.url === this.entryDocument) {
items = {
...items,
slug: '/' + path.relative(process.cwd(), this.out).replace(/\\/g, '/') + '/index',
slug: '/' + path.relative(process.cwd(), this.out).replace(/\\/g, '/') + '/',
};
}
if (sidebarLabel && sidebarLabel !== pageTitle) {
Expand Down
Expand Up @@ -31,8 +31,8 @@ module.exports = {
src: 'img/logo.svg',
},
items: [
{
to: 'docs/api',
{
to: 'docs/api/',
activeBasePath: 'docs',
label: 'API',
position: 'left',
Expand Down

0 comments on commit 900e727

Please sign in to comment.