diff --git a/docs/src/__generated__/gatsby-schema.graphql b/docs/src/__generated__/gatsby-schema.graphql index 44f4c90eb..af2357400 100644 --- a/docs/src/__generated__/gatsby-schema.graphql +++ b/docs/src/__generated__/gatsby-schema.graphql @@ -1728,12 +1728,14 @@ input SiteFieldSelector { children: NodeFieldSelector flags: SiteFlagsFieldSelector graphqlTypegen: SiteGraphqlTypegenFieldSelector + host: FieldSelectorEnum id: FieldSelectorEnum internal: InternalFieldSelector jsxRuntime: FieldSelectorEnum parent: NodeFieldSelector pathPrefix: FieldSelectorEnum polyfill: FieldSelectorEnum + port: FieldSelectorEnum siteMetadata: SiteSiteMetadataFieldSelector trailingSlash: FieldSelectorEnum } @@ -2008,12 +2010,14 @@ input SiteSortInput { children: NodeSortInput flags: SiteFlagsSortInput graphqlTypegen: SiteGraphqlTypegenSortInput + host: SortOrderEnum id: SortOrderEnum internal: InternalSortInput jsxRuntime: SortOrderEnum parent: NodeSortInput pathPrefix: SortOrderEnum polyfill: SortOrderEnum + port: SortOrderEnum siteMetadata: SiteSiteMetadataSortInput trailingSlash: SortOrderEnum } diff --git a/docs/src/__generated__/gatsby-types.d.ts b/docs/src/__generated__/gatsby-types.d.ts index ee00cad77..238504644 100644 --- a/docs/src/__generated__/gatsby-types.d.ts +++ b/docs/src/__generated__/gatsby-types.d.ts @@ -3361,7 +3361,7 @@ type SEOQuery = { readonly ogImage: { readonly gatsbyImageData: import('gatsby-p type SidebarQueryVariables = Exact<{ [key: string]: never; }>; -type SidebarQuery = { readonly allComponentMetaJson: { readonly nodes: ReadonlyArray<{ readonly name: string | null, readonly group: string | null, readonly alias: string | null, readonly platform: { readonly docs: { readonly overview: { readonly status: string | null, readonly mdx: { readonly childMdx: { readonly frontmatter: { readonly slug: string | null } | null } | null } | null } | null } | null } | null }> }, readonly allPrimitiveMetaJson: { readonly nodes: ReadonlyArray<{ readonly name: string | null, readonly description: string | null, readonly primitive: { readonly childMdx: { readonly frontmatter: { readonly slug: string | null } | null } | null } | null }> } }; +type SidebarQuery = { readonly allComponentMetaJson: { readonly nodes: ReadonlyArray<{ readonly name: string | null, readonly group: string | null, readonly alias: string | null, readonly platform: { readonly docs: { readonly overview: { readonly status: string | null, readonly mdx: { readonly childMdx: { readonly frontmatter: { readonly slug: string | null } | null } | null } | null } | null } | null } | null }> } }; } diff --git a/docs/src/components/ComponentDocumentCategoryNav.tsx b/docs/src/components/ComponentDocumentCategoryNav.tsx index 5dea18a5e..ec0788023 100644 --- a/docs/src/components/ComponentDocumentCategoryNav.tsx +++ b/docs/src/components/ComponentDocumentCategoryNav.tsx @@ -1,7 +1,9 @@ import { Link } from "gatsby"; +import * as React from "react"; import * as style from "./ComponentDocumentCategoryNav.css"; +type Category = "overview" | "usage" | "style"; interface ComponentDocumentCategoryNavProps { currentPath: string; } @@ -9,26 +11,51 @@ interface ComponentDocumentCategoryNavProps { const ComponentDocumentCategoryNav = ({ currentPath, }: ComponentDocumentCategoryNavProps) => { + const [currentCategory, setCurrentCategory] = React.useState(); + + const isOverview = /overview/g.test(currentPath); + const isUsage = /usage/g.test(currentPath); + const isStyle = /style/g.test(currentPath); + + // NOTE: /component/alert-dialog/overview/ -> /component/alert-dialog/ + const removedCategoryPath = currentPath.split("/").slice(0, -2).join("/"); + + React.useEffect(() => { + if (isOverview) { + setCurrentCategory("overview"); + return; + } + if (isUsage) { + setCurrentCategory("usage"); + return; + } + if (isStyle) { + setCurrentCategory("style"); + return; + } + setCurrentCategory(undefined); + }, []); + return ( <>