Merge commit '7125ad401ad043e46262afc7eca8dceb6d54bb9e'

This commit is contained in:
Bjørn Erik Pedersen
2024-01-26 08:22:42 +01:00
141 changed files with 904 additions and 813 deletions

View File

@@ -63,8 +63,9 @@ And this template:
{{ with .AllTranslations }}
<ul>
{{ range . }}
{{ $lang := .Language.LanguageName}}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }} ({{ $lang }})</a></li>
{{ $langName := or .Language.LanguageName .Language.Lang }}
{{ $langCode := or .Language.LanguageCode .Language.Lang }}
<li><a href="{{ .RelPermalink }}" hreflang="{{ $langCode }}">{{ .LinkTitle }} ({{ $langName }})</a></li>
{{ end }}
</ul>
{{ end }}
@@ -74,9 +75,9 @@ Hugo will render this list on the "Book 1" page of each site:
```html
<ul>
<li><a href="/books/book-1/">Book 1 (English)</a></li>
<li><a href="/de/books/book-1/">Book 1 (Deutsch)</a></li>
<li><a href="/fr/books/book-1/">Book 1 (Français)</a></li>
<li><a href="/books/book-1/" hreflang="en-US">Book 1 (English)</a></li>
<li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
<li><a href="/fr/books/book-1/" hreflang="fr-FR">Book 1 (Français)</a></li>
</ul>
```
@@ -84,7 +85,7 @@ On the "Book 2" page of the English and German sites, Hugo will render this:
```html
<ul>
<li><a href="/books/book-1/">Book 1 (English)</a></li>
<li><a href="/de/books/book-1/">Book 1 (Deutsch)</a></li>
<li><a href="/books/book-1/" hreflang="en-US">Book 1 (English)</a></li>
<li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
</ul>
```

View File

@@ -29,7 +29,7 @@ enableGitInfo = true
Consider this project structure:
```text
hugo-testing/
my-project/
├── content/
│ ├── books/
│ │ └── les-miserables.md

View File

@@ -12,7 +12,7 @@ action:
- methods/page/IsDescendant
- methods/page/Parent
- methods/page/Sections
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.CurrentSection]
---

View File

@@ -30,8 +30,9 @@ Code defensively by verifying file existence as shown in each of the examples be
The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend on the operating system.
{{% /note %}}
BaseFileName
: (`string`) The file name, excluding the extension.
###### BaseFileName
(`string`) The file name, excluding the extension.
```go-html-template
{{ with .File }}
@@ -39,8 +40,9 @@ BaseFileName
{{ end }}
```
ContentBaseName
: (`string`) If the page is a branch or leaf bundle, the name of the containing directory, else the `TranslationBaseName`.
###### ContentBaseName
(`string`) If the page is a branch or leaf bundle, the name of the containing directory, else the `TranslationBaseName`.
```go-html-template
{{ with .File }}
@@ -48,8 +50,9 @@ ContentBaseName
{{ end }}
```
Dir
: (`string`) The file path, excluding the file name, relative to the `content` directory.
###### Dir
(`string`) The file path, excluding the file name, relative to the `content` directory.
```go-html-template
{{ with .File }}
@@ -57,8 +60,9 @@ Dir
{{ end }}
```
Ext
: (`string`) The file extension.
###### Ext
(`string`) The file extension.
```go-html-template
{{ with .File }}
@@ -66,8 +70,9 @@ Ext
{{ end }}
```
Filename
: (`string`) The absolute file path.
###### Filename
(`string`) The absolute file path.
```go-html-template
{{ with .File }}
@@ -75,8 +80,9 @@ Filename
{{ end }}
```
Lang
: (`string`) The language associated with the given file.
###### Lang
(`string`) The language associated with the given file.
```go-html-template
{{ with .File }}
@@ -84,8 +90,9 @@ Lang
{{ end }}
```
LogicalName
: (`string`) The file name.
###### LogicalName
(`string`) The file name.
```go-html-template
{{ with .File }}
@@ -93,8 +100,9 @@ LogicalName
{{ end }}
```
Path
: (`string`) The file path, relative to the `content` directory.
###### Path
(`string`) The file path, relative to the `content` directory.
```go-html-template
{{ with .File }}
@@ -102,8 +110,9 @@ Path
{{ end }}
```
TranslationBaseName
: (`string`) The file name, excluding the extension and language identifier.
###### TranslationBaseName
(`string`) The file name, excluding the extension and language identifier.
```go-html-template
{{ with .File }}
@@ -111,8 +120,9 @@ TranslationBaseName
{{ end }}
```
UniqueID
: (`string`) The MD5 hash of `.File.Path`.
###### UniqueID
(`string`) The MD5 hash of `.File.Path`.
```go-html-template
{{ with .File }}

