文档

9 个章节
章节目录 主题开发

主题开发

章节链接

主题使用 theme.json 声明元信息与设置项,后台按字段生成设置页。前台样式 style.css 放在主题目录内,由系统内联注入(与 theme.css 变量一起),主题切换即换全套样式。 主题目录结构:

my-theme/
├─ theme.json     # 元信息与设置项声明
├─ theme.css      # 语义 CSS 变量(颜色/字体)
├─ style.css      # 前台布局样式
├─ header.php     # 头部模板
├─ footer.php     # 底部模板
├─ post.php       # 文章模板
├─ page.php       # 页面模板
└─ assets/        # 静态资源

theme.json 示例:

{
  "name": "My Theme",
  "version": "1.0.0",
  "author": "你的名字",
  "config": [
    { "key": "accent", "label": "主色调", "type": "color", "default": "#0d9488" }
  ]
}

语义 CSS 变量在 theme.css 中定义,模板通过 asset_url() 输出资源路径。第三方主题未提供 style.css 时回退默认主题布局,保证始终有样式。