mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
hugolib: Fix panic for Permalink in 404 etc. templates
This commit is contained in:
parent
ee4a33b14f
commit
0aaf3c56a5
2 changed files with 17 additions and 1 deletions
|
@ -71,7 +71,7 @@ type targetPathDescriptor struct {
|
|||
// and URLs for this Page.
|
||||
func (p *Page) createTargetPathDescriptor(t output.Format) (targetPathDescriptor, error) {
|
||||
if p.targetPathDescriptorPrototype == nil {
|
||||
panic("Must run initTargetPathDescriptor()")
|
||||
panic(fmt.Sprintf("Must run initTargetPathDescriptor() for page %q, kind %q", p.Title, p.Kind))
|
||||
}
|
||||
d := *p.targetPathDescriptorPrototype
|
||||
d.Type = t
|
||||
|
|
|
@ -216,11 +216,16 @@ func (s *Site) render404() error {
|
|||
}
|
||||
|
||||
p := s.newNodePage(kind404)
|
||||
|
||||
p.Title = "404 Page not found"
|
||||
p.Data["Pages"] = s.Pages
|
||||
p.Pages = s.Pages
|
||||
p.URLPath.URL = "404.html"
|
||||
|
||||
if err := p.initTargetPathDescriptor(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nfLayouts := []string{"404.html"}
|
||||
|
||||
return s.renderAndWritePage("404 page", "404.html", p, s.appendThemeTemplates(nfLayouts)...)
|
||||
|
@ -245,6 +250,9 @@ func (s *Site) renderSitemap() error {
|
|||
|
||||
page := s.newNodePage(kindSitemap)
|
||||
page.URLPath.URL = ""
|
||||
if err := page.initTargetPathDescriptor(); err != nil {
|
||||
return err
|
||||
}
|
||||
page.Sitemap.ChangeFreq = sitemapDefault.ChangeFreq
|
||||
page.Sitemap.Priority = sitemapDefault.Priority
|
||||
page.Sitemap.Filename = sitemapDefault.Filename
|
||||
|
@ -252,6 +260,11 @@ func (s *Site) renderSitemap() error {
|
|||
n.Data["Pages"] = pages
|
||||
n.Pages = pages
|
||||
|
||||
// TODO(bep) output
|
||||
if err := page.initTargetPathDescriptor(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(bep) this should be done somewhere else
|
||||
for _, page := range pages {
|
||||
if page.Sitemap.ChangeFreq == "" {
|
||||
|
@ -284,6 +297,9 @@ func (s *Site) renderRobotsTXT() error {
|
|||
}
|
||||
|
||||
n := s.newNodePage(kindRobotsTXT)
|
||||
if err := n.initTargetPathDescriptor(); err != nil {
|
||||
return err
|
||||
}
|
||||
n.Data["Pages"] = s.Pages
|
||||
n.Pages = s.Pages
|
||||
|
||||
|
|
Loading…
Reference in a new issue