View File

@@ -12,7 +12,7 @@ action:
- methods/page/IsDescendant
- methods/page/Parent
- methods/page/Sections
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.FirstSection]
---

View File

@@ -28,14 +28,14 @@ Use the `Fragments` method on a `Page` object to create a table of contents with
## Methods
Headings
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Title` and `Headings`. To inspect the data structure:
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
```go-html-template
<pre>{{ .Fragments.Headings | jsonify (dict "indent" " ") }}</pre>
```
HeadingsMap
: (`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Title` and `Headings`. To inspect the data structure:
: (`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
```go-html-template
<pre>{{ .Fragments.HeadingsMap | jsonify (dict "indent" " ") }}</pre>

View File

@@ -6,7 +6,7 @@ keywords: []
action:
related:
- methods/site/GetPage
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.GetPage PATH]
aliases: [/functions/getpage]
---

View File

@@ -34,7 +34,7 @@ hugo --enableGitInfo
```
{{% note %}}
When you set `enableGitInto` to `true`, or enable the feature with the command line flag, the last modification date for each content page will be the Author Date of the last commit for that file.
When you set `enableGitInfo` to `true`, or enable the feature with the command line flag, the last modification date for each content page will be the Author Date of the last commit for that file.
This is configurable. See&nbsp;[details].
@@ -43,8 +43,9 @@ This is configurable. See&nbsp;[details].
## Methods
AbbreviatedHash
: (`string`) The abbreviated commit hash.
###### AbbreviatedHash
(`string`) The abbreviated commit hash.
```go-html-template
{{ with .GitInfo }}
@@ -52,8 +53,9 @@ AbbreviatedHash
{{ end }}
```
AuthorDate
: (`time.Time`) The author date.
###### AuthorDate
(`time.Time`) The author date.
```go-html-template
{{ with .GitInfo }}
@@ -61,8 +63,9 @@ AuthorDate
{{ end }}
```
AuthorEmail
: (`string`) The author's email address, respecting [gitmailmap].
###### AuthorEmail
(`string`) The author's email address, respecting [gitmailmap].
```go-html-template
{{ with .GitInfo }}
@@ -70,8 +73,9 @@ AuthorEmail
{{ end }}
```
AuthorName
: (`string`) The author's name, respecting [gitmailmap].
###### AuthorName
(`string`) The author's name, respecting [gitmailmap].
```go-html-template
{{ with .GitInfo }}
@@ -79,8 +83,19 @@ AuthorName
{{ end }}
```
Hash
: (`string`) The commit hash.
###### CommitDate
(`time.Time`) The commit date.
```go-html-template
{{ with .GitInfo }}
{{ .CommitDate.Format "2006-01-02" }} → 2023-10-09
{{ end }}
```
###### Hash
(`string`) The commit hash.
```go-html-template
{{ with .GitInfo }}
@@ -88,8 +103,9 @@ Hash
{{ end }}
```
Subject
: (`string`) The commit message subject.
###### Subject
(`string`) The commit message subject.
```go-html-template
{{ with .GitInfo }}

View File

@@ -10,7 +10,7 @@ action:
- methods/page/PrevInSection
- methods/pages/Next
- methods/pages/Prev
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.Next]
toc: true
---

View File

@@ -10,7 +10,7 @@ action:
- methods/page/Prev
- methods/pages/Next
- methods/pages/Prev
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.NextInSection]
---

View File

@@ -5,7 +5,7 @@ categories: []
keywords: []
action:
related: []
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.Page]
---

View File

@@ -18,7 +18,6 @@ With this front matter:
title = 'Annual conference'
date = 2023-10-17T15:11:37-07:00
display_related = true
event-date = '2023'
[params.author]
email = 'jsmith@example.org'
name = 'John Smith'
@@ -36,8 +35,9 @@ Access the custom parameters by [chaining] the [identifiers]:
In the template example above, each of the keys is a valid identifier. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the [`index`] function:
```go-html-template
{{ index .Params "event-date" }} → 2023
{{ index .Params "key-with-hyphens" }} → 2023
```
[`index`]: /functions/collections/indexfunction
[chaining]: /getting-started/glossary/#chain
[identifiers]: /getting-started/glossary/#identifier

View File

@@ -12,7 +12,7 @@ action:
- methods/page/IsAncestor
- methods/page/IsDescendant
- methods/page/Sections
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.Parent]
---

View File

@@ -21,5 +21,5 @@ Template:
```go-html-template
{{ $page := .Site.GetPage "/about" }}
{{ $page.RelPermalink }} → https://example.org/docs/about/
{{ $page.Permalink }} → https://example.org/docs/about/
```

View File

@@ -10,7 +10,7 @@ action:
- methods/page/NextInSection
- methods/pages/Prev
- methods/pages/Next
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.Prev]
toc: true
---

View File

@@ -10,7 +10,7 @@ action:
- methods/pages/Next
- methods/page/Prev
- methods/pages/Prev
returnType: hugolib.pageState
returnType: page.Page
signatures: [PAGE.PrevInSection]
---

View File

@@ -21,5 +21,5 @@ Template:
```go-html-template
{{ $page := .Site.GetPage "/about" }}
{{ $page.Permalink }} → /docs/about/
{{ $page.RelPermalink }} → /docs/about/
```

View File

@@ -21,8 +21,9 @@ To work with global or remote resources, see the [`resources`] functions.
## Methods
ByType
: (`resource.Resources`) Returns a collection of page resources of the given [media type], or nil if none found. The media type is typically one of `image`, `text`, `audio`, `video`, or `application`.
###### ByType
(`resource.Resources`) Returns a collection of page resources of the given [media type], or nil if none found. The media type is typically one of `image`, `text`, `audio`, `video`, or `application`.
```go-html-template
{{ range .Resources.ByType "image" }}
@@ -32,8 +33,9 @@ ByType
When working with global resources instead of page resources, use the [`resources.ByType`] function.
Get
: (`resource.Resource`) Returns a page resource from the given path, or nil if none found.
###### Get
(`resource.Resource`) Returns a page resource from the given path, or nil if none found.
```go-html-template
{{ with .Resources.Get "images/a.jpg" }}
@@ -43,8 +45,9 @@ Get
When working with global resources instead of page resources, use the [`resources.Get`] function.
GetMatch
: (`resource.Resource`) Returns the first page resource from paths matching the given [glob pattern], or nil if none found.
###### GetMatch
(`resource.Resource`) Returns the first page resource from paths matching the given [glob pattern], or nil if none found.
```go-html-template
{{ with .Resources.GetMatch "images/*.jpg" }}
@@ -54,8 +57,9 @@ GetMatch
When working with global resources instead of page resources, use the [`resources.GetMatch`] function.
Match
: (`resource.Resources`) Returns a collection of page resources from paths matching the given [glob pattern], or nil if none found.
###### Match
(`resource.Resources`) Returns a collection of page resources from paths matching the given [glob pattern], or nil if none found.
```go-html-template
{{ range .Resources.Match "images/*.jpg" }}

View File

@@ -22,25 +22,28 @@ To create a locally scoped scratch pad that is not attached to a `Page` object,
## Methods
Set
: Sets the value of a given key.
###### Set
Sets the value of a given key.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}
```
Get
: Gets the value of a given key.
###### Get
Gets the value of a given key.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}
{{ .Store.Get "greeting" }} → Hello
```
Add
: Adds a given value to existing value(s) of the given key.
###### Add
: For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list.
Adds a given value to existing value(s) of the given key.
For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}
@@ -60,8 +63,9 @@ Add
{{ .Store.Get "greetings" }} → [Hello Welcome Cheers]
```
SetInMap
: Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`.
###### SetInMap
Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`.
```go-html-template
{{ .Store.SetInMap "greetings" "english" "Hello" }}
@@ -69,8 +73,9 @@ SetInMap
{{ .Store.Get "greetings" }} → map[english:Hello french:Bonjour]
```
DeleteInMap
: Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`.
###### DeleteInMap
Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`.
```go-html-template
{{ .Store.SetInMap "greetings" "english" "Hello" }}
@@ -79,8 +84,9 @@ DeleteInMap
{{ .Store.Get "greetings" }} → map[french:Bonjour]
```
GetSortedMapValues
: Returns an array of values from `key` sorted by `mapKey`.
###### GetSortedMapValues
Returns an array of values from `key` sorted by `mapKey`.
```go-html-template
{{ .Store.SetInMap "greetings" "english" "Hello" }}
@@ -88,8 +94,9 @@ GetSortedMapValues
{{ .Store.GetSortedMapValues "greetings" }} → [Hello Bonjour]
```
Delete
: Removes the given key.
###### Delete
Removes the given key.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}

