diff --git a/config.toml b/config.toml index 712f998..8009d33 100644 --- a/config.toml +++ b/config.toml @@ -4,6 +4,7 @@ title = "Example website" "/" = "/{{ .Date.Format `2006/01/02` }}/{{ path.Base .Path }}/" [[tasks]] +name = "Gemini" url = "gemini://example.com" input = [".gmi"] output = ".gmi" diff --git a/docs/kiln.1.scd b/docs/kiln.1.scd index e135268..97006b6 100644 --- a/docs/kiln.1.scd +++ b/docs/kiln.1.scd @@ -120,6 +120,22 @@ The following keys are supported: --- ``` +*outputs* + Optionally specifies a list of tasks that can build this page. Defaults to + all tasks. + + Example: + + ``` + --- + outputs: ["Gemini", "HTTPS"] + --- + + --- + outputs: [] # Excluded from all tasks + --- + ``` + *params* Specifies extra parameters to be provided to templates. @@ -211,6 +227,19 @@ Tasks can be specified in the [[tasks]] array of tables. The following configuration options are supported per task: +*name* + An optional name for the task. + + Example: + + ``` + [[tasks]] + name = "Gemini" + + [[tasks]] + name = "HTML export" + ``` + *input* A list of input file extensions. Files in the content directory with a matching extension will be processed. diff --git a/page.go b/page.go index aa63d2c..9a9084f 100644 --- a/page.go +++ b/page.go @@ -18,18 +18,19 @@ import ( // Page represents a page. type Page struct { - Title string - Date time.Time - Weight int - Params map[string]interface{} - Path string `yaml:"-"` - FilePath string `yaml:"-"` - URL string `yaml:"-"` - Content string `yaml:"-"` - Prev *Page `yaml:"-"` - Next *Page `yaml:"-"` - Pages []*Page `yaml:"-"` - Dirs []*Page `yaml:"-"` + Title string `yaml:"title"` + Date time.Time `yaml:"date"` + Weight int `yaml:"weight"` + Outputs []string `yaml:"outputs"` + Params map[string]interface{} `yaml:"params"` + Path string `yaml:"-"` + FilePath string `yaml:"-"` + URL string `yaml:"-"` + Content string `yaml:"-"` + Prev *Page `yaml:"-"` + Next *Page `yaml:"-"` + Pages []*Page `yaml:"-"` + Dirs []*Page `yaml:"-"` feeds map[string][]byte index bool } @@ -113,6 +114,21 @@ func (p *Page) _read(fsys fs.FS, path string, task *Task, cfg *Site) error { if len(frontmatter) != 0 { if err := yaml.Unmarshal(frontmatter, page); err != nil { log.Printf("failed to parse frontmatter for %q: %v", path, err) + } else if page.Outputs != nil { + // Enforce page outputs + if len(page.Outputs) == 0 || task.Name == "" { + continue + } + found := false + for _, output := range page.Outputs { + if output == task.Name { + found = true + break + } + } + if !found { + continue + } } // Trim leading newlines from content diff --git a/site.go b/site.go index 0b234ec..c5d5d1d 100644 --- a/site.go +++ b/site.go @@ -25,6 +25,7 @@ type Site struct { // Task represents a site build task. type Task struct { + Name string `toml:"name"` Input []string `toml:"input"` OutputExt string `toml:"output"` TemplateExt string `toml:"template"`