Dies ist eine einfache Möglichkeit, ein Discourse-Symbol global zu ändern.
-
Mache einen Rechtsklick auf das Symbol, das du ändern möchtest, und wähle „Element untersuchen“ oder „Untersuchen“ (abhängig vom Browser)
-
Finde den Symbolnamen
-
Suche hier ein neues Symbol aus: Find Icons with the Perfect Look & Feel | Font Awesome, z. B. external-link-alt
-
Passe den Code an und füge ihn im Tab
Admin > Anpassung > Themes > Code bearbeiten -> JShinzu
// {theme}/javascripts/discourse/api-initializers/init-theme.gjs
import { apiInitializer } from "discourse/lib/api";
export default apiInitializer((api) => {
api.replaceIcon("link", "external-link-tab");
});
- Symbole, die standardmäßig von Discourse nicht verwendet werden, müssen in der Website-Einstellung
svg icon subsethinzugefügt werden. Lade anschließend den Browserzwischenspeicher neu, um die Änderungen anzuzeigen.
Ergebnis:

Alle „link“-Symbole werden durch „external-link-tab“ ersetzt.
Wenn ein Symbol auf anderen Seiten für mehrere Elemente verwendet wird, wie z. B. bei Abzeichen, wird das Symbol auch dort ersetzt.
Ausnahmen
Beachte, dass es bereits ein Theme-Component gibt, mit dem du das „Gefällt mir“-Symbol ändern kannst. Ich verwende diesen Fall als Beispiel
Das „heart“-Symbol, das zum Liken verwendet wird, ist hartcodiert und hat andere Namen ('d-liked' und 'd-unliked'). Es sollte anders behandelt werden als andere Symbole. Um das
-Symbol durch das
-Symbol zu ändern:
api.replaceIcon("d-liked", "thumbs-up");
api.replaceIcon("d-unliked", "thumbs-o-up");
![]()
![]()
aber auf der Badge-Seite ist das Symbol immer noch ein „heart“:
um es dort zu ändern, fügen wir hinzu:
api.replaceIcon("heart", "thumbs-up");
Ein weiteres Beispiel:
api.replaceIcon("d-watching", "eye");
ändert das „Beobachten“-Symbol:
Siehe hier weitere Ausnahmen, die den Verfolgungsstatus, Expandieren/Kollabieren, Benachrichtigungen und natürlich Likes abdecken.
const REPLACEMENTS = {
"d-tracking": "bell",
"d-muted": "discourse-bell-slash",
"d-regular": "far-bell",
"d-watching": "discourse-bell-exclamation",
"d-watching-first": "discourse-bell-one",
"d-drop-expanded": "caret-down",
"d-drop-collapsed": "caret-right",
"d-unliked": "far-heart",
"d-liked": "heart",
"d-post-share": "link",
"d-topic-share": "link",
"notification.mentioned": "at",
"notification.group_mentioned": "users",
"notification.quoted": "quote-right",
"notification.replied": "reply",
"notification.posted": "reply",
"notification.edited": "pencil-alt",
"notification.bookmark_reminder": "discourse-bookmark-clock",
"notification.liked": "heart",
"notification.liked_2": "heart",
"notification.liked_many": "heart",
"notification.liked_consolidated": "heart",
"notification.private_message": "far-envelope",
"notification.invited_to_private_message": "far-envelope",
"notification.invited_to_topic": "hand-point-right",
"notification.invitee_accepted": "user",
"notification.moved_post": "sign-out-alt",
"notification.linked": "link",
"notification.granted_badge": "certificate",
"notification.topic_reminder": "far-clock",
"notification.watching_first_post": "discourse-bell-one",
"notification.group_message_summary": "users",
"notification.post_approved": "check",
"notification.membership_request_accepted": "user-plus",
"notification.membership_request_consolidated": "users",
"notification.reaction": "bell",
"notification.votes_released": "plus",
"notification.chat_quoted": "quote-right",
};
Ref: discourse/icon-library.ts at main · discourse/discourse (github.com)
Gerne kannst du andere Theme-Components erstellen und sie in unserer Kategorie Theme component teilen!
Dieses Dokument wird versionskontrolliert verwaltet – schlage Änderungen auf GitHub vor.