View File

@@ -63,8 +63,9 @@ And this template:
{{ with .Translations }}
<ul>
{{ range . }}
{{ $lang := .Language.LanguageName}}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }} ({{ $lang }})</a></li>
{{ $langName := or .Language.LanguageName .Language.Lang }}
{{ $langCode := or .Language.LanguageCode .Language.Lang }}
<li><a href="{{ .RelPermalink }}" hreflang="{{ $langCode }}">{{ .LinkTitle }} ({{ $langName }})</a></li>
{{ end }}
</ul>
{{ end }}
@@ -74,8 +75,8 @@ Hugo will render this list on the "Book 1" page of the English site:
```html
<ul>
<li><a href="/de/books/book-1/">Book 1 (Deutsch)</a></li>
<li><a href="/fr/books/book-1/">Book 1 (Français)</a></li>
<li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
<li><a href="/fr/books/book-1/" hreflang="fr-FR">Book 1 (Français)</a></li>
</ul>
```
@@ -83,6 +84,6 @@ Hugo will render this list on the "Book 2" page of the English site:
```html
<ul>
<li><a href="/de/books/book-1/">Book 1 (Deutsch)</a></li>
<li><a href="/de/books/book-1/" hreflang="de-DE">Book 1 (Deutsch)</a></li>
</ul>
```

