mirror of
https://github.com/goauthentik/authentik
synced 2026-04-26 01:25:02 +02:00
* Fix import path. * Show unlisted entries if release. * Fix sidebar rendering. * Fix positioning of pre-release note. Tidy phrasing. * Clarify pre-release vs draft.
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import "./styles.css";
|
|
|
|
import { isGlossaryItem } from "../utils/glossaryUtils";
|
|
|
|
import { VersionPicker } from "#components/VersionPicker/index.tsx";
|
|
|
|
import type { PropSidebarItem } from "@docusaurus/plugin-content-docs";
|
|
import {
|
|
DocSidebarItemsExpandedStateProvider,
|
|
isVisibleSidebarItem,
|
|
} from "@docusaurus/plugin-content-docs/client";
|
|
import DocSidebarItem from "@theme/DocSidebarItem";
|
|
import type { Props as DocSidebarItemsProps } from "@theme/DocSidebarItems";
|
|
import { JSX, memo, useMemo } from "react";
|
|
|
|
function isReleaseNotesItem(item: PropSidebarItem): boolean {
|
|
return !!(item.type === "link" && item.docId?.startsWith("releases"));
|
|
}
|
|
|
|
function useVisibleSidebarItems(
|
|
items: readonly PropSidebarItem[],
|
|
activePath: string,
|
|
): PropSidebarItem[] {
|
|
return useMemo(
|
|
() =>
|
|
items.filter((item) => {
|
|
return isVisibleSidebarItem(item, activePath) || isReleaseNotesItem(item);
|
|
}),
|
|
[items, activePath],
|
|
);
|
|
}
|
|
|
|
const DocSidebarItems = ({ items, ...props }: DocSidebarItemsProps): JSX.Element => {
|
|
const visibleItems = useVisibleSidebarItems(items, props.activePath);
|
|
|
|
const includeVersionPicker = props.level === 1 && !props.activePath.startsWith("/integrations");
|
|
|
|
return (
|
|
<DocSidebarItemsExpandedStateProvider>
|
|
{includeVersionPicker ? <VersionPicker /> : null}
|
|
{visibleItems.map((item, index) => {
|
|
if (isGlossaryItem(item)) {
|
|
return null;
|
|
}
|
|
|
|
return <DocSidebarItem key={index} item={item} index={index} {...props} />;
|
|
})}
|
|
</DocSidebarItemsExpandedStateProvider>
|
|
);
|
|
};
|
|
|
|
export default memo(DocSidebarItems);
|