Documentation
¶
Overview ¶
Package builder 提供编译成 HTML 的相关功能
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBuilding = errors.New("正在编译中")
ErrBuilding 另一个 Rebuild 正在执行
当多次快速调用 Builder.Rebuild 时,可能返回此值, 表示另一个调用还未返回,新的调用又开始。
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { // 源码目录 Src fs.FS // 编译后的输出目录 Dest WritableFS // 在编译过程中的一些提示信息通过此输出 // // 可以为空,表示不输出任意内容。 Info *log.Logger // 是否为预览模式 // // 预览模式下会加载草稿内容。 Preview bool // 如果不空则替换 conf.yaml 中的 url 变量 // // 一般在预览模式下,需要将其替换成本地的地址。 BaseURL string // contains filtered or unexported fields }
Builder 提供了一个可重复生成 HTML 内容的对象
func New
deprecated
type WritableFS ¶
type WritableFS interface { fs.FS // WriteFile 将内容写入文件 // // path 遵守 fs.FS.Open 中有关 path 参数的处理规则。 // 整个函数处理逻辑应该与 os.WriteFile 相同。 // 如果文件父目录不存在,应该要自动创建。 WriteFile(path string, data []byte, perm fs.FileMode) error // Reset 重置内容 // // 该操作会删除通过 WriteFile 添加的文件。 // 原来已经存在的内容,则依然会存在,比如 Dir() 创建的实例, // 就有可能是基于一个已经存在的非空目录,Reset 不应该破坏其原来的结构。 Reset() error }
WritableFS 带有写入功能的文件系统
Notes ¶
Bugs ¶
仅记录了文件,但是并未记录文件的父目录结构。 在 Reset 删除时,可能会留下一堆空目录。
Click to show internal directories.
Click to hide internal directories.