diff --git a/bun.lockb b/bun.lockb index b44a5fc..3691af9 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 67e2b3a..a7f0976 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@twemoji/parser": "^15.1.1", "github-slugger": "^2.0.0", "rehype-external-links": "^3.0.0", + "rehype-github-alert": "^1.0.0", "rehype-highlight": "^7.0.1", "rehype-katex": "^7.0.1", "rehype-slug": "^6.0.0", diff --git a/src/lib/components/Markdown.css b/src/lib/components/Markdown.css index 8981d00..b4bbfd4 100644 --- a/src/lib/components/Markdown.css +++ b/src/lib/components/Markdown.css @@ -194,4 +194,51 @@ margin: 1rem; font-size: 1.5rem; } + & .markdown-alert { + padding: 8px 16px; + margin: 1em 0; + + & .markdown-alert-title { + display: flex; + align-items: center; + & svg { + fill: currentColor; + margin-right: 8px; + } + } + & p { + margin: 0; + } + + &.markdown-alert-note { + border-left: solid #0969da 4px; + & .markdown-alert-title { + color: #0969da; + } + } + &.markdown-alert-tip { + border-left: solid #1a7f37 4px; + & .markdown-alert-title { + color: #1a7f37; + } + } + &.markdown-alert-important { + border-left: solid #8250df 4px; + & .markdown-alert-title { + color: #8250df; + } + } + &.markdown-alert-warning { + border-left: solid #9a6700 4px; + & .markdown-alert-title { + color: #9a6700; + } + } + &.markdown-alert-caution { + border-left: solid #cf222e 4px; + & .markdown-alert-title { + color: #cf222e; + } + } + } } \ No newline at end of file diff --git a/src/lib/components/Markdown.ts b/src/lib/components/Markdown.ts index a67c526..37680c3 100644 --- a/src/lib/components/Markdown.ts +++ b/src/lib/components/Markdown.ts @@ -9,6 +9,7 @@ import rehypeslug from 'rehype-slug' import rehypeKatex from 'rehype-katex' import rehypeHighlight from 'rehype-highlight' import rehypeExternalLinks from 'rehype-external-links' +import rehypeGithubAlert from 'rehype-github-alert' import rehypeStringify from 'rehype-stringify' @@ -22,6 +23,7 @@ function Perser(mdtext: string): string { .use(rehypeKatex, {output:'mathml'}) // 数式 .use(rehypeHighlight) // Syntax highlight .use(rehypeExternalLinks, {target:'_blank', rel:['noreferrer','noopener']}) // 外部サイトを新規タブで開く + .use(rehypeGithubAlert) .use(rehypeStringify, {allowDangerousHtml: true}) .processSync(mdtext) .toString()