Files
OpenBB/website/src/theme/DocSidebarItem/index.js
jose-donato 6e9fefce9e Adds bot documentation to docusaurus and changes for hub (#4409)
* feat: adds bot docs to docu

* fix: file structure

* fix: brings changelog and switch platform button

* adding available options and changing Example text

* fix: detect whether iframe, fix availableoptions component, dynamic update third friday for options component

* fix: updated readme to reflect new changes

* fix: made it so from iframe only shows relevant sidebar

* PLAY BUTTON WOOO - works on discord/charting/chart

* comment

* fix: search bar, improve search

* fix: hijacks ctrl+k from iframe, adds visit to hub link

* about

* setting up play button for all images on Discord

* Bot docs updates

* terminal/faqs

* update main page

* add changelog to terminal

* SDK refactoring

* minor reordering

* bot struct in place

* move bot faqs over

* updating bot index and installation

* add new letterings

* fix: adds new navbar

* fix: new bot images and layouts

* updating installation and flow

* black linter

* spelling

* spelling

* The best commit

---------

Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
2023-03-16 16:29:57 +00:00

52 lines
1.4 KiB
JavaScript
Vendored

import React, { useState } from "react";
import DocSidebarItemCategory from "@theme/DocSidebarItem/Category";
import DocSidebarItemLink from "@theme/DocSidebarItem/Link";
import DocSidebarItemHtml from "@theme/DocSidebarItem/Html";
import { useIFrameContext } from "../Root";
import { useLocation } from "@docusaurus/router";
import clsx from "clsx";
function shouldHideItem(item, productPath) {
if (item.items) {
return item.items.every((childItem) =>
shouldHideItem(childItem, productPath)
);
}
if (item.type === "link") {
const itemPath = item.href.replace(/\/$/, "");
return !itemPath.startsWith(productPath);
}
if (item.type === "category") {
return item.items.every((childItem) =>
shouldHideItem(childItem, productPath)
);
}
return false;
}
export default function DocSidebarItem({ item, ...props }) {
const { isIFrame } = useIFrameContext();
const { pathname } = useLocation();
if (isIFrame) {
const firstTwoPathSegments = pathname.split("/").slice(0, 3).join("/");
if (shouldHideItem(item, firstTwoPathSegments)) {
return null;
}
}
switch (item.type) {
case "category":
return <DocSidebarItemCategory item={item} {...props} />;
case "html":
return <DocSidebarItemHtml item={item} {...props} />;
case "link":
default:
return <DocSidebarItemLink item={item} {...props} />;
}
}