add: added emojis

This commit is contained in:
Lukian 2025-04-20 23:45:33 +02:00
parent fafbceb6a2
commit f326555c59
14 changed files with 523 additions and 2 deletions

View file

@ -27,6 +27,10 @@ export default function MessageComponent({ message, user, channel, deleteMessage
array.push(string)
string = ''
array.push(word)
} else if (word.startsWith(":") && word.endsWith(":") && word.length > 2) {
array.push(string)
string = ''
array.push(word)
} else {
string += word + " "
}
@ -47,6 +51,9 @@ export default function MessageComponent({ message, user, channel, deleteMessage
return <span key={index} ><Link to={`/u/${word.substring(1)}`}>{word}</Link> </span>
} else if (word.startsWith("https://") || word.startsWith("http://")) {
return <span key={index} ><Link to={word}>{word}</Link> </span>
} else if (word.startsWith(":") && word.endsWith(":") && word.length > 2) {
const emojiName = word.substring(1, word.length - 1);
return <span key={index} ><img src={`/api/emojis/${emojiName}`} alt={emojiName} className="message-emoji" /> </span>
}
return <span key={index}>{word} </span>;
})}

View file

@ -13,6 +13,7 @@ export default function TopBar({ user }: { user: User | undefined }) {
<Link to="/">Home</Link>
<Link to="/channels">Channels</Link>
<Link to="/users">Users</Link>
<Link to="/emojis">Emojis</Link>
</div>
<div className="topbar-center">
{user && user.id == 5 ? (