Skip to content

Commit

Permalink
fix: Updated breadcrumbs ui
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Dec 3, 2023
1 parent ae99b9b commit fe82916
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 100 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-houses-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typedoc-plugin-markdown': patch
---

- Updated breadcrumbs UI
132 changes: 66 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.10",
"@types/node": "^20.10.0",
"@types/node": "^20.10.2",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"consola": "^3.2.3",
"copyfiles": "^2.4.1",
"cross-spawn": "^7.0.3",
"eslint": "^8.54.0",
"eslint": "^8.55.0",
"glob": "^10.3.10",
"jest": "^29.7.0",
"markdownlint": "^0.32.1",
Expand All @@ -43,7 +43,7 @@
"remark-toc": "^9.0.0",
"to-vfile": "^8.0.0",
"ts-jest": "^29.1.1",
"ts-morph": "^20.0.0",
"ts-morph": "^21.0.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.4",
"typescript": "^5.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/typedoc-plugin-markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "npm-run-all test:*",
"test:lint-md": "node test/__scripts__/lint.md.mjs",
"test:lint-mdx": "node test/__scripts__/lint.mdx.mjs",
"test:jest": "jest",
"test:jest": "jest --updateSnapshot",
"build-and-run": "npm run build && npm run pretest",
"build-and-test": "npm run build && npm run test",
"api-docs": "npm run build && typedoc --options ./typedoc.api.js --out ./docs/api",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
DeclarationReflection,
ProjectReflection,
Reflection,
ReflectionKind,
} from 'typedoc';
import * as path from 'path';
import { DeclarationReflection, ProjectReflection } from 'typedoc';
import { MarkdownThemeRenderContext } from '../..';
import { MarkdownPageEvent } from '../../../plugin/events';
import { link } from '../../../support/elements';
Expand All @@ -19,11 +15,20 @@ export function breadcrumbs(
): string {
const md: string[] = [];

const breadcrumb = (model: Reflection) => {
const isModule = model.kindOf(ReflectionKind.Module);
const isPackage = isModule && model.parent?.kindOf(ReflectionKind.Module);
if (
page.url === page.project.url ||
(page.url === context.options.getValue('entryFileName') &&
page.url.split(path.sep).length === 1)
) {
return '';
}

md.push(
link(escapeChars(page.project.name), context.relativeURL(page.project.url)),
);

if (model?.parent?.parent && !isPackage && !isModule) {
const breadcrumb = (model: any) => {
if (model?.parent?.parent) {
breadcrumb(model.parent);
}
md.push(link(escapeChars(model.name), context.relativeURL(model?.url)));
Expand All @@ -41,5 +46,5 @@ export function breadcrumbs(

md.push(pageName);

return md.length > 1 ? `${md.join('.')}` : '';
return md.length > 1 ? `${md.join(' / ')}` : '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export function memberTemplate(
md.push(context.header(page));
}

if (!context.options.getValue('hidePageTitle')) {
md.push(heading(1, context.pageTitle(page)));
}

if (!context.options.getValue('hideBreadcrumbs')) {
md.push(context.breadcrumbs(page));
}

if (!context.options.getValue('hidePageTitle')) {
md.push(heading(1, context.pageTitle(page)));
}

md.push(context.member(page.model, 1));

md.push(context.footer());
Expand Down
Loading

0 comments on commit fe82916

Please sign in to comment.