HugoBlox / hugo-blox-builder

🚨 GROW YOUR AUDIENCE WITH HUGOBLOX! 🚀 HugoBlox is an easy, fast no-code website builder for researchers, entrepreneurs, data scientists, and developers. Build stunning sites in minutes. 适合研究人员、企业家、数据科学家和开发者的简单快速无代码网站构建器。用拖放功能、可定制模板和内置SEO工具快速创建精美网站!
https://hugoblox.com/templates/
MIT License
8.2k stars 2.9k forks source link

Add a spoiler (collapsable content) shortcode implementation #1712

Closed kortschak closed 4 years ago

kortschak commented 4 years ago

Feature Request

Is your feature request related to a problem? Please describe. In course material it can be helpful to have hidden answers (not to prevent students from getting them, but to prevent them seeing them without even trying).

Describe the solution you'd like Add a way to have mouse-over or click to see spoiler text.

Describe alternatives you've considered There is no reasonable alternative to this that does not cause students to navigate away to another page, losing flow.

gcushen commented 4 years ago

Notes

Shortcode name

Any ideas for a generalised shortcode name?

Ideas include:

kortschak commented 4 years ago

I'd suggest "spoiler" as the most commonly used names. This would make it the most discoverable.

gcushen commented 4 years ago

Documentation

To use:

{{< spoiler text="Click to view the spoiler" >}} You found me! {{< /spoiler >}}

Demo:

https://academic-demo.netlify.app/post/writing-technical-content/

kortschak commented 4 years ago

When I run ./update_academic.sh after this, hugo fails. I was previously using a fork from sourcethemes/academic-kickstart@018be3bb4030ac9262521398714c379476007f75 (so 4.9, same minor version) and I don't see any notes in the update pages. Can you point me to why this has broken?

$ hugo server -w
Building sites … ERROR 2020/05/29 07:27:51 render of "page" failed: execute of template failed: template: docs/single.html:2:3: executing "main" at <partial "docs_layout.html" .>: error calling partial: execute of template failed: template: partials/docs_layout.html:48:13: executing "partials/docs_layout.html" at <partial "page_related" .>: error calling partial: "/home/user/Development/kortschak.io/themes/academic/layouts/partials/page_related.html:1:7": execute of template failed: template: partials/page_related.html:1:7: executing "partials/page_related.html" at <index site.Params.show_related .Type>: error calling index: index of untyped nil
ERROR 2020/05/29 07:27:51 render of "page" failed: execute of template failed: template: docs/single.html:2:3: executing "main" at <partial "docs_layout.html" .>: error calling partial: execute of template failed: template: partials/docs_layout.html:48:13: executing "partials/docs_layout.html" at <partial "page_related" .>: error calling partial: "/home/user/Development/kortschak.io/themes/academic/layouts/partials/page_related.html:1:7": execute of template failed: template: partials/page_related.html:1:7: executing "partials/page_related.html" at <index site.Params.show_related .Type>: error calling index: index of untyped nil
ERROR 2020/05/29 07:27:51 render of "page" failed: execute of template failed: template: docs/single.html:2:3: executing "main" at <partial "docs_layout.html" .>: error calling partial: execute of template failed: template: partials/docs_layout.html:48:13: executing "partials/docs_layout.html" at <partial "page_related" .>: error calling partial: "/home/user/Development/kortschak.io/themes/academic/layouts/partials/page_related.html:1:7": execute of template failed: template: partials/page_related.html:1:7: executing "partials/page_related.html" at <index site.Params.show_related .Type>: error calling index: index of untyped nil
ERROR 2020/05/29 07:27:51 render of "page" failed: execute of template failed: template: docs/single.html:2:3: executing "main" at <partial "docs_layout.html" .>: error calling partial: execute of template failed: template: partials/docs_layout.html:48:13: executing "partials/docs_layout.html" at <partial "page_related" .>: error calling partial: "/home/user/Development/kortschak.io/themes/academic/layouts/partials/page_related.html:1:7": execute of template failed: template: partials/page_related.html:1:7: executing "partials/page_related.html" at <index site.Params.show_related .Type>: error calling index: index of untyped nil
Built in 458 ms
Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: docs/single.html:2:3: executing "main" at <partial "docs_layout.html" .>: error calling partial: execute of template failed: template: partials/docs_layout.html:48:13: executing "partials/docs_layout.html" at <partial "page_related" .>: error calling partial: "/home/user/Development/kortschak.io/themes/academic/layouts/partials/page_related.html:1:7": execute of template failed: template: partials/page_related.html:1:7: executing "partials/page_related.html" at <index site.Params.show_related .Type>: error calling index: index of untyped nil
kortschak commented 4 years ago

Breakage cause by gcushen/hugo-academic@9e562fc076bf8869d6c513d34f7e120dedb63193.

kortschak commented 4 years ago

Fix is to add the show_related attribute to params.toml. Perhaps this value could be nil-guarded in the template to avoid this.