Skip to content

Commit

Permalink
fix(gitlabwiki): remove extension from all urls (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Jun 8, 2024
1 parent 469467d commit c39b265
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-bats-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"typedoc-gitlab-wiki-theme": patch
---

- Remove extension from all urls (#628)
4 changes: 2 additions & 2 deletions packages/typedoc-gitlab-wiki-theme/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export function load(app: Application) {
MarkdownPageEvent.END,
(page: MarkdownPageEvent<Reflection>) => {
page.contents = page.contents?.replace(
/\[([^\]]+)\]\((?!https?:|\/|\.)([^)]+)\)/g,
/\[([^\]]+)\]\((?!https?:)([^)]+)\)/g,
(match: string, text: string, url: string) => {
let relativeUrl = url?.replace(/(.*).md/, '$1');
let relativeUrl = url?.replace(/\.md/g, '');
if (!relativeUrl.startsWith('.') && !relativeUrl.startsWith('/')) {
relativeUrl = './' + relativeUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ exports[`GithubWiki should output index docs 1`] = `
"
`;

exports[`GithubWiki should output member docs 1`] = `
"[typedoc-gitlab-wiki-theme](../../home) / [module-1](../home) / ClassA
# Class: ClassA
## Constructors
### new ClassA()
> **new ClassA**(): [\`ClassA\`](./ClassA)
#### Returns
[\`ClassA\`](./ClassA)
"
`;

exports[`GithubWiki should output single modules sidebar 1`] = `
"## API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ describe(`GithubWiki`, () => {
expect(contents).toMatchSnapshot();
});

test(`should output member docs`, async () => {
const contents = fs
.readFileSync(
path.join(__dirname, '../out/default/module-1/classes/ClassA.md'),
)
.toString();
expect(contents).toMatchSnapshot();
});

test(`should output default sidebar`, async () => {
const contents = fs
.readFileSync(path.join(__dirname, '../out/default/_sidebar.md'))
Expand Down

0 comments on commit c39b265

Please sign in to comment.