Componente di rendering in Widget

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.

2 Mi Piace

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}} />`
      );
    });
  },
};
2 Mi Piace