forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphqlItem.tsx
More file actions
37 lines (35 loc) · 972 Bytes
/
GraphqlItem.tsx
File metadata and controls
37 lines (35 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { HeadingLink } from 'components/article/HeadingLink'
import type { GraphqlT } from './types'
import { Notice } from './Notice'
type Props = {
item: GraphqlT
heading?: string
headingLevel?: number
children?: React.ReactNode
}
export function GraphqlItem({ item, heading, children, headingLevel = 2 }: Props) {
const lowerCaseName = item.name.toLowerCase()
return (
<div>
<HeadingLink
as={headingLevel === 2 ? 'h2' : headingLevel === 3 ? 'h3' : 'h6'}
slug={lowerCaseName}
>
{item.name}
</HeadingLink>
<div
dangerouslySetInnerHTML={{
__html: item.description,
}}
/>
<div>
{item.preview && <Notice item={item} variant="preview" />}
{item.isDeprecated && <Notice item={item} variant="deprecation" />}
</div>
<div>
{heading && <h4 dangerouslySetInnerHTML={{ __html: heading }} />}
{children}
</div>
</div>
)
}