View File

@@ -4,25 +4,28 @@
## Methods
Set
: Sets the value of a given key.
###### Set
Sets the value of a given key.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}
```
Get
: Gets the value of a given key.
###### Get
Gets the value of a given key.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}
{{ .Scratch.Get "greeting" }} → Hello
```
Add
: Adds a given value to existing value(s) of the given key.
###### Add
: For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list.
Adds a given value to existing value(s) of the given key.
For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}
@@ -42,8 +45,9 @@ Add
{{ .Scratch.Get "greetings" }} → [Hello Welcome Cheers]
```
SetInMap
: Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`.
###### SetInMap
Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`.
```go-html-template
{{ .Scratch.SetInMap "greetings" "english" "Hello" }}
@@ -51,8 +55,9 @@ SetInMap
{{ .Scratch.Get "greetings" }} → map[english:Hello french:Bonjour]
```
DeleteInMap
: Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`.
###### DeleteInMap
Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`.
```go-html-template
{{ .Scratch.SetInMap "greetings" "english" "Hello" }}
@@ -61,8 +66,9 @@ DeleteInMap
{{ .Scratch.Get "greetings" }} → map[french:Bonjour]
```
GetSortedMapValues
: Returns an array of values from `key` sorted by `mapKey`.
###### GetSortedMapValues
Returns an array of values from `key` sorted by `mapKey`.
```go-html-template
{{ .Scratch.SetInMap "greetings" "english" "Hello" }}
@@ -70,8 +76,9 @@ GetSortedMapValues
{{ .Scratch.GetSortedMapValues "greetings" }} → [Hello Bonjour]
```
Delete
: Removes the given key.
###### Delete
Removes the given key.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}