diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-07-17 23:20:13 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-07-17 23:20:13 +0200 |
commit | deccc54004cbe88ddbf8f3f951d3178dc0693189 (patch) | |
tree | b2f0ee2079cd5cb731bb540dc3bf526f3f4e5a94 /hugolib/page.go | |
parent | 00b590d7ab4f3021814acceaf74c4eaf64edb226 (diff) |
hubolib: Add HasShortcode
Fixes #3707
Diffstat (limited to 'hugolib/page.go')
-rw-r--r-- | hugolib/page.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index 0f44b8b99..9937be325 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -791,6 +791,17 @@ func (p *Page) Extension() string { return p.extension } +// HasShortcode return whether the page has a shortcode with the given name. +// This method is mainly motivated with the Hugo Docs site's need for a list +// of pages with the `todo` shortcode in it. +func (p *Page) HasShortcode(name string) bool { + if p.shortcodeState == nil { + return false + } + + return p.shortcodeState.nameSet[name] +} + // AllTranslations returns all translations, including the current Page. func (p *Page) AllTranslations() Pages { return p.translations |