-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ApiDocMdx component for nested apis (#180)
- Loading branch information
1 parent
2d09476
commit eb69763
Showing
16 changed files
with
1,607 additions
and
1,458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'docusaurus-theme-redoc': minor | ||
--- | ||
|
||
Add support for multiple apis in MDX |
24 changes: 24 additions & 0 deletions
24
packages/docusaurus-theme-redoc/src/theme/ApiDocMdx/ApiDocMdx.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useMemo } from 'react'; | ||
import Redoc from '../Redoc'; | ||
import { useSpecData } from '../useSpecData'; | ||
import { MdxProps as Props } from '../../types/common'; | ||
import '../ApiSchema/styles.css'; | ||
|
||
const ApiDocMdx: React.FC<Props> = ({ id }: Props): JSX.Element => { | ||
const specProps = useSpecData(id); | ||
const optionsOverrides = useMemo(() => { | ||
return { | ||
theme: { | ||
// TODO: Investigate what the best breakpoints should be | ||
breakpoints: { | ||
medium: '130rem', | ||
large: '130rem', | ||
}, | ||
}, | ||
}; | ||
}, []); | ||
|
||
return <Redoc {...specProps} optionsOverrides={optionsOverrides} />; | ||
}; | ||
|
||
export default ApiDocMdx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ApiDocMdx from './ApiDocMdx'; | ||
|
||
export default ApiDocMdx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: Migrating to V1 | ||
sidebar_position: 4 | ||
--- | ||
|
||
## Options Changed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: Showing Multiple APIs | ||
sidebar_position: 2 | ||
--- | ||
|
||
## Nested View with MDX | ||
|
||
To display multiple API docs with the Docusaurus sidebar for navigation you can use the MDX component `@theme/ApiDocMdx` along with the setting `hide_table_of_contents` for the file. For an example check the "Nested Docs Example" section in the sidebar. | ||
|
||
```mdx | ||
--- | ||
title: API 1 - Swagger Petstore | ||
hide_table_of_contents: true | ||
--- | ||
|
||
import ApiDocMdx from '@theme/ApiDocMdx'; | ||
|
||
<ApiDocMdx id="using-single-yaml" /> | ||
``` | ||
|
||
The output of the above is viewable here: [Nested API 1](/docs/nested/nested-1). | ||
|
||
## Full Pages with links in Dropdown | ||
|
||
For a simpler solution just add all the routes in a Navbar Dropdown (see [docs](https://docusaurus.io/docs/api/themes/configuration#navbar-dropdown)). This is how the "Examples" of this website is structured. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: Schema Imports | ||
sidebar_position: 1 | ||
--- | ||
|
||
import ApiSchema from '@theme/ApiSchema'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
label: 'Nested Docs Example' | ||
position: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: API 1 - Swagger Petstore | ||
hide_table_of_contents: true | ||
--- | ||
|
||
import ApiDocMdx from '@theme/ApiDocMdx'; | ||
|
||
<ApiDocMdx id="using-single-yaml" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: API 2 - Swagger Petstore | ||
hide_table_of_contents: true | ||
--- | ||
|
||
import ApiDocMdx from '@theme/ApiDocMdx'; | ||
|
||
<ApiDocMdx id="using-swagger-json" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
eb69763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
redocusaurus – ./
redocusaurus-rohit-gohri.vercel.app
redocusaurus.vercel.app
redocusaurus-git-main-rohit-gohri.vercel.app
redocusaurus-v1.vercel.app