topbar: improve print button configuration #978

This commit is contained in:
Sören Weber 2024-12-31 14:11:49 +01:00
parent d9152f9aba
commit 2cd8baa02f
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
8 changed files with 32 additions and 10 deletions

View file

@ -135,6 +135,12 @@ disableToc = false
# shown in the topbar. # shown in the topbar.
disableBreadcrumb = false disableBreadcrumb = false
# Hide the print button.
# Default: false
# This hides the print button if you activated the print output format.
# This can be overridden in the page's frontmatter.
disablePrintButton = false
# Hide Next and Previous navigation buttons. # Hide Next and Previous navigation buttons.
# Default: false # Default: false
# If the navigation buttons are hidden, also the keyboard shortcuts are # If the navigation buttons are hidden, also the keyboard shortcuts are

View file

@ -52,6 +52,12 @@ disableToc = false
# shown in the topbar. # shown in the topbar.
disableBreadcrumb = false disableBreadcrumb = false
# Hide the print button.
# Default: false
# This hides the print button if you activated the print output format.
# If not set, the set value of your site's hugo.toml is used.
disablePrintButton = false
# Hide Next and Previous navigation buttons. # Hide Next and Previous navigation buttons.
# Default: false # Default: false
# If the navigation buttons are hidden, also the keyboard shortcuts are # If the navigation buttons are hidden, also the keyboard shortcuts are

View file

