feat: detect Mermaid on nested headless pages

See #2643
This commit is contained in:
Geo 2022-03-22 21:27:41 +00:00
commit cc5708bb9c
3 changed files with 14 additions and 2 deletions

View file

@ -25,7 +25,7 @@
- 🙋‍♀️ **Have a question?**
- **Chat with us now on [Discord](https://discord.gg/z8wNYzb)** or explore the [Troubleshooting Guide]() and [Q&A Forum](https://github.com/wowchemy/wowchemy-hugo-themes/discussions)
- _Also, check out [Hugo Forum](https://discourse.gohugo.io) for Hugo Qs and [Netlify Forum](https://answers.netlify.com/) for Netlify Qs_
- 🐦 Share your Wowchemy site with the community on Twitter: [@wowchemy](https://twitter.com/wowchemy) [@GeorgeCushen](https://twitter.com/GeorgeCushen) [#MadeWithWowchemy](https://twitter.com/search?q=(%23MadeWithWowchemy%20OR%20%23MadeWithAcademic)&src=typed_query)
- 🐦 Share your Wowchemy site with the community on Twitter: [@wowchemy](https://twitter.com/wowchemy) [@GeorgeCushen](https://twitter.com/GeorgeCushen) [#MadeWithWowchemy](https://twitter.com/search?q=%23MadeWithWowchemy&src=typed_query)
- 🗳 [Take the survey and help us improve #OpenSource](https://forms.gle/NioD9VhUg7PNmdCAA)
- ⬆️ **Updating?** View the [Update Guide](https://wowchemy.com/docs/hugo-tutorials/update/) and [Release Notes](https://github.com/wowchemy/wowchemy-hugo-themes/releases)
- 🚀 [Contribute improvements](./.github/contributing.md) or [suggest improvements](https://github.com/wowchemy/wowchemy-hugo-themes/issues)

View file

@ -40,6 +40,7 @@
"lint:js:fix": "eslint '*/**/*.{js,ts,tsx}' --fix",
"lint:style": "stylelint '*/**/*.{css,scss}'",
"format": "prettier --write \"*.{css,js,json,md,scss}\" \"./**/*.{css,js,json,md,scss}\"",
"stylelint-conflict-check": "stylelint-config-prettier-check"
"stylelint-conflict-check": "stylelint-config-prettier-check",
"update:starters": "hugo mod get -u ./..."
}
}

View file

@ -26,7 +26,12 @@
{{ end }}
{{/* Load page sections */}}
{{ $has_mermaid := false }}
{{ range $index, $st := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }}
{{ if .Page.Store.Get "has_mermaid" }}
{{ $has_mermaid = true }}
{{ end }}
{{/* Begin widget styling */}}
{{ $bg := $st.Params.design.background }}
{{ $style := "" }}
@ -152,3 +157,9 @@
{{if $use_container}}</div>{{end}}
</section>
{{ end }}
{{/* Workaround to make Hugo's .Page.Store.Set cascade up to the parent of headless pages */}}
{{ if $has_mermaid }}
{{ .Page.Store.Set "has_mermaid" true }}
{{ end }}