Skip to content

Commit

Permalink
add advanced topics
Browse files Browse the repository at this point in the history
  • Loading branch information
sserrata committed Sep 5, 2024
1 parent 1e235fb commit a89b417
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
58 changes: 58 additions & 0 deletions demo/docs/advanced.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
id: advanced
hide_title: true
sidebar_label: Advanced
title: Advanced
---

```mdx-code-block
import PetSchema from './petstore/schemas/pet.schema.mdx';
import BrowserWindow from '@site/src/components/BrowserWindow';
```

## Importing MDX

:::tip
For more background see the [official documentation](https://docusaurus.io/docs/markdown-features/react#importing-markdown) for importing MDX on docusaurus.io
:::

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!

### Standalone Schema

```mdx title="Standalone Schema"
import PetSchema from './petstore/schemas/pet.schema.mdx';

<PetSchema />
```

```mdx-code-block
<PetSchema />
```

### Schema in BrowserWindow

:::tip
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.
:::

```mdx title="Schema wrapped in BrowserWindow component"
import PetSchema from './petstore/schemas/pet.schema.mdx';
import BrowserWindow from '@site/src/components/BrowserWindow';

<BrowserWindow bodyStyle={{height: 350, overflow: "auto", fontSize: "80%"}} url="https://docusaurus-openapi.tryingpan.dev/advanced#schema-inside-browserwindow">

<PetSchema />

</BrowserWindow>
```

```mdx-code-block
<BrowserWindow bodyStyle={{height: 350, overflow: "auto", fontSize: "80%"}} url="https://docusaurus-openapi.tryingpan.dev/advanced#schema-inside-browserwindow">
<PetSchema />
</BrowserWindow>
```
4 changes: 4 additions & 0 deletions demo/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const sidebars: SidebarsConfig = {
type: "doc",
id: "versioning",
},
{
type: "doc",
id: "advanced",
},
{
type: "category",
label: "Customization",
Expand Down

0 comments on commit a89b417

Please sign in to comment.