mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
theme: compatiblity for output format with Hugo 0.123 #771
This commit is contained in:
parent
eaabbfd6ef
commit
4bc5529bc8
11 changed files with 41 additions and 39 deletions
|
@ -34,13 +34,13 @@ defaultContentLanguage = "en"
|
||||||
title = "Hugo Relearn Theme"
|
title = "Hugo Relearn Theme"
|
||||||
|
|
||||||
[outputs]
|
[outputs]
|
||||||
# add JSON to the home to support Lunr search; This is a mandatory setting
|
# add `json` to the home to support Lunr search; This is a mandatory setting
|
||||||
# for the search functionality
|
# for the search functionality
|
||||||
# add PRINT to home, section and page to activate the feature to print whole
|
# add `print` to home, section and page to activate the feature to print whole
|
||||||
# chapters
|
# chapters
|
||||||
home = ["HTML", "RSS", "PRINT", "SEARCH", "SEARCHPAGE"]
|
home = ["html", "rss", "print", "search", "searchpage"]
|
||||||
section = ["HTML", "RSS", "PRINT"]
|
section = ["html", "rss", "print"]
|
||||||
page = ["HTML", "RSS", "PRINT"]
|
page = ["html", "rss", "print"]
|
||||||
|
|
||||||
[markup]
|
[markup]
|
||||||
[markup.highlight]
|
[markup.highlight]
|
||||||
|
|
|
@ -31,7 +31,7 @@ The theme will append an additional `index.html` to all page bundle links by def
|
||||||
````
|
````
|
||||||
|
|
||||||
{{% notice note %}}
|
{{% notice note %}}
|
||||||
If you want to use the search feature from the file system using an older installation of the theme make sure to change your outputformat for the homepage from the now deprecated `JSON` to `SEARCH` [as seen below](#activate-search).
|
If you want to use the search feature from the file system using an older installation of the theme make sure to change your outputformat for the homepage from the now deprecated `json` to `search` [as seen below](#activate-search).
|
||||||
{{% /notice %}}
|
{{% /notice %}}
|
||||||
|
|
||||||
## Activate search
|
## Activate search
|
||||||
|
@ -40,18 +40,18 @@ If not already present, add the following lines in your `hugo.toml` file.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[outputs]
|
[outputs]
|
||||||
home = ["HTML", "RSS", "SEARCH"]
|
home = ["html", "rss", "search"]
|
||||||
```
|
```
|
||||||
|
|
||||||
This will generate a search index file at the root of your public folder ready to be consumed by the Lunr search library. Note that the `SEARCH` outputformat was named `JSON` in previous releases but was implemented differently. Although `JSON` still works, it is now deprecated.
|
This will generate a search index file at the root of your public folder ready to be consumed by the Lunr search library. Note that the `search` outputformat was named `json` in previous releases but was implemented differently. Although `json` still works, it is now deprecated.
|
||||||
|
|
||||||
### Activate dedicated search page
|
### Activate dedicated search page
|
||||||
|
|
||||||
You can add a dedicated search page for your page by adding the `SEARCHPAGE` outputformat to your home page by adding the following lines in your `hugo.toml` file. This will cause Hugo to generate a new file `http://example.com/mysite/search.html`.
|
You can add a dedicated search page for your page by adding the `searchpage` outputformat to your home page by adding the following lines in your `hugo.toml` file. This will cause Hugo to generate a new file `http://example.com/mysite/search.html`.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[outputs]
|
[outputs]
|
||||||
home = ["HTML", "RSS", "SEARCH", "SEARCHPAGE"]
|
home = ["html", "rss", "search", "searchpage"]
|
||||||
```
|
```
|
||||||
|
|
||||||
You can access this page by either clicking on the magnifier glass or by typing some search term and pressing `ENTER` inside of the menu's search box .
|
You can access this page by either clicking on the magnifier glass or by typing some search term and pressing `ENTER` inside of the menu's search box .
|
||||||
|
@ -66,13 +66,13 @@ To make sure, there is no duplicate content for any given URL of your project, r
|
||||||
|
|
||||||
## Activate print support
|
## Activate print support
|
||||||
|
|
||||||
You can activate print support to add the capability to print whole chapters or even the complete site. Just add the `PRINT` output format to your home, section and page in your `hugo.toml` as seen below:
|
You can activate print support to add the capability to print whole chapters or even the complete site. Just add the `print` output format to your home, section and page in your `hugo.toml` as seen below:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[outputs]
|
[outputs]
|
||||||
home = ["HTML", "RSS", "PRINT", "SEARCH"]
|
home = ["html", "rss", "print", "search"]
|
||||||
section = ["HTML", "RSS", "PRINT"]
|
section = ["html", "rss", "print"]
|
||||||
page = ["HTML", "RSS", "PRINT"]
|
page = ["html", "rss", "print"]
|
||||||
```
|
```
|
||||||
|
|
||||||
This will add a little printer icon in the top bar. It will switch the page to print preview when clicked. You can then send this page to the printer by using your browser's usual print functionality.
|
This will add a little printer icon in the top bar. It will switch the page to print preview when clicked. You can then send this page to the printer by using your browser's usual print functionality.
|
||||||
|
@ -80,7 +80,7 @@ This will add a little printer icon in the top bar. It will switch the page to p
|
||||||
{{% notice note %}}
|
{{% notice note %}}
|
||||||
The resulting URL will not be [configured ugly](https://gohugo.io/templates/output-formats/#configure-output-formats) in terms of [Hugo's URL handling](https://gohugo.io/content-management/urls/#ugly-urls) even if you've set `uglyURLs=true` in your `hugo.toml`. This is due to the fact that for one mime type only one suffix can be configured.
|
The resulting URL will not be [configured ugly](https://gohugo.io/templates/output-formats/#configure-output-formats) in terms of [Hugo's URL handling](https://gohugo.io/content-management/urls/#ugly-urls) even if you've set `uglyURLs=true` in your `hugo.toml`. This is due to the fact that for one mime type only one suffix can be configured.
|
||||||
|
|
||||||
Nevertheless, if you're unhappy with the resulting URLs you can manually redefine `outputFormats.PRINT` in your own `hugo.toml` to your liking.
|
Nevertheless, if you're unhappy with the resulting URLs you can manually redefine `outputFormats.print` in your own `hugo.toml` to your liking.
|
||||||
{{% /notice %}}
|
{{% /notice %}}
|
||||||
|
|
||||||
## Home Button Configuration
|
## Home Button Configuration
|
||||||
|
|
|
@ -42,7 +42,7 @@ theme = "hugo-theme-relearn"
|
||||||
|
|
||||||
# For search functionality
|
# For search functionality
|
||||||
[outputs]
|
[outputs]
|
||||||
home = [ "HTML", "RSS", "SEARCH"]
|
home = [ "html", "rss", "search"]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create your first chapter page
|
## Create your first chapter page
|
||||||
|
|
|
@ -46,6 +46,8 @@ This document shows you what's new in the latest release and flags it with one o
|
||||||
|
|
||||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Restored compatibility with Hugo versions {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.121.0{{% /badge %}} or higher for the [`highlight` shortcode](shortcodes/highlight). This does not change the minimum required Hugo version.
|
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Restored compatibility with Hugo versions {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.121.0{{% /badge %}} or higher for the [`highlight` shortcode](shortcodes/highlight). This does not change the minimum required Hugo version.
|
||||||
|
|
||||||
|
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Restored compatibility with Hugo versions {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.123.0{{% /badge %}} or higher for theme specific [output formats](basics/customization). This does not change the minimum required Hugo version.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5.23.0 (2023-11-03) {#5230}
|
## 5.23.0 (2023-11-03) {#5230}
|
||||||
|
@ -422,7 +424,7 @@ This document shows you what's new in the latest release and flags it with one o
|
||||||
|
|
||||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} This release introduces an additional dedicated search page. On this page, displayed search results have more space making it easier scanning thru large number of results.
|
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} This release introduces an additional dedicated search page. On this page, displayed search results have more space making it easier scanning thru large number of results.
|
||||||
|
|
||||||
To activate this feature, you need to [configure it](basics/customization#activate-dedicated-search-page) in your `hugo.toml` as a new outputformat `SEARCHPAGE` for the home page. If you don't configure it, no dedicated search page will be accessible and the theme works as before.
|
To activate this feature, you need to [configure it](basics/customization#activate-dedicated-search-page) in your `hugo.toml` as a new outputformat `searchpage` for the home page. If you don't configure it, no dedicated search page will be accessible and the theme works as before.
|
||||||
|
|
||||||
You can access the search page by either clicking on the magnifier glass or pressing enter inside of the search box.
|
You can access the search page by either clicking on the magnifier glass or pressing enter inside of the search box.
|
||||||
|
|
||||||
|
@ -460,7 +462,7 @@ This document shows you what's new in the latest release and flags it with one o
|
||||||
|
|
||||||
- {{% badge style="note" title=" " %}}Change{{% /badge %}} [With the proper settings](basics/customization#serving-your-page-from-the-filesystem) in your `hugo.toml` your page is now servable from the local file system using `file://` URLs.
|
- {{% badge style="note" title=" " %}}Change{{% /badge %}} [With the proper settings](basics/customization#serving-your-page-from-the-filesystem) in your `hugo.toml` your page is now servable from the local file system using `file://` URLs.
|
||||||
|
|
||||||
Please note that the searchbox will only work for this if you reconfigure your outputformat for the homepage in your `hugo.toml` from `JSON` to `SEARCH`. The now deprecated `JSON` outputformat still works as before, so there is no need to reconfigure your installation if it is only served from `http://` or `https://`.
|
Please note that the searchbox will only work for this if you reconfigure your outputformat for the homepage in your `hugo.toml` from `json` to `search`. The now deprecated `json` outputformat still works as before, so there is no need to reconfigure your installation if it is only served from `http://` or `https://`.
|
||||||
|
|
||||||
- {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`button` shortcode](shortcodes/button) has a new parameter `target` to set the destination frame/window for the URL to open. If not given, it defaults to a new window/tab for external URLs or is not set at all for internal URLs. Previously even internal URLs where opened in a new window/tab.
|
- {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`button` shortcode](shortcodes/button) has a new parameter `target` to set the destination frame/window for the URL to open. If not given, it defaults to a new window/tab for external URLs or is not set at all for internal URLs. Previously even internal URLs where opened in a new window/tab.
|
||||||
|
|
||||||
|
@ -494,12 +496,12 @@ This document shows you what's new in the latest release and flags it with one o
|
||||||
|
|
||||||
- {{% badge style="note" title=" " %}}Change{{% /badge %}} Because the print preview URLs were non deterministic for normal pages in comparison to page bundles, this is now changed. Each print preview is now accessible by adding a `index.print.html` to the default URL.
|
- {{% badge style="note" title=" " %}}Change{{% /badge %}} Because the print preview URLs were non deterministic for normal pages in comparison to page bundles, this is now changed. Each print preview is now accessible by adding a `index.print.html` to the default URL.
|
||||||
|
|
||||||
You can revert this behavior by overwriting the PRINT output format setting in your `hugo.toml`to:
|
You can revert this behavior by overwriting the `print` output format setting in your `hugo.toml`to:
|
||||||
|
|
||||||
````toml
|
````toml
|
||||||
[outputFormats]
|
[outputFormats]
|
||||||
[outputFormats.PRINT]
|
[outputFormats.print]
|
||||||
name= "PRINT"
|
name= "print"
|
||||||
baseName = "index"
|
baseName = "index"
|
||||||
path = "_print"
|
path = "_print"
|
||||||
isHTML = true
|
isHTML = true
|
||||||
|
|
12
hugo.toml
12
hugo.toml
|
@ -7,24 +7,24 @@
|
||||||
suffixes = ["js"]
|
suffixes = ["js"]
|
||||||
|
|
||||||
[outputFormats]
|
[outputFormats]
|
||||||
[outputFormats.PRINT]
|
[outputFormats.print]
|
||||||
name= "PRINT"
|
name= "print"
|
||||||
baseName = "index.print"
|
baseName = "index.print"
|
||||||
isHTML = true
|
isHTML = true
|
||||||
mediaType = 'text/html'
|
mediaType = 'text/html'
|
||||||
permalinkable = false
|
permalinkable = false
|
||||||
noUgly = true
|
noUgly = true
|
||||||
|
|
||||||
[outputFormats.SEARCH]
|
[outputFormats.search]
|
||||||
name= "SEARCH"
|
name= "search"
|
||||||
baseName = "index.search"
|
baseName = "index.search"
|
||||||
isPlainText = true
|
isPlainText = true
|
||||||
mediaType = 'text/javascript'
|
mediaType = 'text/javascript'
|
||||||
permalinkable = false
|
permalinkable = false
|
||||||
noUgly = true
|
noUgly = true
|
||||||
|
|
||||||
[outputFormats.SEARCHPAGE]
|
[outputFormats.searchpage]
|
||||||
name= "SEARCHPAGE"
|
name= "searchpage"
|
||||||
baseName = "search"
|
baseName = "search"
|
||||||
isHTML = true
|
isHTML = true
|
||||||
mediaType = 'text/html'
|
mediaType = 'text/html'
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
|
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
|
||||||
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
|
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
|
||||||
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
||||||
{{- with .OutputFormats.Get "RSS" }}
|
{{- with .OutputFormats.Get "rss" }}
|
||||||
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }}
|
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- range $pages }}
|
{{- range $pages }}
|
||||||
|
|
|
@ -49,8 +49,8 @@
|
||||||
{{- if eq .Rel "canonical" }}
|
{{- if eq .Rel "canonical" }}
|
||||||
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
||||||
{{- else if eq $outputFormat "searchpage" }}
|
{{- else if eq $outputFormat "searchpage" }}
|
||||||
{{- else if eq .Name "SEARCHPAGE" }}
|
{{- else if eq .Name "searchpage" }}
|
||||||
{{- else if and (ne .Name "JSON") (ne .Name "SEARCH") }}
|
{{- else if and (ne .Name "json") (ne .Name "search") }}
|
||||||
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
|
|
||||||
{{- if and (ne .Site.Params.disableSeoHiddenPages true) (ne .Site.Params.disableSearchHiddenPages true) }}
|
{{- if and (ne .Site.Params.disableSeoHiddenPages true) (ne .Site.Params.disableSearchHiddenPages true) }}
|
||||||
{{- range .AlternativeOutputFormats }}
|
{{- range .AlternativeOutputFormats }}
|
||||||
{{- if eq .Name "SEARCHPAGE" }}
|
{{- if eq .Name "searchpage" }}
|
||||||
{{- else if eq .Name "JSON" }}
|
{{- else if eq .Name "json" }}
|
||||||
{{ (printf $link (.Permalink | relURL) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
{{ (printf $link (.Permalink | relURL) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{- $link := "" }}
|
{{- $link := "" }}
|
||||||
{{- if or (.Site.Home.OutputFormats.Get "JSON") (.Site.Home.OutputFormats.Get "SEARCH") }}
|
{{- if or (.Site.Home.OutputFormats.Get "json") (.Site.Home.OutputFormats.Get "search") }}
|
||||||
{{- with .Site.Home.OutputFormats.Get "SEARCHPAGE" }}
|
{{- with .Site.Home.OutputFormats.Get "searchpage" }}
|
||||||
{{- $link = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
|
{{- $link = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
<script>
|
<script>
|
||||||
{{ "// hack to let hugo tell us how to get to the root when using relativeURLs, it needs to be called *url= for it to do its magic:" | safeJS }}
|
{{ "// hack to let hugo tell us how to get to the root when using relativeURLs, it needs to be called *url= for it to do its magic:" | safeJS }}
|
||||||
{{ "// https://github.com/gohugoio/hugo/blob/145b3fcce35fbac25c7033c91c1b7ae6d1179da8/transform/urlreplacers/absurlreplacer.go#L72" | safeJS }}
|
{{ "// https://github.com/gohugoio/hugo/blob/145b3fcce35fbac25c7033c91c1b7ae6d1179da8/transform/urlreplacers/absurlreplacer.go#L72" | safeJS }}
|
||||||
{{- with .Site.Home.OutputFormats.Get "JSON" }}
|
{{- with .Site.Home.OutputFormats.Get "json" }}
|
||||||
{{- warnf "%q: DEPRECATED usage of 'JSON' output format found, use 'SEARCH' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/customization#activate-search" $page.File.Filename }}
|
{{- warnf "%q: DEPRECATED usage of 'json' output format found, use 'search' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/customization#activate-search" $page.File.Filename }}
|
||||||
window.index_json_url={{ "index.json" | relLangURL }};
|
window.index_json_url={{ "index.json" | relLangURL }};
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Site.Home.OutputFormats.Get "SEARCH" }}
|
{{- with .Site.Home.OutputFormats.Get "search" }}
|
||||||
window.index_js_url={{ "index.search.js" | relLangURL }};
|
window.index_js_url={{ "index.search.js" | relLangURL }};
|
||||||
{{- end }}
|
{{- end }}
|
||||||
var root_url="/";
|
var root_url="/";
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{{- with .page }}
|
{{- with .page }}
|
||||||
{{- $format := partial "get-format.hugo" . }}
|
{{- $format := partial "get-format.hugo" . }}
|
||||||
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
|
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
|
||||||
{{- $printFormat := .OutputFormats.Get "PRINT" }}
|
{{- $printFormat := .OutputFormats.Get "print" }}
|
||||||
{{- if and (eq $outputFormat "html") $printFormat }}
|
{{- if and (eq $outputFormat "html") $printFormat }}
|
||||||
{{- partial "topbar/func/button.html" (dict
|
{{- partial "topbar/func/button.html" (dict
|
||||||
"page" .
|
"page" .
|
||||||
|
|
|
@ -114,7 +114,7 @@ function initLunrJson() {
|
||||||
// this does not work if pages are served via
|
// this does not work if pages are served via
|
||||||
// file:// protocol; this is only left for
|
// file:// protocol; this is only left for
|
||||||
// backward compatiblity if the user did not
|
// backward compatiblity if the user did not
|
||||||
// define the SEARCH output format for the homepage
|
// define the `search` output format for the homepage
|
||||||
if( window.index_json_url && !window.index_js_url ){
|
if( window.index_json_url && !window.index_js_url ){
|
||||||
xhr = new XMLHttpRequest;
|
xhr = new XMLHttpRequest;
|
||||||
xhr.onreadystatechange = function(){
|
xhr.onreadystatechange = function(){
|
||||||
|
|
Loading…
Reference in a new issue