I must be doing something very stupid, but I’m incapable of seeing it. I’m hoping that posting here will make me see it so I can delete this before anyone else knows how stupid I am.
“HELLO WORLD” should be rendering on the home page. I see “THIS IS THE HOMEPAGE” in the console. I know it’s firing. But it’s not there.
Then I tried adding “Extra item” because I didn’t have any other ideas. It’s not rendering either.
I did get errors before I renamed the file to .gjs
, so that’s further evidence that it’s paying attention to the file and it’s making something happen.
import { apiInitializer } from "discourse/lib/api";
export default apiInitializer("1.8.0", (api) => {
// see if we're on the home page
api.onPageChange(() => {
const router = api.container.lookup("service:router");
const url = router?.currentURL;
const isHomePage = url === "/";
api.renderInOutlet("top-notices", <template>Extra item</template>);
if (isHomePage) {
console.log("THIS IS THE HOMEPAGE");
api.renderInOutlet("after-header", <template>HELLO WORLD</template>);
}
});
});