Discourse 支持从远程仓库导入包含资源的(theme)主题。
这允许主题作者共享字体和图像。
创建包含字体的新的 git 仓库
mkdir discourse-roboto-theme
cd discourse-roboto-theme
git init .
vim about.json
对于 about.json 添加一个骨架配置文件
{
"name": "Roboto theme component",
"about_url": "",
"license_url": "",
"assets": {
"roboto": "assets/roboto.woff2"
}
}
添加一个 LICENSE 文件,我通常使用 MIT
vim LICENSE
下载字体
http://localfont.com/ 是一个获取字体的便捷网站
mkdir assets
cp ~/Downloads/roboto.woff2 roboto.woff2
添加消耗该主题的 CSS
mkdir common
cd common
创建一个名为 common.scss 的文件,内容如下:
@font-face {
font-family: Roboto;
src: url($roboto) format("woff2");
}
body {
font-family: Roboto;
}
推送更改到 GitHub
检查入所有更改:
git add LICENSE
git add about.json
git add assets/roboto.woff2
git add common/common.scss
git commit -am "first commit"
在 GitHub.com 创建一个账户,然后创建一个新的仓库。
(可选) 在 Discourse 中创建一个主题来讨论你的颜色
理想情况下,您应该在 #plugin:theme 类别中创建一个带有颜色方案截图的主题。您将使用此主题的 URL 作为您的 about_url
填写 about.json 文件中缺失的信息
-
导航到 GitHub 上的 LICENSE 页面,填写该 URL 作为您的
license_url -
使用 GitHub 项目 URL 或 Discourse 主题 URL 作为您的
about_url
在流程结束时,您的 about.json 文件看起来会像这样:
{
"name": "Roboto theme component",
"about_url": "https://github.com/SamSaffron/discourse-roboto-theme",
"license_url": "https://github.com/SamSaffron/discourse-roboto-theme/blob/master/LICENSE",
"assets": {
"roboto": "assets/roboto.woff2"
}
}
检查入更改并推送到 GitHub
git commit -am "added more details"
git push
测试你的字体组件
- 在
admin/customize/theme屏幕中从 GitHub 导入你的主题
![]()
现在你可以轻松共享字体了!
另请参阅:
此文档是版本控制的 - 在 github 上建议更改。

