mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
hugolib, output: Restrict Render to regular Pages
Using it for list pages doesn't work and has potential weird side-effects. The user probably meant to range over .Site.ReqularPages, and that is now marked clearly in the log.
This commit is contained in:
@@ -83,19 +83,23 @@ indexes/indexes.NAME.SUFFIX indexes/indexes.SUFFIX
|
||||
`
|
||||
)
|
||||
|
||||
func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format) []string {
|
||||
func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format) ([]string, error) {
|
||||
|
||||
// We will get lots of requests for the same layouts, so avoid recalculations.
|
||||
key := layoutCacheKey{d, layoutOverride, f}
|
||||
l.mu.RLock()
|
||||
if cacheVal, found := l.cache[key]; found {
|
||||
l.mu.RUnlock()
|
||||
return cacheVal
|
||||
return cacheVal, nil
|
||||
}
|
||||
l.mu.RUnlock()
|
||||
|
||||
var layouts []string
|
||||
|
||||
if layoutOverride != "" && d.Kind != "page" {
|
||||
return layouts, fmt.Errorf("Custom layout (%q) only supported for regular pages, not kind %q", layoutOverride, d.Kind)
|
||||
}
|
||||
|
||||
layout := d.Layout
|
||||
|
||||
if layoutOverride != "" {
|
||||
@@ -106,7 +110,7 @@ func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format)
|
||||
|
||||
if d.Kind == "page" {
|
||||
if isRSS {
|
||||
return []string{}
|
||||
return []string{}, nil
|
||||
}
|
||||
layouts = regularPageLayouts(d.Type, layout, f)
|
||||
} else {
|
||||
@@ -148,14 +152,14 @@ func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format)
|
||||
}
|
||||
}
|
||||
|
||||
return layoutsWithThemeLayouts
|
||||
return layoutsWithThemeLayouts, nil
|
||||
}
|
||||
|
||||
l.mu.Lock()
|
||||
l.cache[key] = layouts
|
||||
l.mu.Unlock()
|
||||
|
||||
return layouts
|
||||
return layouts, nil
|
||||
}
|
||||
|
||||
func resolveListTemplate(d LayoutDescriptor, f Format,
|
||||
|
Reference in New Issue
Block a user