mirror of
https://github.com/koodiklinikka/koodiklinikka.fi.git
synced 2026-03-18 13:05:26 +00:00
rename slack message markdown transformer
This commit is contained in:
@@ -10,22 +10,26 @@ import { getChannels } from "../data/channels";
|
|||||||
import emoji from "emoji-dictionary";
|
import emoji from "emoji-dictionary";
|
||||||
import ReactMarkdown from "react-markdown";
|
import ReactMarkdown from "react-markdown";
|
||||||
|
|
||||||
const emojiSupport = (text: { value: string }) => {
|
const slackMarkdownRenderer = (text: { value: string }) => {
|
||||||
const emojiText = text.value.replace(/:\w+:/gi, (name) =>
|
const emojiText = text.value.replace(/:\w+:/gi, (name) =>
|
||||||
emoji.getUnicode(name)
|
emoji.getUnicode(name)
|
||||||
);
|
);
|
||||||
|
|
||||||
return emojiText.split(/(<#[A-Z0-9]+\|[A-Za-z0-9]+>)/).map((str) => {
|
return (
|
||||||
const matches = str.match(/<#([A-Z0-9]+)\|([A-Za-z0-9]+)>/);
|
<span>
|
||||||
if (matches) {
|
{emojiText.split(/(<#[A-Z0-9]+\|[A-Za-z0-9]+>)/).map((str) => {
|
||||||
return (
|
const matches = str.match(/<#([A-Z0-9]+)\|([A-Za-z0-9]+)>/);
|
||||||
<a href={`https://app.slack.com/client/T03BQ3NU9/${matches[1]}`}>
|
if (matches) {
|
||||||
{matches[2]}
|
return (
|
||||||
</a>
|
<a href={`https://app.slack.com/client/T03BQ3NU9/${matches[1]}`}>
|
||||||
);
|
{matches[2]}
|
||||||
}
|
</a>
|
||||||
return str;
|
);
|
||||||
});
|
}
|
||||||
|
return str;
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
@@ -161,7 +165,7 @@ const IndexContent = (props: IndexProps) => (
|
|||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
className="channel-topic"
|
className="channel-topic"
|
||||||
source={channel.topic}
|
source={channel.topic}
|
||||||
renderers={{ text: emojiSupport }}
|
renderers={{ text: slackMarkdownRenderer }}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user