config: Tweak variable names

This commit is contained in:
adnano 2021-04-11 18:42:55 -04:00
parent 4ec169afdc
commit 71931dfa4e
2 changed files with 18 additions and 18 deletions

View file

@ -23,16 +23,16 @@ type Config struct {
// Task represents a site build task. // Task represents a site build task.
type Task struct { type Task struct {
Input string `toml:"input"` // input file extension InputExt string `toml:"input_ext"` // input file extension
Output string `toml:"output"` // output file extension OutputExt string `toml:"output_ext"` // output file extension
Template string `toml:"template"` // template file extension TemplateExt string `toml:"template_ext"` // template file extension
PostProcess string `toml:"postprocess"` // postprocess directive PostProcess string `toml:"postprocess"` // postprocess command
Static string `toml:"static"` // static file directory StaticDir string `toml:"static_dir"` // static file directory
Destination string `toml:"destination"` // destination directory OutputDir string `toml:"output_dir"` // output directory
} }
func (t Task) Format(p *Page) (string, []byte) { 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. // Run a custom command.
if t.PostProcess != "" { if t.PostProcess != "" {
@ -56,11 +56,11 @@ func DefaultConfig() *Config {
c.Feeds = make(map[string]string) c.Feeds = make(map[string]string)
c.Tasks = make(map[string]*Task) c.Tasks = make(map[string]*Task)
c.Tasks["gemini"] = &Task{ c.Tasks["gemini"] = &Task{
Input: ".gmi", InputExt: ".gmi",
Output: ".gmi", OutputExt: ".gmi",
Template: ".gmi", TemplateExt: ".gmi",
Static: "static", StaticDir: "static",
Destination: "public", OutputDir: "public",
} }
return c return c
} }

12
main.go
View file

@ -61,9 +61,9 @@ func runAll(cfg *Config) error {
func runTask(cfg *Config, task *Task) error { func runTask(cfg *Config, task *Task) error {
// Load content // Load content
dir := NewDir("") dir := NewDir("")
dir.inputExt = task.Input dir.inputExt = task.InputExt
dir.outputExt = task.Output dir.outputExt = task.OutputExt
dir.templateExt = task.Template dir.templateExt = task.TemplateExt
if err := dir.read("content", ""); err != nil { if err := dir.read("content", ""); err != nil {
return err return err
} }
@ -73,12 +73,12 @@ func runTask(cfg *Config, task *Task) error {
return err return err
} }
// Write content // Write content
if err := dir.write(task.Destination, task); err != nil { if err := dir.write(task.OutputDir, task); err != nil {
return err return err
} }
// Copy static files // Copy static files
if task.Static != "" { if task.StaticDir != "" {
err := copyAll(task.Static, task.Destination) err := copyAll(task.StaticDir, task.OutputDir)
if err != nil { if err != nil {
return err return err
} }