本主题将引导您了解如何使用 Theme CLI 和我们的 Theme Creator 站点来开发主题并在实时 Discourse 站点上预览您的更改。
如果您还没有帐户,请在此处注册 Meta 帐户
登录 Theme Creator
通过此处说明 安装 Theme CLI
通过以下步骤在 Theme Creator 上创建新主题:
点击 advanced ,然后点击 edit locally ,最后点击 retrieve API key 。
复制生成的 API 密钥。
返回命令行并输入 discourse_theme download example-folder,其中 example-folder 是您本地存储主题的目录。按照提示操作。
现在您的本地主题文件夹正在被监视更改,这些更改将自动上传到 Theme Creator。您可以通过点击 Theme Creator 上主题设置中的 preview 来打开主题的预览。
要停止监视更改,请在命令行窗口中按 ctrl + c 。要再次开始监视更改,请键入 discourse_theme watch example-theme。
现在您有了一个本地主题目录,可以对其进行编辑并实时查看更改!
要深入了解主题的结构以及您可以进行的操作,请查看我们的 Developing Discourse Themes & Theme Components
此文档是版本控制的 - 请在 github 上建议更改。
42 个赞
你好。我正在尝试遵循这些说明,但一直遇到障碍。添加 API 密钥后,我看到以下内容:
/usr/local/lib/ruby/gems/3.2.0/gems/discourse_theme-0.7.3/lib/discourse_theme/cli.rb:100:in `run': undefined method `exists?' for Dir:Class (NoMethodError)
FileUtils.mkdir_p dir unless Dir.exists?(dir)
^^^^^^^
Did you mean? exist?
from /usr/local/lib/ruby/gems/3.2.0/gems/discourse_theme-0.7.3/bin/discourse_theme:6:in `<top (required)>'
from /usr/local/lib/ruby/gems/3.2.0/bin/discourse_theme:25:in `load'
from /usr/local/lib/ruby/gems/3.2.0/bin/discourse_theme:25:in `<main>'
知道为什么吗?
提前感谢。
1 个赞
leonardo
(Leonardo Mosquera)
2023 年1 月 24 日 21:47
21
您好!
此工具尚不支持 Ruby 3.2,因为语言已发生更改。我们正在开发修复程序,但在此期间 Ruby 3.1.x 可以正常工作。
6 个赞
leonardo
(Leonardo Mosquera)
2023 年1 月 25 日 20:03
23
这现在已修复 - discourse_theme 在 Ruby 3.2.x 上从 gem 版本 0.7.4 开始应该可以正常工作
3 个赞
哇,真快
谢谢。在我的直线经理的帮助下,我确实设法让它工作了,他建议:
rbenv install 3.1.3
rbenv shell 3.1.3
gem install discourse_theme
实际上,直到我关闭终端标签页并重新打开它,它才起作用。
discourse_theme watch 不再实时重新加载了吗?它以前在我保存主题时会刷新我的主题,但现在我必须手动刷新我的标签页。控制台中没有任何迹象表明原因。
1 个赞
Moin
2026 年1 月 27 日 08:38
26
一段时间前有一次更改
Live reloads of stylesheets have been disabled for production instances , because they were causing problems when updating themes and/or Discourse core.
Fundamentally: stylesheet changes are often tied to changes in JS/HTML, so live-loading for only stylesheets is risky. Users end up running ‘new’ stylesheets against ‘old’ HTML, which can lead to some very strange experiences.
Live-loading is still enabled for development-mode Discourse instances. Ideally, you’d use that for development rather …
你可能对这个感兴趣 Live Reload in Production
4 个赞