mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
hugolib: Handle shortcode per output format
This commit allows shortcode per output format, a typical use case would be the special AMP media tags. Note that this will only re-render the "overridden" shortcodes and only in pages where these are used, so performance in the normal case should not suffer. Closes #3220
This commit is contained in:
@@ -1257,6 +1257,11 @@ func (p *Page) Menus() PageMenus {
|
||||
return p.pageMenus
|
||||
}
|
||||
|
||||
func (p *Page) shouldRenderTo(f output.Format) bool {
|
||||
_, found := p.outputFormats.GetByName(f.Name)
|
||||
return found
|
||||
}
|
||||
|
||||
func (p *Page) determineMarkupType() string {
|
||||
// Try markup explicitly set in the frontmatter
|
||||
p.Markup = helpers.GuessType(p.Markup)
|
||||
@@ -1372,8 +1377,8 @@ func (p *Page) SaveSource() error {
|
||||
}
|
||||
|
||||
func (p *Page) processShortcodes() error {
|
||||
p.shortcodeState = newShortcodeHandler()
|
||||
tmpContent, err := p.shortcodeState.extractAndRenderShortcodes(string(p.workContent), p)
|
||||
p.shortcodeState = newShortcodeHandler(p)
|
||||
tmpContent, err := p.shortcodeState.extractShortcodes(string(p.workContent), p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user