diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-13 17:21:42 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-14 19:59:51 +0100 |
commit | 51dd462c3958f7cf032b06503f1f200a6aceebb9 (patch) | |
tree | 6e153b1daa623729a7a469b996b15cf38ac5cf8e /output/docshelper.go | |
parent | b6ea6d07d0b072d850fb066c78976acd6c2f5e81 (diff) |
layout: Respect Type and Layout for list template selection
This commit also has some other nice side-effects:
* The layout logic is unified for all page types, which should make it less surprising
* Page.Render now supports all types
* The legacy "indexes" type is removed from the template lookup order. This is an undocumented type from early Hugo days. This means that having a template in, say, `/layouts/indexes/list.html` will no longer work.
* The theme override logic is improved. As an example, an `index.html` in theme will now wn over a `_default/list.html` in the project, which most will expect.
Fixes #3005
Fixes #3245
Diffstat (limited to 'output/docshelper.go')
-rw-r--r-- | output/docshelper.go | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/output/docshelper.go b/output/docshelper.go index 9ed94b09b..5ccf0f57d 100644 --- a/output/docshelper.go +++ b/output/docshelper.go @@ -37,27 +37,26 @@ func createLayoutExamples() interface{} { ) for _, example := range []struct { - name string - d LayoutDescriptor - hasTheme bool - layoutOverride string - f Format + name string + d LayoutDescriptor + hasTheme bool + f Format }{ - {`AMP home, with theme "demoTheme".`, LayoutDescriptor{Kind: "home"}, true, "", AMPFormat}, - {`AMP home, French language".`, LayoutDescriptor{Kind: "home", Lang: "fr"}, false, "", AMPFormat}, - {"RSS home, no theme.", LayoutDescriptor{Kind: "home"}, false, "", RSSFormat}, - {"JSON home, no theme.", LayoutDescriptor{Kind: "home"}, false, "", JSONFormat}, - {fmt.Sprintf(`CSV regular, "layout: %s" in front matter.`, demoLayout), LayoutDescriptor{Kind: "page", Layout: demoLayout}, false, "", CSVFormat}, - {fmt.Sprintf(`JSON regular, "type: %s" in front matter.`, demoType), LayoutDescriptor{Kind: "page", Type: demoType}, false, "", JSONFormat}, - {"HTML regular.", LayoutDescriptor{Kind: "page"}, false, "", HTMLFormat}, - {"AMP regular.", LayoutDescriptor{Kind: "page"}, false, "", AMPFormat}, - {"Calendar blog section.", LayoutDescriptor{Kind: "section", Section: "blog"}, false, "", CalendarFormat}, - {"Calendar taxonomy list.", LayoutDescriptor{Kind: "taxonomy", Section: "tag"}, false, "", CalendarFormat}, - {"Calendar taxonomy term.", LayoutDescriptor{Kind: "taxonomyTerm", Section: "tag"}, false, "", CalendarFormat}, + {`AMP home, with theme "demoTheme".`, LayoutDescriptor{Kind: "home"}, true, AMPFormat}, + {`AMP home, French language".`, LayoutDescriptor{Kind: "home", Lang: "fr"}, false, AMPFormat}, + {"RSS home, no theme.", LayoutDescriptor{Kind: "home"}, false, RSSFormat}, + {"JSON home, no theme.", LayoutDescriptor{Kind: "home"}, false, JSONFormat}, + {fmt.Sprintf(`CSV regular, "layout: %s" in front matter.`, demoLayout), LayoutDescriptor{Kind: "page", Layout: demoLayout}, false, CSVFormat}, + {fmt.Sprintf(`JSON regular, "type: %s" in front matter.`, demoType), LayoutDescriptor{Kind: "page", Type: demoType}, false, JSONFormat}, + {"HTML regular.", LayoutDescriptor{Kind: "page"}, false, HTMLFormat}, + {"AMP regular.", LayoutDescriptor{Kind: "page"}, false, AMPFormat}, + {"Calendar blog section.", LayoutDescriptor{Kind: "section", Section: "blog"}, false, CalendarFormat}, + {"Calendar taxonomy list.", LayoutDescriptor{Kind: "taxonomy", Section: "tag"}, false, CalendarFormat}, + {"Calendar taxonomy term.", LayoutDescriptor{Kind: "taxonomyTerm", Section: "tag"}, false, CalendarFormat}, } { l := NewLayoutHandler(example.hasTheme) - layouts, _ := l.For(example.d, example.layoutOverride, example.f) + layouts, _ := l.For(example.d, example.f) basicExamples = append(basicExamples, Example{ Example: example.name, |