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 导入你的主题
![]()
你现在可以轻松分享字体了!
另请参阅:
本文档受版本控制 - 请在 GitHub 上建议更改。

