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 = `