File tree 3 files changed +14
-3
lines changed
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " nextra-theme-docs " : patch
3
+ ---
4
+
5
+ fix type of ` Navbar.children ` , should be ` ReactNode ` , not ` ReactElement `
Original file line number Diff line number Diff line change @@ -3,14 +3,14 @@ import cn from 'clsx'
3
3
import NextLink from 'next/link'
4
4
import { Anchor } from 'nextra/components'
5
5
import { DiscordIcon , GitHubIcon } from 'nextra/icons'
6
- import { element } from 'nextra/schemas'
6
+ import { element , reactNode } from 'nextra/schemas'
7
7
import type { FC } from 'react'
8
8
import { z } from 'zod'
9
9
import { fromZodError } from 'zod-validation-error'
10
10
import { ClientNavbar } from './index.client'
11
11
12
12
const propsSchema = z . strictObject ( {
13
- children : element . optional ( ) ,
13
+ children : reactNode . optional ( ) ,
14
14
logoLink : z . union ( [ z . string ( ) , z . boolean ( ) ] ) . default ( true ) ,
15
15
logo : element ,
16
16
projectLink : z . string ( ) . optional ( ) ,
Original file line number Diff line number Diff line change 1
1
import type { ProcessorOptions } from '@mdx-js/mdx'
2
2
import type { MathJax3Config } from 'better-react-mathjax'
3
- import type { ReactElement } from 'react'
3
+ import type { ReactElement , ReactNode } from 'react'
4
4
import { isValidElement } from 'react'
5
5
import type { Options as RehypeKatexOptions } from 'rehype-katex'
6
6
import type { Options as RehypePrettyCodeOptions } from 'rehype-pretty-code'
@@ -72,6 +72,12 @@ export const element = z.custom<ReactElement<Record<string, unknown>>>(
72
72
isValidElement ,
73
73
{ message : 'Must be React.ReactElement' }
74
74
)
75
+ export const reactNode = z . custom < ReactNode > (
76
+ data =>
77
+ isValidElement ( data ) ||
78
+ ( Array . isArray ( data ) && data . every ( value => isValidElement ( value ) ) ) ,
79
+ { message : 'Must be React.ReactNode' }
80
+ )
75
81
76
82
export const stringOrElement = z . union ( [ z . string ( ) , element ] )
77
83
You can’t perform that action at this time.
0 commit comments