UI & OpenAPI: Use full mode on docs pages by default on OpenAPI generated pages

This commit is contained in:
fuma-nama
2024-06-21 21:43:19 +08:00
parent eaa4415704
commit 78acd5567b
10 changed files with 17 additions and 8 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'fumadocs-openapi': patch
'fumadocs-mdx': patch
---
Use full mode on docs pages by default on OpenAPI generated pages
+1 -1
View File
@@ -49,7 +49,7 @@ export default function Page({
<DocsPage
toc={page.data.exports.toc}
lastUpdate={page.data.exports.lastModified}
full={!page.data.toc}
full={page.data.full}
tableOfContent={{
footer,
}}
@@ -22,6 +22,7 @@ By default, it includes:
| `title` | The title of page |
| `description` | The description of page |
| `icon` | The name of icon, see [Icons](#icons) |
| `full` | Enable full mode on the page |
You may extend your content source to add additional properties.
@@ -29,6 +30,8 @@ You may extend your content source to add additional properties.
---
title: My Page
description: Best document ever
icon: HomeIcon
full: false
---
## Learn More
-3
View File
@@ -6,9 +6,6 @@ void OpenAPI.generateFiles({
input: ['./*.yaml'],
output: './content/docs/ui',
per: 'tag',
frontmatter: () => ({
toc: false,
}),
renderer: {
Root(child) {
return OpenAPI.createElement(
-1
View File
@@ -17,7 +17,6 @@ export const utils = loader({
schema: {
frontmatter: defaultSchemas.frontmatter.extend({
preview: z.string().optional(),
toc: z.boolean().default(true),
index: z.boolean().default(false),
}),
},
@@ -17,7 +17,7 @@ export default async function Page({
const MDX = page.data.exports.default;
return (
<DocsPage toc={page.data.exports.toc}>
<DocsPage toc={page.data.exports.toc} full={page.data.full}>
<DocsBody>
<h1>{page.data.title}</h1>
<MDX />
@@ -17,7 +17,7 @@ export default async function Page({
const MDX = page.data.exports.default;
return (
<DocsPage toc={page.data.exports.toc}>
<DocsPage toc={page.data.exports.toc} full={page.data.full}>
<DocsBody>
<h1>{page.data.title}</h1>
<MDX />
+1
View File
@@ -12,6 +12,7 @@ const frontmatterSchema = z.object({
title: z.string(),
description: z.string().optional(),
icon: z.string().optional(),
full: z.boolean().optional(),
});
export const defaultSchemas = {
+3 -1
View File
@@ -18,7 +18,9 @@ export interface GenerateOptions {
}[];
/**
* Customise frontmatter
* Customise frontmatter.
*
* A `full: true` property will be added by default.
*/
frontmatter?: (
title: string,
+1
View File
@@ -11,6 +11,7 @@ export function renderPage(
const banner = dump({
title,
description,
full: true,
...options.frontmatter?.(title, description),
}).trim();