Skip to content

Commit

Permalink
Allow separators as possible menu items (#3765)
Browse files Browse the repository at this point in the history
* Allow separator as possible item in menu

* Create wise-bikes-run.md

---------

Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
  • Loading branch information
hasparus and dimaMachina authored Dec 4, 2024
1 parent 7159410 commit dd2e216
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-bikes-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextra": patch
---

Allow `type: 'separator'` item as `items` for `type: 'menu'`
13 changes: 7 additions & 6 deletions packages/nextra/src/server/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ const linkSchema = z.strictObject({
href: z.string()
})

const separatorItemSchema = z.strictObject({
type: z.literal('separator'),
title
})

const menuItemSchema = z
.union([
stringOrElement,
linkSchema,
z.strictObject({ title: stringOrElement })
z.strictObject({ title: stringOrElement }),
separatorItemSchema
])
.transform(transformTitle)

Expand All @@ -113,11 +119,6 @@ export const menuSchema = z.strictObject({
})
})

const separatorItemSchema = z.strictObject({
type: z.literal('separator'),
title
})

export const itemSchema = z.strictObject({
type: z.enum(['page', 'doc']).optional(),
title,
Expand Down

0 comments on commit dd2e216

Please sign in to comment.