It is possible, here’s one way to do it.
You’re essentially replacing our default header-buttons widget and moving !attrs.topic. You can add this to a theme in the header section (admin > customize > themes > edit CSS/HTML).
<script type="text/discourse-plugin" version="0.8.13">
api.reopenWidget("header-buttons", {
tagName: "span.header-buttons",
html(attrs) {
if (this.currentUser) {
return;
}
const buttons = [];
if (attrs.canSignUp) {
buttons.push(
this.attach("button", {
label: "sign_up",
className: "btn-primary btn-small sign-up-button",
action: "showCreateAccount"
})
);
}
if (!attrs.topic) {
buttons.push(
this.attach("button", {
label: "log_in",
className: "btn-primary btn-small login-button",
action: "showLogin",
icon: "user"
})
);
}
return buttons;
}
});
</script>