Skip to content

Commit a89b417

Browse files
committed
add advanced topics
1 parent 1e235fb commit a89b417

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

demo/docs/advanced.mdx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
id: advanced
3+
hide_title: true
4+
sidebar_label: Advanced
5+
title: Advanced
6+
---
7+
8+
```mdx-code-block
9+
import PetSchema from './petstore/schemas/pet.schema.mdx';
10+
import BrowserWindow from '@site/src/components/BrowserWindow';
11+
```
12+
13+
## Importing MDX
14+
15+
:::tip
16+
For more background see the [official documentation](https://docusaurus.io/docs/markdown-features/react#importing-markdown) for importing MDX on docusaurus.io
17+
:::
18+
19+
Let's say you're working on supporting documentation for your API and you want to reference a particular schema. With Docusaurus, you can import generated `*.schema.mdx` files and use them as components!
20+
21+
### Standalone Schema
22+
23+
```mdx title="Standalone Schema"
24+
import PetSchema from './petstore/schemas/pet.schema.mdx';
25+
26+
<PetSchema />
27+
```
28+
29+
```mdx-code-block
30+
31+
<PetSchema />
32+
33+
```
34+
35+
### Schema in BrowserWindow
36+
37+
:::tip
38+
The `BrowserWindow` component implemented by [docusaurus.io](https://github.com/facebook/docusaurus/tree/main/website/src/components/BrowserWindow) was adapted for this example. Aside from visually framing a schema it also supports passing custom styles to the schema component itself.
39+
:::
40+
41+
```mdx title="Schema wrapped in BrowserWindow component"
42+
import PetSchema from './petstore/schemas/pet.schema.mdx';
43+
import BrowserWindow from '@site/src/components/BrowserWindow';
44+
45+
<BrowserWindow bodyStyle={{height: 350, overflow: "auto", fontSize: "80%"}} url="https://docusaurus-openapi.tryingpan.dev/advanced#schema-inside-browserwindow">
46+
47+
<PetSchema />
48+
49+
</BrowserWindow>
50+
```
51+
52+
```mdx-code-block
53+
<BrowserWindow bodyStyle={{height: 350, overflow: "auto", fontSize: "80%"}} url="https://docusaurus-openapi.tryingpan.dev/advanced#schema-inside-browserwindow">
54+
55+
<PetSchema />
56+
57+
</BrowserWindow>
58+
```

demo/sidebars.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ const sidebars: SidebarsConfig = {
4141
type: "doc",
4242
id: "versioning",
4343
},
44+
{
45+
type: "doc",
46+
id: "advanced",
47+
},
4448
{
4549
type: "category",
4650
label: "Customization",

0 commit comments

Comments
 (0)