添加自定义匿名模式按钮

你能告诉我如何像图片中那样移动我的匿名按钮吗?


谢谢

这可以通过使用插件出口并添加一些 Handlebars 来实现(这些概念在 Developing Discourse Themes & Theme Components 中有详细介绍)

在你的主题中(管理 > 自定义 > 主题 > 编辑 CSS/HTML),你可以将此代码添加到你的 <head> 文件中。

<script type="text/x-handlebars" data-template-name="/connectors/above-main-container/anon-button">
{{#if this.currentUser}}
  {{#if this.currentUser.is_anonymous}}
    {{d-button class="btn-primary" action=(route-action 'toggleAnonymous') icon="ban" label="switch_from_anon"}}
  {{else}}
    {{d-button class="btn-primary" action=(route-action 'toggleAnonymous') icon="user-secret" label="switch_to_anon"}}
  {{/if}}
{{/if}}
</script>