mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-11-08 14:19:20 +01:00
config: Tweak variable names
This commit is contained in:
parent
4ec169afdc
commit
71931dfa4e
24
config.go
24
config.go
@ -23,16 +23,16 @@ type Config struct {
|
||||
|
||||
// Task represents a site build task.
|
||||
type Task struct {
|
||||
Input string `toml:"input"` // input file extension
|
||||
Output string `toml:"output"` // output file extension
|
||||
Template string `toml:"template"` // template file extension
|
||||
PostProcess string `toml:"postprocess"` // postprocess directive
|
||||
Static string `toml:"static"` // static file directory
|
||||
Destination string `toml:"destination"` // destination directory
|
||||
InputExt string `toml:"input_ext"` // input file extension
|
||||
OutputExt string `toml:"output_ext"` // output file extension
|
||||
TemplateExt string `toml:"template_ext"` // template file extension
|
||||
PostProcess string `toml:"postprocess"` // postprocess command
|
||||
StaticDir string `toml:"static_dir"` // static file directory
|
||||
OutputDir string `toml:"output_dir"` // output directory
|
||||
}
|
||||
|
||||
func (t Task) Format(p *Page) (string, []byte) {
|
||||
path := path.Join(p.Path, "index"+t.Output)
|
||||
path := path.Join(p.Path, "index"+t.OutputExt)
|
||||
|
||||
// Run a custom command.
|
||||
if t.PostProcess != "" {
|
||||
@ -56,11 +56,11 @@ func DefaultConfig() *Config {
|
||||
c.Feeds = make(map[string]string)
|
||||
c.Tasks = make(map[string]*Task)
|
||||
c.Tasks["gemini"] = &Task{
|
||||
Input: ".gmi",
|
||||
Output: ".gmi",
|
||||
Template: ".gmi",
|
||||
Static: "static",
|
||||
Destination: "public",
|
||||
InputExt: ".gmi",
|
||||
OutputExt: ".gmi",
|
||||
TemplateExt: ".gmi",
|
||||
StaticDir: "static",
|
||||
OutputDir: "public",
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
12
main.go
12
main.go
@ -61,9 +61,9 @@ func runAll(cfg *Config) error {
|
||||
func runTask(cfg *Config, task *Task) error {
|
||||
// Load content
|
||||
dir := NewDir("")
|
||||
dir.inputExt = task.Input
|
||||
dir.outputExt = task.Output
|
||||
dir.templateExt = task.Template
|
||||
dir.inputExt = task.InputExt
|
||||
dir.outputExt = task.OutputExt
|
||||
dir.templateExt = task.TemplateExt
|
||||
if err := dir.read("content", ""); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -73,12 +73,12 @@ func runTask(cfg *Config, task *Task) error {
|
||||
return err
|
||||
}
|
||||
// Write content
|
||||
if err := dir.write(task.Destination, task); err != nil {
|
||||
if err := dir.write(task.OutputDir, task); err != nil {
|
||||
return err
|
||||
}
|
||||
// Copy static files
|
||||
if task.Static != "" {
|
||||
err := copyAll(task.Static, task.Destination)
|
||||
if task.StaticDir != "" {
|
||||
err := copyAll(task.StaticDir, task.OutputDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user