From fbe2d442f272ff8540b561ac6c6bf225084f8024 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Thu, 12 Dec 2024 12:56:38 -0800 Subject: [PATCH] Miscellaneous updates for v0.140.0 - Add configuration option: disableDefaultLanguageRedirect - Allow collections.Querify to accept a map argument --- .../en/functions/collections/Dictionary.md | 2 +- content/en/functions/collections/Querify.md | 23 +++++++++++++++---- content/en/getting-started/configuration.md | 6 +++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/content/en/functions/collections/Dictionary.md b/content/en/functions/collections/Dictionary.md index 2ac875d283..07d1eb0f2e 100644 --- a/content/en/functions/collections/Dictionary.md +++ b/content/en/functions/collections/Dictionary.md @@ -7,7 +7,7 @@ action: aliases: [dict] related: - functions/collections/Slice - returnType: mapany + returnType: map[string]any signatures: ['collections.Dictionary [VALUE...]'] aliases: [/functions/dict] --- diff --git a/content/en/functions/collections/Querify.md b/content/en/functions/collections/Querify.md index 07e27bd7e8..0eb4094212 100644 --- a/content/en/functions/collections/Querify.md +++ b/content/en/functions/collections/Querify.md @@ -1,6 +1,6 @@ --- title: collections.Querify -description: Returns a URL query string composed of the given key-value pairs. +description: Returns a URL query string composed of the given key-value pairs, encoded and sorted by key. categories: [] keywords: [] action: @@ -13,18 +13,18 @@ action: aliases: [/functions/querify] --- -Specify the key-value pairs as individual arguments, or as a slice. The following are equivalent: - +Specify the key-value pairs as a map, a slice, or a sequence of scalar values. For example, the following are equivalent: ```go-html-template -{{ collections.Querify "a" 1 "b" 2 }} +{{ collections.Querify (dict "a" 1 "b" 2) }} {{ collections.Querify (slice "a" 1 "b" 2) }} +{{ collections.Querify "a" 1 "b" 2 }} ``` To append a query string to a URL: ```go-html-template -{{ $qs := collections.Querify "a" 1 "b" 2 }} +{{ $qs := collections.Querify (dict "a" 1 "b" 2) }} {{ $href := printf "https://example.org?%s" $qs }} Link @@ -35,3 +35,16 @@ Hugo renders this to: ```html Link ``` + +You can also pass in a map from your site configuration or front matter. For example: + +{{< code-toggle file=content/example.md fm=true >}} +title = 'Example' +[params.query] +a = 1 +b = 2 +{{< /code-toggle >}} + +```go-html-template +{{ collections.Querify .Params.query }} +``` diff --git a/content/en/getting-started/configuration.md b/content/en/getting-started/configuration.md index 342804a72b..b8922723a9 100644 --- a/content/en/getting-started/configuration.md +++ b/content/en/getting-started/configuration.md @@ -278,6 +278,12 @@ To remain consistent and prevent unexpected behavior, do not mix these strategie (`bool`) Will disable generation of alias redirects. Note that even if `disableAliases` is set, the aliases themselves are preserved on the page. The motivation with this is to be able to generate 301 redirects in an `.htaccess`, a Netlify `_redirects` file or similar using a custom output format. Default is `false`. +###### disableDefaultLanguageRedirect + +{{< new-in 0.140.0 >}} + +(`bool`) Disables generation of redirect to the default language when DefaultContentLanguageInSubdir is `true`. Default is `false`. + ###### disableHugoGeneratorInject (`bool`) Hugo will, by default, inject a generator meta tag in the HTML head on the _home page only_. You can turn it off, but we would really appreciate if you don't, as this is a good way to watch Hugo's popularity on the rise. Default is `false`.