mirror of https://github.com/halo-dev/halo
![]() #### What type of PR is this? /kind feature /milestone 2.0 /area core #### What this PR does / why we need it: 文章/自定义页面/分类支持通过主题配置多套渲染模板 首先需要在 theme.yaml 中声明模板,以文章为例: ```yaml apiVersion: theme.halo.run/v1alpha1 kind: Theme metadata: name: fake-theme-name spec: # ... customTemplates: # 支持通过以下形式配置 post, category, page post: - name: 新闻 description: 新闻类型的文章模板 screenshot: foo.png # file 路径相对于主题目录的 templates 目录,.html 后缀可以带也可以省略 # 默认 thymeleaf 查找 html 文件,除非修改了 thymeleaf suffix 配置 file: post_news.html ``` 当文章页选择模板时便可得到下拉列表以配置使用哪个模板 see https://github.com/halo-dev/halo/issues/2322#issuecomment-1215135195 选择了模板之后将模板名存储到 post 的 spec.template 中,渲染时便会首先使用 spec.template,如果该模板不存在则渲染默认模板 #### Which issue(s) this PR fixes: Fixes #2569 #### Special notes for your reviewer: how to test it? 1. 创建一篇文章并发布 2. 安装一个主题并查看文章详情,默认渲染主题提供的 post.html 页面 3. 修改此文章的 spec.template 字段为一个新的 html 例如 spec.template=post_docs 4. 查看该文章的详情页会渲染为 post_docs.html 5. 分类、自定义页面亦如是 /cc @halo-dev/sig-halo #### Does this PR introduce a user-facing change? ```release-note 文章/自定义页面/分类支持通过主题配置多套渲染模板 ``` |
||
---|---|---|
.github | ||
config/checkstyle | ||
docs | ||
gradle/wrapper | ||
hack | ||
src | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
Dockerfile | ||
LICENSE | ||
OWNERS | ||
README.md | ||
SECURITY.md | ||
build.gradle | ||
gradle.properties | ||
gradlew | ||
gradlew.bat | ||
settings.gradle |
README.md
Halo [ˈheɪloʊ],一款现代化的开源博客/CMS系统,值得一试。
官网
文档(2.0 Alpha)
社区
Gitee
Telegram 频道
注意
当前分支为 Halo 2.0 的开发分支,目前 Halo 2.0 处于 Alpha 测试阶段,无法从 1.5 直接升级,也不建议在生产环境使用。稳定版本(Halo 1.x)请查阅以下地址:
- 1.5 分支:https://github.com/halo-dev/halo/tree/release-1.5
- 1.6 分支:https://github.com/halo-dev/halo/tree/release-1.6
- 1.5 文档:https://docs.halo.run
快速开始
Docker
docker run -it -d --name halo-next -p 8090:8090 -v ~/halo-next:/root/halo-next --restart=unless-stopped halohub/halo-dev:2.0.0-alpha.3
详细部署文档请查阅:https://docs.halo.run/2.0.0-SNAPSHOT/getting-started/install/docker
在线体验
- 环境地址:https://demo.halo.run
- 后台地址:https://demo.halo.run/console
- 用户名:
demo
- 密码:
P@ssw0rd123..
生态
可访问 awesome-halo 查看已经适用于 Halo 2.0 的主题和插件,以及适用于 Halo 1.x 的相关仓库。
许可证
Halo 使用 GPL-v3.0 协议开源,请遵守开源协议。
贡献
参考 CONTRIBUTING。