summaryrefslogtreecommitdiffhomepage
path: root/resources/page/pagemeta/pagemeta.go
diff options
context:
space:
mode:
Diffstat (limited to 'resources/page/pagemeta/pagemeta.go')
-rw-r--r--resources/page/pagemeta/pagemeta.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/resources/page/pagemeta/pagemeta.go b/resources/page/pagemeta/pagemeta.go
index 07e5c5673..1f8afdc18 100644
--- a/resources/page/pagemeta/pagemeta.go
+++ b/resources/page/pagemeta/pagemeta.go
@@ -13,9 +13,59 @@
package pagemeta
+import (
+ "github.com/mitchellh/mapstructure"
+)
+
type URLPath struct {
URL string
Permalink string
Slug string
Section string
}
+
+var defaultBuildConfig = BuildConfig{
+ List: true,
+ Render: true,
+ PublishResources: true,
+ set: true,
+}
+
+// BuildConfig holds configuration options about how to handle a Page in Hugo's
+// build process.
+type BuildConfig struct {
+ // Whether to add it to any of the page collections.
+ // Note that the page can still be found with .Site.GetPage.
+ List bool
+
+ // Whether to render it.
+ Render bool
+
+ // Whether to publish its resources. These will still be published on demand,
+ // but enabling this can be useful if the originals (e.g. images) are
+ // never used.
+ PublishResources bool
+
+ set bool // BuildCfg is non-zero if this is set to true.
+}
+
+// Disable sets all options to their off value.
+func (b *BuildConfig) Disable() {
+ b.List = false
+ b.Render = false
+ b.PublishResources = false
+ b.set = true
+}
+
+func (b BuildConfig) IsZero() bool {
+ return !b.set
+}
+
+func DecodeBuildConfig(m interface{}) (BuildConfig, error) {
+ b := defaultBuildConfig
+ if m == nil {
+ return b, nil
+ }
+ err := mapstructure.WeakDecode(m, &b)
+ return b, err
+}