markdown: support new output format #979

This commit is contained in:
Sören Weber 2024-12-31 14:32:43 +01:00
parent 7807445527
commit fbec3905ed
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
13 changed files with 77 additions and 7 deletions

View file

@ -135,6 +135,12 @@ disableToc = false
# shown in the topbar. # shown in the topbar.
disableBreadcrumb = false disableBreadcrumb = false
# Hide the Markdown button.
# Default: false
# This hides the Markdown button if you activated the Markdown output format.
# This can be overridden in the page's frontmatter.
disableMarkdownButton = false
# Hide the print button. # Hide the print button.
# Default: false # Default: false
# This hides the print button if you activated the print output format. # This hides the print button if you activated the print output format.

View file

@ -52,6 +52,12 @@ disableToc = false
# shown in the topbar. # shown in the topbar.
disableBreadcrumb = false disableBreadcrumb = false
# Hide the Markdown button.
# Default: false
# This hides the Markdown button if you activated the Markdown output format.
# If not set, the set value of your site's hugo.toml is used.
disableMarkdownButton = false
# Hide the print button. # Hide the print button.
# Default: false # Default: false
# This hides the print button if you activated the print output format. # This hides the print button if you activated the print output format.

View file

@ -1,8 +1,8 @@
+++ +++
categories = ["howto"] categories = ["howto"]
description = "Configure the topbar" description = "Configure the topbar"
frontmatter = ["disableBreadcrumb", "disableNextPrev", "disablePrintButton", "disableToc", "editURL"] frontmatter = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disablePrintButton", "disableToc", "editURL"]
options = ["disableBreadcrumb", "disableNextPrev", "disablePrintButton", "disableToc", "editURL"] options = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disablePrintButton", "disableToc", "editURL"]
title = "Topbar" title = "Topbar"
weight = 4 weight = 4
+++ +++
@ -15,7 +15,8 @@ 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}(#print-button) if [print support](configuration/sitemanagement/outputformats#print-support) was activated - {{% button style="transparent" icon="fa-fw fab fa-markdown" %}}{{% /button %}} **markdown**: browses to the [chapters Markdown source](#markdown-button) if [markdown support](configuration/sitemanagement/outputformats#markdown-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 +49,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 >}}
## Markdown 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 Markdown button if the [Markdown output format](configuration/sitemanagement/outputformats/#markdown-support) is active by setting `disableMarkdownButton=true`.
{{< multiconfig >}}
disableMarkdownButton = true
{{< /multiconfig >}}
## Print Button ## 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`. {{% 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`.

View file

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

View file

@ -35,6 +35,7 @@ The theme ships with the following predefined buttons (from left to right in the
- {{% button style="transparent" icon="bars" %}}{{% /button %}} [**sidebar**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/sidebar.html): opens the sidebar flyout if in mobile layout - {{% button style="transparent" icon="bars" %}}{{% /button %}} [**sidebar**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/sidebar.html): opens the sidebar flyout if in mobile layout
- {{% button style="transparent" icon="list-alt" %}}{{% /button %}} [**toc**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/toc.html): [opens the table of contents in an overlay](authoring/frontmatter/topbar#table-of-contents) - {{% button style="transparent" icon="list-alt" %}}{{% /button %}} [**toc**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/toc.html): [opens the table of contents in an overlay](authoring/frontmatter/topbar#table-of-contents)
- {{% button style="transparent" icon="pen" %}}{{% /button %}} [**edit**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/edit.html): browses to the editable page if the `editURL` [parameter is set](authoring/frontmatter/topbar#edit-button) - {{% button style="transparent" icon="pen" %}}{{% /button %}} [**edit**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/edit.html): browses to the editable page if the `editURL` [parameter is set](authoring/frontmatter/topbar#edit-button)
- {{% button style="transparent" icon="fa-fw fab fa-markdown" %}}{{% /button %}} [**markdown**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/markdown.html): browses to the chapter's markdown source if [markdown support](configuration/sitemanagement/outputformats#markdown-support) was activated
- {{% button style="transparent" icon="print" %}}{{% /button %}} [**print**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/print.html): browses to the chapter's printable page if [print support](configuration/sitemanagement/outputformats#print-support) was activated - {{% button style="transparent" icon="print" %}}{{% /button %}} [**print**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/print.html): browses to the chapter's printable page if [print support](configuration/sitemanagement/outputformats#print-support) was activated
- {{% button style="transparent" icon="chevron-left" %}}{{% /button %}} [**prev**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/prev.html): browses to the [previous page](authoring/frontmatter/topbar#arrow-navigation) if there is one - {{% button style="transparent" icon="chevron-left" %}}{{% /button %}} [**prev**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/prev.html): browses to the [previous page](authoring/frontmatter/topbar#arrow-navigation) if there is one
- {{% button style="transparent" icon="chevron-right" %}}{{% /button %}} [**next**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/next.html): browses to the [next page]authoring/frontmatter/topbar(#arrow-navigation) if there is one - {{% button style="transparent" icon="chevron-right" %}}{{% /button %}} [**next**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/next.html): browses to the [next page]authoring/frontmatter/topbar(#arrow-navigation) if there is one

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 >}}
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. By default this adds a printer icon in the topbar but [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.
@ -32,3 +32,18 @@ If you don't like the URLs, you can reconfigure `outputFormats.print` in your `h
permalinkable = false permalinkable = false
noUgly = true noUgly = true
{{< /multiconfig >}} {{< /multiconfig >}}
## Markdown Support
Enable support to show the Markdown source of a page . Add the `markdown` output format to your home, section, and page in `hugo.toml`:
{{< multiconfig file=hugo >}}
[outputs]
home = ['html', 'rss', 'markdown']
section = ['html', 'rss', 'markdown']
page = ['html', 'rss', 'markdown']
{{< /multiconfig >}}
By default this adds a Markdown icon in the topbar but [can be deactived](authoring/frontmatter/topbar/#markdown-button). Clicking it switches to the Markdown source of the page.
The `markdown` output format configuration is [provided by Hugo](https://gohugo.io/templates/output-formats/#output-format-definitions).

View file

@ -13,3 +13,5 @@ weight = -3
- {{% 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. - {{% 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.
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme supports the new [`markdown` output format](configuration/sitemanagement/outputformats/#markdown-support) which behaves similar in configuration as the `print` output format but allows the original Markdown source of a page to be viewed.

View file

@ -0,0 +1,4 @@
{{/* the following check avoids to print out content of headless bundles if called from nestedContent.gotmpl */}}
{{- if .RelPermalink }}
{{- .RawContent }}
{{- end }}

1
layouts/_default/list.md Normal file
View file

@ -0,0 +1 @@
{{ define "_empty" }}{{ end }}

View file

@ -0,0 +1 @@
{{ define "_empty" }}{{ end }}

View file

@ -1,6 +1,9 @@
{{- partial "topbar/button/edit.html" (dict {{- partial "topbar/button/edit.html" (dict
"page" . "page" .
)}} )}}
{{- partial "topbar/button/markdown.html" (dict
"page" .
)}}
{{- partial "topbar/button/print.html" (dict {{- partial "topbar/button/print.html" (dict
"page" . "page" .
)}} )}}

View file

@ -0,0 +1,22 @@
{{- $onwidths := cond (isset . "onwidths") .onwidths "area-more" }}
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
{{- with .page }}
{{- $format := .OutputFormats.Get "markdown" }}
{{- $show := and $format (not (.Param "disableMarkdownButton")) }}
{{- if $show }}
{{- $show = not (partial "_relearn/pageIsSpecial.gotmpl" .) }}
{{- end }}
{{- if $show }}
{{- partial "topbar/func/button.html" (dict
"page" .
"class" "topbar-button-markdown"
"href" $format.RelPermalink
"icon" "fa-fw fab fa-markdown"
"onwidths" $onwidths
"onwidthm" $onwidthm
"onwidthl" $onwidthl
"hint" (T "Show-Markdown")
)}}
{{- end }}
{{- end }}

View file

@ -1 +1 @@
7.2.1+2cd8baa02f811124d580c519d95b3f977a1972f6 7.2.1+780744552727654e03983918f0ad49ccae2a696b