这需要更多的自定义,因为它在此处的 home-logo 小部件中被阻止:
所以您必须使用 changeWidgetSetting 来设置 URL,然后使用 reopenWidget 来添加 _blank 并覆盖阻止在新窗口中打开的默认单击行为。
<script type="text/discourse-plugin" version="0.8">
const { h } = require("virtual-dom");
api.changeWidgetSetting('home-logo', 'href', 'https://discourse.org');
api.reopenWidget("home-logo", {
html() {
return h(
"a",
{ attributes: { href: this.href(), "data-auto-route": true, "target": "_blank" } },
this.logo()
);
},
click(e) {
return;
},
});
</script>