Skip to content

Commit 332c7fb

Browse files
committed
feat: keypoints
1 parent f9eacd6 commit 332c7fb

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

docs/getting-started/authoring.mdx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ nav: 1
66
---
77

88
<Intro>
9-
This is a guide on how to write documentation. We support all [GitHub Flavored Markdown](https://github.github.com/gfm/) syntax, plus some custom components that are described here.
9+
This is a guide on how to write documentation. We support all [GFM](https://github.github.com/gfm/) syntax, plus some custom components that are described here.
1010
</Intro>
1111

12+
<Keypoints>
13+
<KeypointsItem>[Front matter](#frontmatter)</KeypointsItem>
14+
<KeypointsItem>Custom [markdown](#markdown) components</KeypointsItem>
15+
</Keypoints>
16+
1217
In your `MDX` folder, create any `path/to/my-document.mdx`:
1318

1419
```md
@@ -61,6 +66,24 @@ Plus, all exported [`components/mdx/index.tsx`](components/mdx/index.tsx) MDX co
6166
</Intro>
6267
</details>
6368

69+
### `Keypoints`
70+
71+
```md
72+
<Keypoints>
73+
<KeypointsItem>First item</KeypointsItem>
74+
<KeypointsItem>Second **item**</KeypointsItem>
75+
</Keypoints>
76+
```
77+
78+
<details>
79+
<summary>Result</summary>
80+
81+
<Keypoints>
82+
<KeypointsItem>First item</KeypointsItem>
83+
<KeypointsItem>Second **item**</KeypointsItem>
84+
</Keypoints>
85+
</details>
86+
6487
### `Img`
6588

6689
Relative images are supported. Eg, inside your [`MDX`](introduction#configuration:~:text=MDX) folder:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import cn from '@/lib/cn'
2+
import { ComponentProps } from 'react'
3+
import { li as Li, ul as Ul } from '../index'
4+
5+
export function Keypoints({
6+
title = 'Keypoints',
7+
children,
8+
className,
9+
...props
10+
}: { title: string } & ComponentProps<'section'>) {
11+
return (
12+
<section
13+
{...props}
14+
className={cn(className, 'bg-surface-dim my-8 rounded-xl border border-outline-variant p-6')}
15+
>
16+
<h2 className="mb-6 text-2xl font-bold">{title}</h2>
17+
18+
<Ul className="mb-0 text-sm">{children}</Ul>
19+
</section>
20+
)
21+
}
22+
23+
export function KeypointsItem(props: ComponentProps<'li'>) {
24+
return <Li {...props} />
25+
}

src/components/mdx/Keypoints/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Keypoints'

src/components/mdx/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export * from './Grid'
66
export * from './Hint'
77
export * from './Img'
88
export * from './Intro'
9+
export * from './Keypoints'
910
export * from './Summary'
1011
export * from './Toc'
1112

@@ -44,12 +45,12 @@ export const h6 = ({ id, ...props }: Omit<ComponentProps<typeof Heading>, 'Tag'>
4445
)
4546

4647
export const ul = ({ className, ...props }: ComponentProps<'ul'>) => (
47-
<div className={cn(className, 'my-4 mb-8')}>
48+
<div className={cn('my-4 mb-8', className)}>
4849
<ul className="ms-6 list-disc" {...props} />
4950
</div>
5051
)
5152
export const ol = ({ className, ...props }: ComponentProps<'ol'>) => (
52-
<div className={cn(className, 'my-4 mb-8')}>
53+
<div className={cn('my-4 mb-8', className)}>
5354
<ol className="ms-6 list-decimal" {...props} />
5455
</div>
5556
)

0 commit comments

Comments
 (0)