docs: change sidebar behavior

[DOCS-967]: https://hasurahq.atlassian.net/browse/DOCS-967?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9179
GitOrigin-RevId: f99e342f6ca2602304c8f35b016b2d63c93340b0
This commit is contained in:
Rob Dominguez 2023-05-19 08:08:08 -05:00 committed by hasura-bot
parent c0e998400b
commit 962e176258
10 changed files with 66 additions and 10 deletions

View File

@ -1,4 +1,7 @@
{
"label": "Authentication & Authorization",
"position": 70
}
"position": 70,
"customProps": {
"sidebar_pathname": "auth"
}
}

View File

@ -1,4 +1,7 @@
{
"label": "GraphQL Federation",
"position": 100
"position": 100,
"customProps": {
"sidebar_pathname": "data-federation"
}
}

View File

@ -1,5 +1,8 @@
{
"label": "Hasura Enterprise",
"position": 210,
"className": "enterprise-icon"
"className": "enterprise-icon",
"customProps": {
"sidebar_pathname": "enterprise"
}
}

View File

@ -1,4 +1,7 @@
{
"label": "Migrations, Metadata and Seeds",
"position": 140
"position": 140,
"customProps": {
"sidebar_pathname": "migrations-metadata-seeds"
}
}

View File

@ -1,4 +1,7 @@
{
"label": "Hasura Policies",
"position": 220
"position": 220,
"customProps": {
"sidebar_pathname": "policies"
}
}

View File

@ -1,4 +1,7 @@
{
"label": "Hasura Use Cases",
"position": 1
"position": 1,
"customProps": {
"sidebar_pathname": "resources/use-case"
}
}

View File

@ -1,4 +1,7 @@
{
"label": "RESTified Endpoints",
"position": 125
"position": 125,
"customProps": {
"sidebar_pathname": "restified"
}
}

View File

@ -1,4 +1,7 @@
{
"label": "GraphQL Schema",
"position": 30
"position": 30,
"customProps": {
"sidebar_pathname": "schema"
}
}

View File

@ -1,4 +1,7 @@
{
"label": "Security Tools",
"position": 160
"position": 160,
"customProps": {
"sidebar_pathname": "security"
}
}

View File

@ -0,0 +1,29 @@
import React from 'react';
import DocSidebarItemCategory from '@theme/DocSidebarItem/Category';
import DocSidebarItemLink from '@theme/DocSidebarItem/Link';
import DocSidebarItemHtml from '@theme/DocSidebarItem/Html';
export default function DocSidebarItem({ item, ...props }) {
switch (item.type) {
case 'category':
if (item.customProps?.sidebar_pathname) {
// if there is a custom sidebar_pathname, use it
item.href = `/docs/latest/${item.customProps.sidebar_pathname}/overview/`;
} else if (item.href === undefined) {
// if there is no custom sidebar_pathname, use the label with our regex
// and apparently deal with the Wiki as a special case
if (item.label != 'Docs Wiki') {
item.href = `/docs/latest/${item.label.toLowerCase().replace(/\s/g, '-')}/overview/`;
}
} else {
// if it already has a href (such as any category that has an index within the dir), use it
item.href = item.href;
}
return <DocSidebarItemCategory item={item} {...props} />;
case 'html':
return <DocSidebarItemHtml item={item} {...props} />;
case 'link':
default:
return <DocSidebarItemLink item={item} {...props} />;
}
}