Skip to content

Commit

Permalink
feat: allow 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 72d1f52 commit 485d49e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
32 changes: 23 additions & 9 deletions src/components/ui/markdown/parsers/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ import type { MarkdownToJSX } from 'markdown-to-jsx'

import { Banner } from '../../banner/Banner'
import { Gallery } from '../../gallery/Gallery'
import { Markdown } from '../Markdown'
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 @@ -45,9 +57,14 @@ export const ContainerRule: MarkdownToJSX.Rule = {
<Banner
type={name || (transformMap as any)[name] || 'info'}
className="my-4"
message={content}
key={state?.key}
/>
>
<Markdown
value={content}
allowsScript
className="[&>p:first-child]:mt-0"
/>
</Banner>
)
}
case 'banner': {
Expand All @@ -56,12 +73,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}>
<Markdown value={content} allowsScript />
</Banner>
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/socket/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const eventHandler = (
case EventTypes.POST_DELETE: {
const post = data as PostModel
if (getCurrentPostData()?.id === post.id) {
router.push(routeBuilder(Routes.PageDeletd, {}))
router.replace(routeBuilder(Routes.PageDeletd, {}))
toast.error('文章已删除')
}
break
Expand All @@ -77,7 +77,7 @@ export const eventHandler = (
case 'NOTE_DELETE': {
const note = data as NoteModel
if (getCurrentNoteData()?.data.id === note.id) {
router.push(routeBuilder(Routes.PageDeletd, {}))
router.replace(routeBuilder(Routes.PageDeletd, {}))
toast.error('手记已删除')
}
break
Expand Down

1 comment on commit 485d49e

@vercel
Copy link

@vercel vercel bot commented on 485d49e Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

innei.in
springtide.vercel.app
shiro-innei.vercel.app
shiro-git-main-innei.vercel.app

Please sign in to comment.