node to page: Basic outline

Updates #2297
This commit is contained in:
Bjørn Erik Pedersen
2016-10-30 17:59:24 +01:00
parent e7d0bc8a74
commit e371ac0b6f
8 changed files with 185 additions and 17 deletions

View File

@@ -182,14 +182,6 @@ func (p *Page) initPlainWords() {
})
}
func (p *Page) IsNode() bool {
return false
}
func (p *Page) IsPage() bool {
return true
}
// Param is a convenience method to do lookups in Page's and Site's Params map,
// in that order.
//
@@ -423,7 +415,7 @@ func (p *Page) getRenderingConfig() *helpers.Blackfriday {
func newPage(filename string) *Page {
page := Page{contentType: "",
Source: Source{File: *source.NewFile(filename)},
Node: Node{Keywords: []string{}, Sitemap: Sitemap{Priority: -1}},
Node: Node{NodeType: nodeTypeFromFilename(filename), Keywords: []string{}, Sitemap: Sitemap{Priority: -1}},
Params: make(map[string]interface{}),
translations: make(Pages, 0),
}
@@ -457,6 +449,11 @@ func (p *Page) layouts(l ...string) []string {
return p.layoutsCalculated
}
// TODO(bep) np
if p.NodeType == NodeHome {
return []string{"index.html", "_default/list.html"}
}
if p.Layout != "" {
return layouts(p.Type(), p.Layout)
}
@@ -1136,6 +1133,10 @@ func (p *Page) FullFilePath() string {
}
func (p *Page) TargetPath() (outfile string) {
// TODO(bep) ml
if p.NodeType == NodeHome {
return "index.html"
}
// Always use URL if it's specified
if len(strings.TrimSpace(p.URLPath.URL)) > 2 {
outfile = strings.TrimSpace(p.URLPath.URL)