@ -1,8 +1,8 @@
+++ +++
categories = ["howto"] categories = ["howto"]
description = "Configure the topbar" description = "Configure the topbar"
frontmatter = ["disableBreadcrumb", "disableNextPrev", "disableToc", "editURL"] frontmatter = ["disableBreadcrumb", "disableNextPrev", "disablePrintButton", "disableToc", "editURL"]
options = ["disableBreadcrumb", "disableNextPrev", "disableToc", "editURL"] options = ["disableBreadcrumb", "disableNextPrev", "disablePrintButton", "disableToc", "editURL"]
title = "Topbar" title = "Topbar"
weight = 4 weight = 4
+++ +++
@ -15,7 +15,7 @@ Your topbar contains the following elements. Some of them are configuarable:
- {{% button style="transparent" icon="list-alt" %}}{{% /button %}} **toc**: [opens the table of contents in an overlay](#table-of-contents) - {{% button style="transparent" icon="list-alt" %}}{{% /button %}} **toc**: [opens the table of contents in an overlay](#table-of-contents)
- {{% button style="transparent" icon="empty" %}}{{% /button %}} **breadcrumb**: shows the clickable [breadcrumbs](#breadcrumbs) - {{% button style="transparent" icon="empty" %}}{{% /button %}} **breadcrumb**: shows the clickable [breadcrumbs](#breadcrumbs)
- {{% button style="transparent" icon="pen" %}}{{% /button %}} **edit**: browses to the editable page if the `editURL` [parameter is set](#edit-button) - {{% button style="transparent" icon="pen" %}}{{% /button %}} **edit**: browses to the editable page if the `editURL` [parameter is set](#edit-button)
- {{% button style="transparent" icon="print" %}}{{% /button %}} **print**: browses to the chapters printable page if [print support](configuration/sitemanagement/outputformats#print-support) was activated - {{% button style="transparent" icon="print" %}}{{% /button %}} **print**: browses to the [chapters printable page}(#print-button) if [print support](configuration/sitemanagement/outputformats#print-support) was activated
- {{% button style="transparent" icon="chevron-left" %}}{{% /button %}} **prev**: browses to the [previous page](#arrow-navigation) if there is one - {{% button style="transparent" icon="chevron-left" %}}{{% /button %}} **prev**: browses to the [previous page](#arrow-navigation) if there is one
- {{% button style="transparent" icon="chevron-right" %}}{{% /button %}} **next**: browses to the [next page](#arrow-navigation) if there is one - {{% button style="transparent" icon="chevron-right" %}}{{% /button %}} **next**: browses to the [next page](#arrow-navigation) if there is one
- {{% button style="transparent" icon="ellipsis-v" %}}{{% /button %}} **more**: opens the overlay if screen space is limited - {{% button style="transparent" icon="ellipsis-v" %}}{{% /button %}} **more**: opens the overlay if screen space is limited
@ -48,6 +48,14 @@ The value can contain the macro `${FilePath}` which will be replaced by the file
editURL = 'https://github.com/McShelby/hugo-theme-relearn/edit/main/exampleSite/content/${FilePath}' editURL = 'https://github.com/McShelby/hugo-theme-relearn/edit/main/exampleSite/content/${FilePath}'
{{< /multiconfig >}} {{< /multiconfig >}}
## Print Button
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can hide the print button if the [print output format](configuration/sitemanagement/outputformats/#print-support) is active by setting `disablePrintButton=true`.
{{< multiconfig >}}
disablePrintButton = true
{{< /multiconfig >}}
## Arrow Navigation ## Arrow Navigation
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can hide the previous/next buttons by setting `disableNextPrev=true`. If the buttons are hidden, also the keyboard shortcuts are disabled. {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can hide the previous/next buttons by setting `disableNextPrev=true`. If the buttons are hidden, also the keyboard shortcuts are disabled.

View file

@ -1,8 +1,8 @@
+++ +++
categories = ["howto"] categories = ["howto"]
description = "Configure the topbar" description = "Configure the topbar"
frontmatter = ["disableBreadcrumb", "disableNextPrev", "disableToc", "editURL"] frontmatter = ["disableBreadcrumb", "disableNextPrev", "disablePrintButton", "disableToc", "editURL"]
options = ["disableBreadcrumb", "disableNextPrev", "disableToc", "editURL"] options = ["disableBreadcrumb", "disableNextPrev", "disablePrintButton", "disableToc", "editURL"]
title = "Topbarrr" title = "Topbarrr"
weight = 4 weight = 4
+++ +++

View file

@ -16,7 +16,7 @@ Enable print support to print entire chapters or the whole site. Add the `print`
page = ['html', 'rss', 'print'] page = ['html', 'rss', 'print']
{{< /multiconfig >}} {{< /multiconfig >}}
This adds a printer icon in the topbar. Clicking it switches to print preview, showing the page and its [visible subpages](configuration/content/hidden) in a printer-friendly format. Use your browser's print function to print or save as PDF. By default this adds a printer icon in the topbar by can be [deactived](authoring/frontmatter/topbar/#print-button). Clicking it switches to print preview, showing the page and its [visible subpages](configuration/content/hidden) in a printer-friendly format. Use your browser's print function to print or save as PDF.
The URL won't be [configured ugly](https://gohugo.io/templates/output-formats/#configure-output-formats) for [Hugo's URL handling](https://gohugo.io/content-management/urls/#ugly-urls), even with `uglyURLs=true` in `hugo.toml`. This is because each mime type can only have one suffix. The URL won't be [configured ugly](https://gohugo.io/templates/output-formats/#configure-output-formats) for [Hugo's URL handling](https://gohugo.io/content-management/urls/#ugly-urls), even with `uglyURLs=true` in `hugo.toml`. This is because each mime type can only have one suffix.

View file

@ -11,3 +11,5 @@ weight = -3
### New ### New
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Support for Hugos built-in [`details` shortcode](https://gohugo.io/content-management/shortcodes/#details) by mapping it to the theme's [`expand` shortcode](shortcodes/expand). - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Support for Hugos built-in [`details` shortcode](https://gohugo.io/content-management/shortcodes/#details) by mapping it to the theme's [`expand` shortcode](shortcodes/expand).
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The topbar button for the print format [can now be hidden](authoring/frontmatter/topbar/#print-button) if the print output format is active by setting `disablePrintButton=true` in your `hugo.toml` or Front Matter.

View file

@ -2,8 +2,8 @@
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }} {{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }} {{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
{{- with .page }} {{- with .page }}
{{- $printFormat := .OutputFormats.Get "print" }} {{- $format := .OutputFormats.Get "print" }}
{{- $show := $printFormat }} {{- $show := and $format (not (.Param "disablePrintButton")) }}
{{- if $show }} {{- if $show }}
{{- $show = not (partial "_relearn/pageIsSpecial.gotmpl" .) }} {{- $show = not (partial "_relearn/pageIsSpecial.gotmpl" .) }}
{{- end }} {{- end }}
@ -11,7 +11,7 @@
{{- partial "topbar/func/button.html" (dict {{- partial "topbar/func/button.html" (dict
"page" . "page" .
"class" "topbar-button-print" "class" "topbar-button-print"
"href" $printFormat.RelPermalink "href" $format.RelPermalink
"icon" "print" "icon" "print"
"onwidths" $onwidths "onwidths" $onwidths
"onwidthm" $onwidthm "onwidthm" $onwidthm

View file

@ -1 +1 @@
7.2.1+49b2f8f770804e95af85e2dfdb515518b4f46821 7.2.1+d9152f9abaf57fec38d9a8ede67ebbf94303b9e3