Squashed 'docs/' changes from 60a58d123..327003421

327003421 Update index.md
cafdccc13 Hugo 0.86.1
467a89a02 Merge branch 'v0861'
a22c37bc9 Merge branch 'release-0.86.1'
276da91a8 releaser: Add release notes to /docs for release of 0.86.1
198cdf8f0 tpl/lang: Add new localized versions of lang.FormatNumber etc.
93f986ecc Add timezone support for front matter dates without one
b30b876bb Localize time.Format
950fdab90 Fix AddDate documentation
78d7b52b6 Document config.cascade
fd1e1e4b7 Fix grammar and spelling (#1497)
05bf3aa32 Fix grammar / typos in news
32060a3b4 One more try
f6e24ddfa PNG to JPG for the rel notes image
9ec5bdfad Update index.md
5f5d7f69d Release Hugo 0.86.0
2dd60bb71 releaser: Add release notes to /docs for release of 0.86.0
6445fb36c Merge commit '53a352795a69a9d4a373f50ec62138595948c6ea'
cb57ca73a Simplify "active menu" logic for section menus

git-subtree-dir: docs
git-subtree-split: 327003421d8c07f9764aaaf644626805287fd30c
This commit is contained in:
Bjørn Erik Pedersen 2021-08-03 11:51:36 +02:00
parent 53a352795a
commit bd77f6e1c9
246 changed files with 278 additions and 44 deletions

View File

@ -17,6 +17,12 @@ pluralizeListTitles = false
# We do redirects via Netlify's _redirects file, generated by Hugo (see "outputs" below).
disableAliases = true
[minify]
[minify.tdewolff]
[minify.tdewolff.css]
[minify.tdewolff.html]
keepWhitespace = true
[module]
[module.hugoVersion]
min = "0.56.0"

View File

@ -134,7 +134,7 @@ Or individually access EXIF data with dot access, e.g.:
{{ end }}
```
Some fields may need to be formatted with [`lang.NumFmt`]({{< relref "functions/numfmt" >}}) function to prevent display like `Aperture: 2.278934289` instead of `Aperture: 2.28`.
Some fields may need to be formatted with [`lang.FormatNumberCustom`]({{< relref "functions/lang" >}}) function to prevent display like `Aperture: 2.278934289` instead of `Aperture: 2.28`.
#### Exif fields

View File

@ -34,7 +34,7 @@ link = "https://twitter.com/spf13"
date = "2017-01-07T00:00:00Z"
{{< /code-toggle >}}
Let's assume you want to grab Tweets from the last two years and present them in a random order. In conjunction with the [`where`](/functions/where/) and [`now`](/functions/now/) functions, you can limit our range to the last two years via `now.AddDate -2 0 0`, which represents a point in time 2 years, 0 days, and 0 hours before the time of your last site build.
Let's assume you want to grab Tweets from the last two years and present them in a random order. In conjunction with the [`where`](/functions/where/) and [`now`](/functions/now/) functions, you can limit our range to the last two years via `now.AddDate -2 0 0`, which represents a point in time 2 years, 0 months, and 0 days before the time of your last site build.
{{< code file="partials/templates/random-tweets.html" download="tweets.html" >}}
{{ range where $.Site.Data.tweets.tweet "date" "ge" (now.AddDate -2 0 0) | shuffle }}

View File

@ -1,6 +1,6 @@
---
title: dateFormat
description: Converts the textual representation of the `datetime` into the specified format.
title: time.Format
description: Converts a date/time to a localized string.
godocref: https://golang.org/pkg/time/
date: 2017-02-01
publishdate: 2017-02-01
@ -10,23 +10,47 @@ menu:
docs:
parent: "functions"
keywords: [dates,time,strings]
signature: ["dateFormat LAYOUT INPUT"]
signature: ["time.Format LAYOUT INPUT"]
workson: []
hugoversion:
relatedfuncs: [Format,now,Unix,time]
deprecated: false
---
`dateFormat` converts a timestamp string `INPUT` into the format specified by the `LAYOUT` string.
`time.Format` (alias `dateFormat`) converts either a `time.Time` object (e.g. `.Date`) or a timestamp string `INPUT` into the format specified by the `LAYOUT` string.
```
{{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }} → "Wednesday, Jan 21, 2015"
```go-html-template
{{ time.Format "Monday, Jan 2, 2006" "2015-01-21" }} → "Wednesday, Jan 21, 2015"
```
{{% warning %}}
As of v0.19 of Hugo, the `dateFormat` function is *not* supported as part of Hugo's [multilingual feature](/content-management/multilingual/).
{{% /warning %}}
Note that since Hugo 0.87.0, `time.Format` will return a localized string for the currrent language. {{< new-in "0.87.0" >}}
See [Gos Layout String](/functions/format/#gos-layout-string) to learn about how the `LAYOUT` string has to be formatted. There are also some useful examples.
The `LAYOUT` string can be either:
* [Gos Layout String](/functions/format/#gos-layout-string) to learn about how the `LAYOUT` string has to be formatted. There are also some useful examples.
* A custom Hugo layout identifier (see full list below)
See the [`time` function](/functions/time/) to convert a timestamp string to a Go `time.Time` type value.
## Date/time formatting layouts
{{< new-in "0.87.0" >}}
Go's date layout strings can be hard to reason about, especially with multiple languages. Since Hugo 0.87.0 you can alternatively use some predefined layout idenfifiers that will output localized dates or times:
```go-html-template
{{ .Date | time.Format ":date_long" }}
```
The full list of custom layouts with examples for English:
* `:date_full` => `Wednesday, June 6, 2018`
* `:date_long` => `June 6, 2018`
* `:date_medium` => `Jun 6, 2018`
* `:date_short` => `6/6/18`
* `:time_full` => `2:09:37 am UTC`
* `:time_long` => `2:09:37 am UTC`
* `:time_medium` => `2:09:37 am`
* `:time_short` => `2:09 am`

View File

@ -24,4 +24,6 @@ aliases: []
returns `true` if the PAGE is the same object as the `.Page` in one of the
**children menu entries** under MENUENTRY in a given MENU.
{{< new-in "0.86.0" >}} If MENUENTRY's `.Page` is a [section](/content-management/sections/) then, from Hugo `0.86.0`, this method also returns true for any descendant of that section..
You can find its example use in [menu templates](/templates/menu-templates/).

View File

@ -1,10 +1,8 @@
---
title: lang.NumFmt
description: "Formats a number with a given precision using the requested `negative`, `decimal`, and `grouping` options. The `options` parameter is a string consisting of `<negative> <decimal> <grouping>`."
godocref: ""
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-08-21
title: lang
package: lang
description: "TODO.."
date: 2021-07-28
categories: [functions]
keywords: [numbers]
menu:
@ -12,18 +10,13 @@ menu:
parent: "functions"
toc: false
signature: ["lang.NumFmt PRECISION NUMBER [OPTIONS [DELIMITER]]"]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
draft: false
aliases: []
comments:
aliases: ['/functions/numfmt/']
type: 'template-func'
---
The default options value is `- . ,`. The default delimiter within the options
value is a space. If you need to use a space as one of the options, set a
custom delimiter.
custom delimiter.s
Numbers greater than or equal to 5 are rounded up. For example, if precision is set to `0`, `1.5` becomes `2`, and `1.4` becomes `1`.

View File

@ -11,7 +11,7 @@ menu:
docs:
parent: "functions"
keywords: [dates,time,location]
signature: ["time INPUT [LOCATION]"]
signature: ["time INPUT [TIMEZONE]"]
workson: []
hugoversion: "v0.77.0"
relatedfuncs: []
@ -19,6 +19,7 @@ deprecated: false
aliases: []
---
`time` converts a timestamp string with an optional default location into a [`time.Time`](https://godoc.org/time#Time) structure so you can access its fields:
```
@ -29,10 +30,12 @@ aliases: []
## Using Locations
The optional `LOCATION` parameter is a string that sets a default location that is associated with the specified time value. If the time value has an explicit timezone or offset specified, it will take precedence over the `LOCATION` parameter.
The optional `TIMEZONE` parameter is a string that sets a default time zone (or more specific, the location, which represents the collection of time offsets in a geographical area) that is associated with the specified time value. If the time value has an explicit timezone or offset specified, it will take precedence over the `TIMEZONE` parameter.
The list of valid locations may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
If no `TIMEZONE` is set, the `timeZone` from site configuration will be used.
```
{{ time "2020-10-20" }} → 2020-10-20 00:00:00 +0000 UTC
{{ time "2020-10-20" "America/Los_Angeles" }} → 2020-10-20 00:00:00 -0700 PDT

View File

@ -133,6 +133,9 @@ buildFuture (false)
caches
: See [Configure File Caches](#configure-file-caches)
cascade {{< new-in "0.86.0" >}}
: Pass down down default configuration values (front matter) to pages in the content tree. The options in site config is the same as in page front matter, see [Front Matter Cascade](/content-management/front-matter#front-matter-cascade).
canonifyURLs (false)
: Enable to turn relative URLs into absolute.
@ -299,6 +302,9 @@ themesDir ("themes")
timeout (10000)
: Timeout for generating page contents, in milliseconds (defaults to 10&nbsp;seconds). *Note:* this is used to bail out of recursive content generation, if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents) you might need to raise this limit.
timeZone {{< new-in "0.86.0" >}}
: The time zone (or location), e.g. `Europe/Oslo`, used to parse front matter dates without such information and in the [`time` function](/functions/time/).
title ("")
: Site title.

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

View File

@ -0,0 +1,56 @@
---
date: 2021-07-21
title: "Hugo 0.86.0: Cascade in Config"
description: "Hugo 0.86.0 adds cascade keyword to site config, much improved \"active menu item\" logic for section pages, and more."
categories: ["Releases"]
---
This release is a set of smaller fixes and improvements. Some of the more notable:
You can now have a top level [cascade](https://gohugo.io/content-management/front-matter#front-matter-cascade) (or one per language, if needed) section in your site configuration (e.g. `config.toml`). This way you can control default front matter values from outside of the content files.
Hugo's [Menu system](https://gohugo.io/content-management/menus/) works well, but hasn't been particularly easy to set the active menu state for section pages without a menu definition. We have had the option [Section Menu for Lazy Bloggers](https://gohugo.io/templates/menu-templates/#section-menu-for-lazy-bloggers). That helped for the common case, but we have now made it behave more sensible out of the box: `$page.HasMenuCurrent $sectionMenuEntry` will now always return true for any descendant of that section. To support this for menu definitions in the site config, we have added a new `pageRef` option on [MenuEntry](https://gohugo.io/variables/menus/#menu-entry-variables):
```toml
[[menus.main]]
pageRef = "blog"
# When pageRef is set, setting `url` is optional; it will be used as a fallback if the page is not found.
url = "/blog"
```
Set `pageRef` to a value that [site.GetPage](https://gohugo.io/functions/getpage/) understands, and the menu entry will be correctly connected to the page.
This release represents **14 contributions by 2 contributors** to the main Hugo code base.
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
which has received **1 contributions by 1 contributors**.
Hugo now has:
* 53005+ [stars](https://github.com/gohugoio/hugo/stargazers)
* 431+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors)
* 370+ [themes](http://themes.gohugo.io/)
## Enhancements
### Other
* Simplify "active menu" logic for section menus [d831d2fc](https://github.com/gohugoio/hugo/commit/d831d2fce8198fb814ea4d3d8c311db5c388d04c) [@bep](https://github.com/bep) [#8776](https://github.com/gohugoio/hugo/issues/8776)
* Make keepWhitespace = true default for HTML [c19f65f9](https://github.com/gohugoio/hugo/commit/c19f65f956739ab76c38222d48a3e461525e31af) [@bep](https://github.com/bep) [#8771](https://github.com/gohugoio/hugo/issues/8771)
* Make FileMeta a struct [022c4795](https://github.com/gohugoio/hugo/commit/022c4795510306e08a4aba31504ca382d41c7fac) [@bep](https://github.com/bep) [#8749](https://github.com/gohugoio/hugo/issues/8749)
* Add tabindex="0" to default <pre> wrapper [f27e5424](https://github.com/gohugoio/hugo/commit/f27e542442d19436f1428cc22bb03aca398d37a7) [@rhymes](https://github.com/rhymes) [#7194](https://github.com/gohugoio/hugo/issues/7194)
* Rename/reorder the hook methods [80566481](https://github.com/gohugoio/hugo/commit/805664818d0e1f95a3474271c2db3e5f49db26ba) [@bep](https://github.com/bep) [#8755](https://github.com/gohugoio/hugo/issues/8755)
* Support auto links in render hook [ee3d2bb1](https://github.com/gohugoio/hugo/commit/ee3d2bb1d3974584f47cde7c973fbd1ae1f512b6) [@bep](https://github.com/bep) [#8755](https://github.com/gohugoio/hugo/issues/8755)
* Adjust a test helper [eb2a5003](https://github.com/gohugoio/hugo/commit/eb2a500367780b07d67c301ce7c866e6b67aa687) [@bep](https://github.com/bep)
* Add config.cascade [5cb52c23](https://github.com/gohugoio/hugo/commit/5cb52c23150032b3fdb211a095745c512369b463) [@bep](https://github.com/bep) [#8741](https://github.com/gohugoio/hugo/issues/8741)
* Regenerate image golden testdata [30eea391](https://github.com/gohugoio/hugo/commit/30eea3915b67f72611a3b2f4547146d4c6a96864) [@bep](https://github.com/bep) [#8729](https://github.com/gohugoio/hugo/issues/8729)
## Fixes
### Other
* Fix panic on invalid config in "hugo mod get" and similar [351ed0f5](https://github.com/gohugoio/hugo/commit/351ed0f569f96aff29b03925bf5154d80a164e00) [@bep](https://github.com/bep) [#8773](https://github.com/gohugoio/hugo/issues/8773)
* Fix Params case handling for menu items defined in site config [634481ba](https://github.com/gohugoio/hugo/commit/634481ba8cfcd865ba0d8811d8834f6af45663d7) [@bep](https://github.com/bep) [#8775](https://github.com/gohugoio/hugo/issues/8775)
* Fix default values when loading from config dir [ae6cf93c](https://github.com/gohugoio/hugo/commit/ae6cf93c84c3584b111f4b9fa3fb4e3f63d37915) [@bep](https://github.com/bep) [#8763](https://github.com/gohugoio/hugo/issues/8763)
* Fix the deprecation error/warn log levels [a70da2b7](https://github.com/gohugoio/hugo/commit/a70da2b74a6af0834cce9668cdb6acdb1c86a4c0) [@bep](https://github.com/bep)
* Fix transparency problem when converting 32-bit images to WebP [8f40f34c](https://github.com/gohugoio/hugo/commit/8f40f34cd10a98598bb822ec633fd5d0ea64b612) [@bep](https://github.com/bep) [#8729](https://github.com/gohugoio/hugo/issues/8729)

View File

@ -0,0 +1,19 @@
---
date: 2021-07-30
title: "Hugo 0.86.1: One Bug Fix"
description: "This version fixes a of bug introduced in 0.86.0."
categories: ["Releases"]
images:
- images/blog/hugo-bug-poster.png
---
This is a bug-fix release with one important fix.
* config: Fix a potential deadlock in config reading [94b616bd](https://github.com/gohugoio/hugo/commit/94b616bdfad177daa99f5e87535943f509198f6f) [@bep](https://github.com/bep) [#8791](https://github.com/gohugoio/hugo/issues/8791)

View File

@ -40,6 +40,9 @@ Reference to the [page object][page-object] associated with the menu entry. This
will be non-nil if the menu entry is set via a page's front-matter and not via
the site config.
.PageRef {{< new-in "0.86.0" >}}
: _string_ <br /> Can be set if defined in site config and the menu entry refers to a Page. [site.GetPage](/functions/getpage/) will be used to do the page lookup. If this is set, you don't need to set the `URL`.
.Name
: _string_ <br />
Name of the menu entry. The `name` key, if set for the menu entry, sets

View File

@ -1677,6 +1677,9 @@
"caches": {
"_merge": "none"
},
"cascade": {
"_merge": "none"
},
"frontmatter": {
"_merge": "none"
},
@ -1745,7 +1748,7 @@
"keepDocumentTags": true,
"keepEndTags": true,
"keepQuotes": false,
"keepWhitespace": false
"keepWhitespace": true
},
"css": {
"keepCSS2": true,
@ -1756,7 +1759,8 @@
"keepVarNames": false
},
"json": {
"precision": 0
"precision": 0,
"keepNumbers": false
},
"svg": {
"precision": 0
@ -3898,14 +3902,52 @@
}
},
"lang": {
"Merge": {
"Description": "",
"Args": null,
"FormatAccounting": {
"Description": "FormatAccounting returns the currency reprecentation of number for the given currency and precision\nfor the current language in accounting notation.",
"Args": [
"precision",
"currency",
"number"
],
"Aliases": null,
"Examples": null
"Examples": [
[
"{{ 512.5032 | lang.FormatAccounting 2 \"NOK\" }}",
"NOK512.50"
]
]
},
"NumFmt": {
"Description": "NumFmt formats a number with the given precision using the\nnegative, decimal, and grouping options. The `options`\nparameter is a string consisting of `\u003cnegative\u003e \u003cdecimal\u003e \u003cgrouping\u003e`. The\ndefault `options` value is `- . ,`.\n\nNote that numbers are rounded up at 5 or greater.\nSo, with precision set to 0, 1.5 becomes `2`, and 1.4 becomes `1`.",
"FormatCurrency": {
"Description": "FormatCurrency returns the currency reprecentation of number for the given currency and precision\nfor the current language.",
"Args": [
"precision",
"currency",
"number"
],
"Aliases": null,
"Examples": [
[
"{{ 512.5032 | lang.FormatCurrency 2 \"USD\" }}",
"$512.50"
]
]
},
"FormatNumber": {
"Description": "FormatNumber formats number with the given precision for the current language.",
"Args": [
"precision",
"number"
],
"Aliases": null,
"Examples": [
[
"{{ 512.5032 | lang.FormatNumber 2 }}",
"512.50"
]
]
},
"FormatNumberCustom": {
"Description": "FormatNumberCustom formats a number with the given precision using the\nnegative, decimal, and grouping options. The `options`\nparameter is a string consisting of `\u003cnegative\u003e \u003cdecimal\u003e \u003cgrouping\u003e`. The\ndefault `options` value is `- . ,`.\n\nNote that numbers are rounded up at 5 or greater.\nSo, with precision set to 0, 1.5 becomes `2`, and 1.4 becomes `1`.\n\nFor a simpler function that adapts to the current language, see FormatNumberCustom.",
"Args": [
"precision",
"number",
@ -3914,19 +3956,19 @@
"Aliases": null,
"Examples": [
[
"{{ lang.NumFmt 2 12345.6789 }}",
"{{ lang.FormatNumberCustom 2 12345.6789 }}",
"12,345.68"
],
[
"{{ lang.NumFmt 2 12345.6789 \"- , .\" }}",
"{{ lang.FormatNumberCustom 2 12345.6789 \"- , .\" }}",
"12.345,68"
],
[
"{{ lang.NumFmt 6 -12345.6789 \"- .\" }}",
"{{ lang.FormatNumberCustom 6 -12345.6789 \"- .\" }}",
"-12345.678900"
],
[
"{{ lang.NumFmt 0 -12345.6789 \"- . ,\" }}",
"{{ lang.FormatNumberCustom 0 -12345.6789 \"- . ,\" }}",
"-12,346"
],
[
@ -3935,6 +3977,32 @@
]
]
},
"FormatPercent": {
"Description": "FormatPercent formats number with the given precision for the current language.\nNote that the number is assumbed to be percent.",
"Args": [
"precision",
"number"
],
"Aliases": null,
"Examples": [
[
"{{ 512.5032 | lang.FormatPercent 2 }}",
"512.50%"
]
]
},
"Merge": {
"Description": "",
"Args": null,
"Aliases": null,
"Examples": null
},
"NumFmt": {
"Description": "",
"Args": null,
"Aliases": null,
"Examples": null
},
"Translate": {
"Description": "Translate returns a translated string for id.",
"Args": [

View File

@ -0,0 +1,54 @@
{{ $pkg := .Params.package}}
{{ $funcs := index site.Data.docs.tpl.funcs $pkg }}
{{ range $k, $v := $funcs }}
{{ if $v.Description }}
{{ $func := printf "%s.%s" $pkg $k }}
<h2>
<a class="header-link" href="#{{ $func | anchorize | safeURL }}">
<svg class="fill-current o-60 hover-accent-color-light" height="22px" viewBox="0 0 24 24" width="22px" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
</svg>
</a>
{{ $func }}
</h2>
{{ with $v.Description }}
<p class="f4 lh-copy">
{{ . | $.RenderString | safeHTML }}
</p>
{{ end }}
<h4 class="minor mb3 pt2 primary-color-dark">
Syntax
</h4>
<div class="f5 mb4 ph3 pv2 bg-light-gray" style="border-left:4px solid #0594CB;">
{{ $pkg }}.{{ $k }}
{{ with $v.Args }}
<span class="ttu">
{{ delimit $v.Args ", "}}
</span>
{{ end }}
<span></span>
</div>
{{ if $v.Examples }}
<h4 class="minor mb3 pt2 primary-color-dark">
Examples
</h4>
{{ end }}
{{ range $v.Examples }}
{{ $input := index . 0 }}
{{ $result := index . 1 }}
{{ $example := printf "%s ---> %s" $input $result }}
{{ highlight $example "go-html-template" "" }}
{{ end }}
{{ with $v.Aliases }}
<h4 class="minor mb3 pt2 primary-color-dark">
Aliases
</h4>
<p>
{{ delimit . ", "}}
</p>
{{ end }}
{{ end }}
{{ end }}

View File

@ -3,7 +3,7 @@ publish = "public"
command = "hugo --gc --minify"
[context.production.environment]
HUGO_VERSION = "0.85.0"
HUGO_VERSION = "0.86.1"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
command = "hugo --gc --minify --enableGitInfo"
[context.split1.environment]
HUGO_VERSION = "0.85.0"
HUGO_VERSION = "0.86.1"
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.deploy-preview.environment]
HUGO_VERSION = "0.85.0"
HUGO_VERSION = "0.86.1"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
[context.branch-deploy.environment]
HUGO_VERSION = "0.85.0"
HUGO_VERSION = "0.86.1"
[context.next.environment]
HUGO_ENABLEGITINFO = "true"

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Some files were not shown because too many files have changed in this diff Show More