특정 위젯에 컴포넌트를 삽입하는 방법에 대해 조언을 구합니다. 구체적으로는 ‘post-body’ 위젯에 TopicNotificationsButton 컴포넌트를 배치하는 것이 목표입니다.
도와주시면 감사하겠습니다.
특정 위젯에 컴포넌트를 삽입하는 방법에 대해 조언을 구합니다. 구체적으로는 ‘post-body’ 위젯에 TopicNotificationsButton 컴포넌트를 배치하는 것이 목표입니다.
도와주시면 감사하겠습니다.
이 작업을 수행할 수 있는 시ム(Shim)이 있습니다… 테마에서는 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}} />`
);
});
},
};