diff --git a/components/Markdown.tsx b/components/Markdown.tsx
index 8ae33b6..dd6f9a7 100644
--- a/components/Markdown.tsx
+++ b/components/Markdown.tsx
@@ -1,10 +1,11 @@
-import { anchorHeader, twemoji } from '@utils/Tools'
+import { anchorHeader, customEmoji, twemoji } from '@utils/Tools'
import MarkdownView from 'react-showdown'
import sanitizeHtml from 'sanitize-html'
+import Emoji from 'node-emoji'
const Markdown = ({ text }:MarkdownProps):JSX.Element => {
return
-
sanitizeHtml(html, {
+ sanitizeHtml(html, {
allowedTags: [
'addr', 'address', 'article', 'aside', 'h1', 'h2', 'h3', 'h4',
'h5', 'h6', 'section', 'blockquote', 'dd', 'div',
diff --git a/utils/Constants.ts b/utils/Constants.ts
index e76a28c..7cd5f8c 100644
--- a/utils/Constants.ts
+++ b/utils/Constants.ts
@@ -163,6 +163,9 @@ export const git = { 'github.com': { icon: 'github', text: 'Github' }, 'gitlab.
export const KoreanbotsDiscord = 'https://discord.gg/JEh53MQ'
export const ThemeColors = [{ name: '파랑', rgb: 'rgb(51, 102, 255)', hex: '#3366FF', color: 'koreanbots-blue' }, { name: '하양', rgb: 'rgb(251, 251, 251)', hex: '#FBFBFB', color: 'little-white' }, { name: '검정', rgb: 'rgb(27, 30, 35)', hex: '#1B1E23', color: 'very-black' }, { name: '보라', rgb: 'rgb(114, 137, 218)', hex: '#7289DA', color: 'discord-blurple' } ]
+export const KoreanbotsEmoji = {
+ koreanbots: '/logo.png'
+}
export const ErrorText = {
DEFAULT: '예상치 못한 에러가 발생하였습니다.',
200: '문제가 없는데 여기를 어떻게 오셨죠?',
diff --git a/utils/Regex.ts b/utils/Regex.ts
index a3e9d77..35bb69f 100644
--- a/utils/Regex.ts
+++ b/utils/Regex.ts
@@ -8,3 +8,4 @@ export const Url = urlRegex({ strict: true })
export const Emoji = '(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])'
export const Heading = '(.*?)<\\/h(\\d)>'
+export const EmojiSyntax = ':(\\w+):'
diff --git a/utils/ShowdownExtensions.ts b/utils/ShowdownExtensions.ts
index 14b26d4..340c363 100644
--- a/utils/ShowdownExtensions.ts
+++ b/utils/ShowdownExtensions.ts
@@ -1,10 +1,11 @@
-import { Emoji, Heading } from './Regex'
+import { Emoji, EmojiSyntax, Heading } from './Regex'
import Twemoji from 'twemoji'
+import { KoreanbotsEmoji } from './Constants'
export const anchorHeader = {
type: 'output',
regex: Heading,
- replace: function (__match, id:string, title:string, level:number) {
+ replace: function (__match: string, id:string, title:string, level:number) {
// github anchor style
const octicon_html = `
@@ -19,11 +20,20 @@ export const anchorHeader = {
export const twemoji = {
type: 'output',
- regex: Emoji,
- replace: function(__match, emoji: string) {
- console.log(emoji)
- const emoj = Twemoji.parse(emoji, { folder: 'svg', ext: '.svg' })
- if(!emoj) return emoji
+ regex: `${Emoji}{2}|${Emoji}`,
+ replace: function(__match: string, two: string, one: string) {
+ const parsed = __match || two || one
+ const emoj = Twemoji.parse(parsed, { folder: 'svg', ext: '.svg' })
+ if(!emoj) return parsed
return emoj
}
+}
+
+export const customEmoji = {
+ type: 'output',
+ regex: EmojiSyntax,
+ replace: function(__match: string, name: string) {
+ if(!name) return `:${name}:`
+ return `
`
+ }
}
\ No newline at end of file
diff --git a/utils/Tools.ts b/utils/Tools.ts
index ed0749d..282efc4 100644
--- a/utils/Tools.ts
+++ b/utils/Tools.ts
@@ -90,4 +90,4 @@ export function redirectTo(router: NextRouter, to: string) {
return
}
-export { anchorHeader, twemoji } from './ShowdownExtensions'
\ No newline at end of file
+export { anchorHeader, twemoji, customEmoji } from './ShowdownExtensions'
\ No newline at end of file