Add id attributes to GitInfo, File, and Resources methods

This commit is contained in:
Joe Mooring 2023-12-22 09:43:56 -08:00 committed by GitHub
parent b12d9cb8fa
commit 2a1adea798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 48 deletions

View File

@ -1,5 +1,6 @@
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md # https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
MD001: false
MD002: false MD002: false
MD003: false MD003: false
MD004: false MD004: false

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

View File

@ -43,8 +43,9 @@ This is configurable. See [details].
## Methods ## Methods
AbbreviatedHash ###### AbbreviatedHash
: (`string`) The abbreviated commit hash.
(`string`) The abbreviated commit hash.
```go-html-template ```go-html-template
{{ with .GitInfo }} {{ with .GitInfo }}
@ -52,8 +53,9 @@ AbbreviatedHash
{{ end }} {{ end }}
``` ```
AuthorDate ###### AuthorDate
: (`time.Time`) The author date.
(`time.Time`) The author date.
```go-html-template ```go-html-template
{{ with .GitInfo }} {{ with .GitInfo }}
@ -61,17 +63,9 @@ AuthorDate
{{ end }} {{ end }}
``` ```
CommitDate ###### AuthorEmail
: (`time.Time`) The commit date.
```go-html-template (`string`) The author's email address, respecting [gitmailmap].
{{ with .GitInfo }}
{{ .CommitDate.Format "2006-01-02" }} → 2023-10-09
{{ end }}
```
AuthorEmail
: (`string`) The author's email address, respecting [gitmailmap].
```go-html-template ```go-html-template
{{ with .GitInfo }} {{ with .GitInfo }}
@ -79,8 +73,9 @@ AuthorEmail
{{ end }} {{ end }}
``` ```
AuthorName ###### AuthorName
: (`string`) The author's name, respecting [gitmailmap].
(`string`) The author's name, respecting [gitmailmap].
```go-html-template ```go-html-template
{{ with .GitInfo }} {{ with .GitInfo }}
@ -88,8 +83,19 @@ AuthorName
{{ end }} {{ end }}
``` ```
Hash ###### CommitDate
: (`string`) The commit hash.
(`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 ```go-html-template
{{ with .GitInfo }} {{ with .GitInfo }}
@ -97,8 +103,9 @@ Hash
{{ end }} {{ end }}
``` ```
Subject ###### Subject
: (`string`) The commit message subject.
(`string`) The commit message subject.
```go-html-template ```go-html-template
{{ with .GitInfo }} {{ with .GitInfo }}

View File

@ -21,8 +21,9 @@ To work with global or remote resources, see the [`resources`] functions.
## Methods ## Methods
ByType ###### 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`.
(`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 ```go-html-template
{{ range .Resources.ByType "image" }} {{ range .Resources.ByType "image" }}
@ -32,8 +33,9 @@ ByType
When working with global resources instead of page resources, use the [`resources.ByType`] function. When working with global resources instead of page resources, use the [`resources.ByType`] function.
Get ###### Get
: (`resource.Resource`) Returns a page resource from the given path, or nil if none found.
(`resource.Resource`) Returns a page resource from the given path, or nil if none found.
```go-html-template ```go-html-template
{{ with .Resources.Get "images/a.jpg" }} {{ 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. When working with global resources instead of page resources, use the [`resources.Get`] function.
GetMatch ###### GetMatch
: (`resource.Resource`) Returns the first page resource from paths matching the given [glob pattern], or nil if none found.
(`resource.Resource`) Returns the first page resource from paths matching the given [glob pattern], or nil if none found.
```go-html-template ```go-html-template
{{ with .Resources.GetMatch "images/*.jpg" }} {{ with .Resources.GetMatch "images/*.jpg" }}
@ -54,8 +57,9 @@ GetMatch
When working with global resources instead of page resources, use the [`resources.GetMatch`] function. When working with global resources instead of page resources, use the [`resources.GetMatch`] function.
Match ###### Match
: (`resource.Resources`) Returns a collection of page resources from paths matching the given [glob pattern], or nil if none found.
(`resource.Resources`) Returns a collection of page resources from paths matching the given [glob pattern], or nil if none found.
```go-html-template ```go-html-template
{{ range .Resources.Match "images/*.jpg" }} {{ range .Resources.Match "images/*.jpg" }}