Skip to content

Commit

Permalink
Add sidebar item classname for method (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
bourdakos1 committed Dec 18, 2021
1 parent 162bf0a commit 843f8ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@docusaurus/utils": "^2.0.0-beta.13",
"@docusaurus/utils-validation": "^2.0.0-beta.13",
"chalk": "^4.1.2",
"clsx": "^1.1.1",
"fs-extra": "^9.0.1",
"js-yaml": "^4.1.0",
"json-refs": "^3.0.15",
Expand Down
32 changes: 20 additions & 12 deletions packages/docusaurus-plugin-openapi/src/sidebars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import clsx from "clsx";

import { ApiMetadata, ApiPageMetadata } from "../types";

interface Options {
Expand Down Expand Up @@ -60,14 +62,17 @@ function groupByTags(
return item.api.tags?.includes(tag);
})
.map((item) => {
const apiPage = item as ApiPageMetadata; // TODO: we should have filtered out all info pages, but I don't like this
return {
type: "link",
label: item.title,
href: item.permalink,
docId: item.id,
className: (item as ApiPageMetadata).api.deprecated // TODO: we should have filtered out all info pages, but I don't like this
? "menu__list-item--deprecated"
: undefined,
label: apiPage.title,
href: apiPage.permalink,
docId: apiPage.id,
className: clsx({
"menu__list-item--deprecated": apiPage.api.deprecated,
"api-method": !!apiPage.api.method,
[apiPage.api.method]: !!apiPage.api.method,
}),
};
}),
};
Expand All @@ -93,14 +98,17 @@ function groupByTags(
return false;
})
.map((item) => {
const apiPage = item as ApiPageMetadata; // TODO: we should have filtered out all info pages, but I don't like this
return {
type: "link",
label: item.title,
href: item.permalink,
docId: item.id,
className: (item as ApiPageMetadata).api.deprecated // TODO: we should have filtered out all info pages, but I don't like this
? "menu__list-item--deprecated"
: undefined,
label: apiPage.title,
href: apiPage.permalink,
docId: apiPage.id,
className: clsx({
"menu__list-item--deprecated": apiPage.api.deprecated,
"api-method": !!apiPage.api.method,
[apiPage.api.method]: !!apiPage.api.method,
}),
};
}),
},
Expand Down

0 comments on commit 843f8ea

Please sign in to comment.