Skip to content

Commit

Permalink
chore(website): Each package includes a link to typedoc API in naviga…
Browse files Browse the repository at this point in the history
…tion tree
  • Loading branch information
mlaursen committed Jul 27, 2021
1 parent dec09b8 commit c388ba6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/documentation/src/constants/navItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ import ReactSVGIcon from "icons/ReactSVGIcon";
import createIdGenerator from "utils/createIdGenerator";
import { toTitle } from "utils/toTitle";

import { PACKAGE_NAMES, SCSS_PACKAGES } from "./packages";
import { PACKAGE_NAMES, SCSS_PACKAGES, TYPESCRIPT_PACKAGES } from "./packages";
import {
RouteNavItem,
NavItem,
DividerNavItem,
SubheaderNavItem,
} from "./meta/types";
import { snakeCase } from "lodash";

const uuid = createIdGenerator("nav");
const TSDOCS_PREFIX = "/tsdocs/modules/_react_md_";

const getPackageRoutes = (name: string): RouteNavItem[] => {
const routes: RouteNavItem[] = [];
Expand Down Expand Up @@ -52,6 +54,13 @@ const getPackageRoutes = (name: string): RouteNavItem[] => {
children: "Installation",
});

if (name !== "material-icons" && TYPESCRIPT_PACKAGES.includes(name)) {
routes.push({
href: `${TSDOCS_PREFIX}${snakeCase(name)}.html`,
children: "API (typedoc)",
});
}

if (SCSS_PACKAGES.includes(name)) {
routes.push({
href: "/sassdoc",
Expand Down Expand Up @@ -226,7 +235,7 @@ function createNavItem(
return tree;
}

if (!navItem.href.startsWith("/")) {
if (!navItem.href.startsWith("/") || navItem.href.startsWith(TSDOCS_PREFIX)) {
const itemId = navItem.href;
tree[itemId] = {
...navItem,
Expand Down

1 comment on commit c388ba6

@vercel
Copy link

@vercel vercel bot commented on c388ba6 Jul 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.