feat(website): migrates nav data format and updates docs pages (#1049)
* migrates nav data format and updates docs pages * removes sidebar_title from content files * updates api docs to work with new format
This commit is contained in:
1 parent
d3b72899f1
commit
bd8cc5464e
72 files changed
+613
-634
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import { useState, useRef } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import Link from 'next/link'
|
||||
import OperationObject from './partials/operation-object'
|
||||
import Head from 'next/head'
|
||||
@@ -13,12 +12,11 @@ import useOnClickOutside from 'lib/hooks/use-on-click-outside'
|
||||
function OpenApiPage({
|
||||
info,
|
||||
operationCategory,
|
||||
sidenavOrder,
|
||||
navData,
|
||||
productName,
|
||||
productSlug,
|
||||
pathFromRoot,
|
||||
currentPath,
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const operationsRef = useRef(null)
|
||||
const [expandedOperations, setExpandedOperations] = useState([])
|
||||
useOnClickOutside(operationsRef, () => setExpandedOperations([]))
|
||||
@@ -41,11 +39,10 @@ function OpenApiPage({
|
||||
/>
|
||||
<DocsSidenav
|
||||
Link={Link}
|
||||
currentPage={router.asPath}
|
||||
category={pathFromRoot}
|
||||
currentPath={currentPath}
|
||||
baseRoute={'api-docs'}
|
||||
disableFilter={true}
|
||||
order={sidenavOrder}
|
||||
data={[]}
|
||||
navData={navData}
|
||||
/>
|
||||
<Content
|
||||
product={productSlug}
|
||||
|
||||
@@ -8,9 +8,12 @@ export function getPropsForPage(schema, params) {
|
||||
const serviceIds = getServiceIds(operationObjects)
|
||||
// info and sidenav data are needed on all pages
|
||||
const info = schema.info
|
||||
const sidenavOrder = getSidenavData(serviceIds)
|
||||
const navData = getSidenavData(serviceIds)
|
||||
// If there's no "page" param, then this is the landing page
|
||||
const isLanding = !params || !params.page || params.page.length == 0
|
||||
|
||||
const currentPath = params && params.page ? params.page.join('/') : ''
|
||||
|
||||
// Otherwise, we should have an operationCategory that matches the slug-ified ID from the URL path
|
||||
const operationCategory = isLanding
|
||||
? false
|
||||
@@ -24,7 +27,8 @@ export function getPropsForPage(schema, params) {
|
||||
)
|
||||
return { name, slug, operations }
|
||||
})[0]
|
||||
return { info, sidenavOrder, operationCategory }
|
||||
|
||||
return { info, navData, operationCategory, currentPath }
|
||||
}
|
||||
|
||||
/* Given a schema, return all the paths we'll render for our openapi generated docs */
|
||||
@@ -44,7 +48,7 @@ to render a flat list of services */
|
||||
function getSidenavData(serviceIds) {
|
||||
const order = serviceIds.map((serviceId) => {
|
||||
return {
|
||||
sidebar_title: capitalCase(serviceId),
|
||||
title: capitalCase(serviceId),
|
||||
indexData: true,
|
||||
path: getServiceSlug(serviceId),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user