-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update diy suspense, add admonitions
- Loading branch information
1 parent
8118ac6
commit 8757789
Showing
3 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import type {MDXComponents} from 'mdx/types'; | ||
|
||
import Admonition from '@/lib/components/Admonition'; | ||
|
||
export function useMDXComponents(components: MDXComponents): MDXComponents { | ||
return { | ||
...components, | ||
Admonition, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export type Type = 'note' | 'warning'; | ||
|
||
const icons: Record<Type, React.ReactNode> = { | ||
note: <div>🛈</div>, | ||
warning: <div>⚠</div>, | ||
}; | ||
|
||
const messages: Record<Type, React.ReactNode> = { | ||
note: <div>Note</div>, | ||
warning: <div>Warning!</div>, | ||
}; | ||
|
||
const classNames: Record<Type, string> = { | ||
note: 'text-indigo-100 bg-indigo-500/10 ring-indigo-500', | ||
warning: 'text-amber-100 bg-amber-500/10 ring-amber-500', | ||
}; | ||
|
||
export default function Admonition({ | ||
children, | ||
type, | ||
}: { | ||
children: React.ReactNode; | ||
type: Type; | ||
}) { | ||
return ( | ||
<div | ||
className={`flex flex-col prose-p:m-0 p-4 rounded-lg ring-1 ${classNames[type]}`} | ||
> | ||
<div className="flex flex-row items-start gap-2 mb-2 font-bold lowercase"> | ||
{icons[type]} | ||
{messages[type]} | ||
</div> | ||
<div>{children}</div> | ||
</div> | ||
); | ||
} |