Per favore, come potrei inserire un Componente in un particolare widget. Quello che mi interessa è posizionare il componente TopicNotificationsButton nel widget “post-body”.
Apprezzerei immensamente l’assistenza.
Per favore, come potrei inserire un Componente in un particolare widget. Quello che mi interessa è posizionare il componente TopicNotificationsButton nel widget “post-body”.
Apprezzerei immensamente l’assistenza.
Abbiamo uno shim che può farlo… in un tema dovresti aggiungere un file come questo nella directory javascripts/discourse/api-initializers…
import { withPluginApi } from "discourse/lib/plugin-api";
import { registerWidgetShim } from "discourse/widgets/render-glimmer";
import { hbs } from "ember-cli-htmlbars";
export default {
name: "unique-customization-name",
initialize() {
withPluginApi("0.1", (api) => {
api.decorateWidget(`post-body:after`, (decorate) => {
const attrs = decorate.attrs;
return decorate.widget.attach("custom-widget-name", { attrs });
});
registerWidgetShim(
"custom-widget-name",
"div.custom-widget-name",
hbs`<ComponentName @postAttrs={{@data.attrs}} />`
);
});
},
};