Discourse 支持从远程仓库导入包含资源的主题。
这使得主题作者可以分享字体和图片。
创建包含字体的新 git 仓库
mkdir discourse-roboto-theme
cd discourse-roboto-theme
git init .
vim about.json
为 about.json 添加一个骨架配置文件
{
"name": "Roboto 主题组件",
"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 "首次提交"
在 GitHub.com 上创建一个账户,然后创建一个新的仓库。
(可选)在 Discourse 上创建一个主题作为讨论你配色的主页
理想情况下,你应在 Customization > Theme 分类下创建一个主题,并附上一些配色方案的截图。你将把这个链接用作你的 about_url
填写 about.json 文件中缺失的信息
-
导航到 GitHub 上的 LICENSE 页面,将该 URL 填入
license_url -
使用 GitHub 项目 URL 或 Discourse 主题 URL 作为你的
about_url
整个过程结束后,你的 about.json 文件看起来应该像这样:
{
"name": "Roboto 主题组件",
"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 "添加更多详细信息"
git push
测试你的字体组件
- 在
admin/customize/theme界面中,从 GitHub 导入你的主题
![]()
现在你可以轻松地分享字体了!
另请参阅:
本文档受版本控制 - 建议修改 on github。

