Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

EmoticonTranslations: Eliminate unnecessary construction of raw HTML.

Anders Kaseorg81e8155bc4ef
diff --git a/starlight_help/src/components/EmoticonTranslations.astro b/starlight_help/src/components/EmoticonTranslations.astro
index 62214ff4d1f..2a6419cec7f 100644
--- a/starlight_help/src/components/EmoticonTranslations.astro
+++ b/starlight_help/src/components/EmoticonTranslations.astro
@@ -4,17 +4,6 @@ import {getCollection} from "astro:content";
const emoticons = (await getCollection("emoticons")).toSorted(
(a, b) => a.data.order - b.data.order,
);
-
-const rowHTML = (emoticon: string, emoji: string, imageSrc: string) => `
-<tr>
- <td><code>${emoticon}</code></td>
- <td><img src="${imageSrc}" alt="${emoji}" class="emoji-big"></td>
-</tr>
-`;
-let body = "";
-for (const entry of emoticons) {
- body += rowHTML(entry.id, entry.data.emoji, entry.data.image.src);
-}
---
<table>
@@ -25,6 +14,17 @@ for (const entry of emoticons) {
</tr>
</thead>
<tbody>
- <Fragment set:html={body} />
+ {
+ emoticons.map((entry) => (
+ <tr>
+ <td>
+ <code>{entry.id}</code>
+ </td>
+ <td>
+ <img src={entry.data.image.src} alt={entry.data.emoji} class="emoji-big" />
+ </td>
+ </tr>
+ ))
+ }
</tbody>
</table>