/ Book 模式 / 配置 (sena.toml)

在 Book 模式下,sena.toml 是站点唯一需要的配置文件,位于项目根目录。运行 mopress init 时会自动生成一份带有默认值的 sena.toml

sena.toml 使用 TOML 格式编写。以下是本书的完整配置:

title = "MoPress Book"
description = "A modern documentation and static site generator for the MoonBit ecosystem, inspired by mdBook and Hakyll"
keywords = "Documentation,Static Site Generator,SSG,MoonBit,MoonLang,Moon,Functional,Haskell,mdBook,Hakyll"
favicon = "https://himeno-sena.com/favicon.ico"
logo = "https://himeno-sena.com/favicon.ico"
authors = ["Himeno Sena"]
language = "zh"
repository = "https://github.com/biyuehu/mopress"
src = "./"
dest = "./dest"
base-url = "/"

[features]
highlight-enabled = true
highlight-theme = "github"
mathjax-enabled = true

[extensions]
template = "templates/default.html"
assets = [
  "images/**/",
  "styles/**/*",
  "scripts/**/*",
  "plugins/runtime/**/*",
  "index.html",
  "plugins.json",
]
inject-head = []
inject-body = []
use-js = ["console.log('Hello, MoPress!');"]
use-css = []
import-css = []
import-js = ["/plugins/runtime/bili-video.js"]
preprocessors = [
  "bun plugins/preprocessers/github-alert",
  "bun plugins/preprocessers/refer-file",
]
transformers = [
  "bun plugins/transformers/link-checker",
  "bun plugins/transformers/relative2absolute.ts",
]

下表列出了 sena.toml 顶层支持的所有字段。具体定义参考 BookConfig

字段类型说明
titleString站点标题,用于页面 <title>
descriptionString站点简介,用于 <meta name="description"> 元信息
keywordsString站点关键词,用于 <meta name="keywords"> 元信息
faviconStringfavicon 文件路径(相对于站点根目录),用于页面 <link rel="icon">
logoString站点 Logo 文件路径
authorsArray[String]作者列表,渲染时会以逗号拼接
languageString站点主语言,用于 HTML 的 lang 属性
repositoryString?源码仓库地址,若填写会通过 repository 变量暴露给模板
srcString源文件目录,相对于项目根目录
destString构建输出目录,相对于项目根目录
base_urlString基本 URL,用于构建输出的 URL 路径,默认值为 /
[features]FeaturesConfig内置功能开关,详见 功能预设
[extensions]ExtensionsConfig模板、资源注入与插件相关配置,详见 扩展配置

  • [features][extensions] 字段外,均会以不同形式自动注入为模板中的变量,具体行为参考 页面定制

  • srcdest 建议使用相对路径,且不要让两者产生嵌套关系(如 destsrc 的子目录),否则构建时可能会把已生成的输出当作源文件重复处理。

  • [features][extensions] 并非互斥关系:features 中的开关会在配置加载时自动展开(脱糖)为 extension 中的具体字段(如注入对应的 CSS/JS)。也就是说,你既可以只用 features 走“预设”路线,也可以直接在 extension 中手写等效配置,两者最终作用的对象是一致的。详见 功能预设