Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

Commit

Permalink
feat: support banner markdown
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 3, 2023
1 parent 3cfce25 commit 63e6685
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/components/ui/Markdown/parsers/container.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import type { MarkdownToJSX } from 'markdown-to-jsx'
import { Priority, blockRegex } from 'markdown-to-jsx'
import { blockRegex, Priority } from 'markdown-to-jsx'
import React from 'react'

import { KamiMarkdown } from '~/components/common/KamiMarkdown'

import { Banner } from '../../Banner'
import { Gallery } from '../components/gallery'
import { pickImagesFromMarkdown } from '../utils/image'

const shouldCatchContainerName = ['gallery', 'banner', 'carousel'].join('|')
const shouldCatchContainerName = [
'gallery',
'banner',
'carousel',

'warn',
'error',
'danger',
'info',
'success',
'warning',
].join('|')
export const ContainerRule: MarkdownToJSX.Rule = {
match: blockRegex(
new RegExp(
Expand Down Expand Up @@ -43,11 +56,12 @@ export const ContainerRule: MarkdownToJSX.Rule = {
}
return (
<Banner
type={name || transformMap[name]}
type={name || (transformMap as any)[name] || 'info'}
className="my-4"
message={content}
key={state?.key}
/>
>
<KamiMarkdown>{content}</KamiMarkdown>
</Banner>
)
}
case 'banner': {
Expand All @@ -56,12 +70,9 @@ export const ContainerRule: MarkdownToJSX.Rule = {
}

return (
<Banner
type={params}
className="my-4"
message={content}
key={state?.key}
/>
<Banner type={params} className="my-4" key={state?.key}>
<KamiMarkdown>{content}</KamiMarkdown>
</Banner>
)
}
}
Expand Down

0 comments on commit 63e6685

Please sign in to comment.