すでに /my/billing/subscriptions が、現在のユーザーを自身のユーザープロフィール(特に Discourse Subscriptions に付属する請求セクション)にリンクする方法であることを理解しています。しかし、以下のコード内の if 文の式では、これが機能していないようです。具体的には、ユーザーの請求ページでのみボタンが表示されるようにしようとしています。実際、/my で始まる URL(billing、preferences、activity など、どのようなものでも)に対して、すべて機能していないように見えます。何か間違えているのでしょうか?何をすべきでしょうか?(ただし、if 文内でのみ機能していない点に注意してください。それ以外では /my を使用することは問題なく機能しています。)
<script type="text/discourse-plugin" version="0.8">
api.registerConnectorClass("above-user-profile", "back-button", {
setupComponent(args, component) {
api.onPageChange((url) => {
if (url === "/my/billing/subscriptions" ){
document.querySelector("html").classList.add("custom-homepage");
component.set("displayCustomHomepage", true);
} else {
document.querySelector("html").classList.remove("custom-homepage");
component.set("displayCustomHomepage", false);
}
});
}
});
</script>
<script type="text/x-handlebars" data-template-name="/connectors/above-user-profile/back-button">
{{#if displayCustomHomepage}}
<a href="https://mathbymiles.com/my/preferences" class="btn btn-default">
<span class="d-button-label">
設定に戻る!
</span>
</a>
{{/if}}
</script>