Skip to content

Commit

Permalink
fix: Update child packages parseUrl functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Feb 6, 2024
1 parent c8c2902 commit cbf62fa
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
7 changes: 7 additions & 0 deletions .changeset/five-cobras-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"typedoc-github-wiki-theme": patch
"typedoc-gitlab-wiki-theme": patch
"typedoc-vitepress-theme": patch
---

- Updates to typedoc-plugin-markdown internal apis
7 changes: 5 additions & 2 deletions packages/typedoc-github-wiki-theme/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export class GithubWikiTheme extends MarkdownTheme {
}

class ThemeRenderContext extends MarkdownThemeRenderContext {
parseUrl = (url: string) => {
return encodeURI('../wiki/' + url.replace('.md', ''));
override helpers = {
...this.helpers,
parseUrl: (url: string) => {
return encodeURI('../wiki/' + url.replace('.md', ''));
},
};
}
3 changes: 2 additions & 1 deletion packages/typedoc-gitlab-wiki-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"build": "tsc",
"build-and-test": "npm run build && npm run test",
"pretest": "ts-node ./test/__scripts__/prepare.ts",
"test": "jest"
"test": "jest",
"test:update": "npm run build && npm test -- -u"
},
"author": "Thomas Grey",
"license": "MIT",
Expand Down
13 changes: 8 additions & 5 deletions packages/typedoc-gitlab-wiki-theme/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ export class GitlabWikiTheme extends MarkdownTheme {
}

class ThemeRenderContext extends MarkdownThemeRenderContext {
parseUrl = (url: string) => {
const relativeUrl = url?.replace(/(.*).md/, '$1').replace(/ /g, '-');
return encodeURI(
relativeUrl?.startsWith('..') ? relativeUrl : './' + relativeUrl,
);
override helpers = {
...this.helpers,
parseUrl: (url: string) => {
const relativeUrl = url?.replace(/(.*).md/, '$1').replace(/ /g, '-');
return encodeURI(
relativeUrl?.startsWith('..') ? relativeUrl : './' + relativeUrl,
);
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ export class MarkdownThemeRenderContext {
*/
text = text(this.theme);

/**
* @deprecated - moved to helpers
*/
parseUrl = (url: string) => {
return encodeURI(url);
};

/**
* Hook into the TypeDoc rendering system.
*/
Expand Down
17 changes: 10 additions & 7 deletions packages/typedoc-vitepress-theme/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ export class VitepressTheme extends MarkdownTheme {
}

class ThemeRenderContext extends MarkdownThemeRenderContext {
parseUrl = (url: string) => {
const urlWithAnchor = url.split('#');
if (urlWithAnchor.length > 1) {
const anchorPart = slugify(urlWithAnchor[1]);
return encodeURI(`${urlWithAnchor[0]}#${anchorPart}`);
}
return encodeURI(url);
override helpers = {
...this.helpers,
parseUrl: (url: string) => {
const urlWithAnchor = url.split('#');
if (urlWithAnchor.length > 1) {
const anchorPart = slugify(urlWithAnchor[1]);
return encodeURI(`${urlWithAnchor[0]}#${anchorPart}`);
}
return encodeURI(url);
},
};
}

Expand Down

0 comments on commit cbf62fa

Please sign in to comment.