mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 14:40:43 +03:00
Merge commit 'd276e901b3
'
This commit is contained in:
commit
d7497b28c1
28 changed files with 663 additions and 389 deletions
|
@ -17,11 +17,11 @@ If [Goldmark](https://gohugo.io/getting-started/configuration-markup#goldmark) i
|
|||
|
||||
Since the `defaultMarkdownHandler` and this template function use the same sanitizing logic, you can use the latter to determine the ID of a header for linking with anchor tags.
|
||||
|
||||
```
|
||||
{{anchorize "This is a header"}} → "this-is-a-header"
|
||||
{{anchorize "This is also a header"}} → "this-is-also-a-header"
|
||||
{{anchorize "main.go"}} → "main-go"
|
||||
{{anchorize "Article 123"}} → "article-123"
|
||||
{{anchorize "<- Let's try this, shall we?"}} → "let-s-try-this-shall-we"
|
||||
{{anchorize "Hello, 世界"}} → "hello-世界"
|
||||
```go-html-template
|
||||
{{ anchorize "This is a header" }} --> "this-is-a-header"
|
||||
{{ anchorize "This is also a header" }} --> "this-is-also----a-header"
|
||||
{{ anchorize "main.go" }} --> "maingo"
|
||||
{{ anchorize "Article 123" }} --> "article-123"
|
||||
{{ anchorize "<- Let's try this, shall we?" }} --> "--lets-try-this-shall-we"
|
||||
{{ anchorize "Hello, 世界" }} --> "hello-世界"
|
||||
```
|
||||
|
|
|
@ -25,14 +25,9 @@ An example appending single values:
|
|||
|
||||
The same example appending a slice to a slice:
|
||||
|
||||
|
||||
```go-html-template
|
||||
{{ $s := slice "a" "b" "c" }}
|
||||
{{ $s = $s | append (slice "d" "e") }}
|
||||
```
|
||||
|
||||
The `append` function works for all types, including `Pages`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -64,13 +64,13 @@ If you have `post-tag-list.html` and `post-tag-link.html` as [partials][], you *
|
|||
Tags:
|
||||
{{ $len := len . }}
|
||||
{{ if eq $len 1 }}
|
||||
{{ partial "post-tag-link" (index . 0) }}
|
||||
{{ partial "post-tag-link.html" (index . 0) }}
|
||||
{{ else }}
|
||||
{{ $last := sub $len 1 }}
|
||||
{{ range first $last . }}
|
||||
{{ partial "post-tag-link" . }},
|
||||
{{ partial "post-tag-link.html" . }},
|
||||
{{ end }}
|
||||
{{ partial "post-tag-link" (index . $last) }}
|
||||
{{ partial "post-tag-link.html" (index . $last) }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
@ -89,7 +89,7 @@ This first version of `layouts/partials/post-tag-list.html` separates all of the
|
|||
<div class="tags-list">
|
||||
Tags:
|
||||
{{ $sort := sort . }}
|
||||
{{ $links := apply $sort "partial" "post-tag-link" "." }}
|
||||
{{ $links := apply $sort "partial" "post-tag-link.html" "." }}
|
||||
{{ $clean := apply $links "chomp" "." }}
|
||||
{{ delimit $clean ", " }}
|
||||
</div>
|
||||
|
@ -102,7 +102,7 @@ Now in the completed version, you can sort the tags, convert the tags to links w
|
|||
{{ with .Params.tags }}
|
||||
<div class="tags-list">
|
||||
Tags:
|
||||
{{ delimit (apply (apply (sort .) "partial" "post-tag-link" ".") "chomp" ".") ", " }}
|
||||
{{ delimit (apply (apply (sort .) "partial" "post-tag-link.html" ".") "chomp" ".") ", " }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
|
|
@ -28,10 +28,4 @@ hugoversion: "0.49"
|
|||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
||||
|
||||
|
||||
The page group you get from `group` is of the same type you get from the built-in [group methods](/templates/lists#group-content) in Hugo. The above example can even be [paginated](/templates/pagination/#list-paginator-pages).
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ linktitle: hugo
|
|||
description: The `hugo` function provides easy access to Hugo-related data.
|
||||
date: 2019-01-31
|
||||
publishdate: 2019-01-31
|
||||
lastmod: 2019-01-31
|
||||
keywords: []
|
||||
categories: [functions]
|
||||
menu:
|
||||
|
@ -60,17 +59,17 @@ hugo.Deps
|
|||
|
||||
`hugo.Deps` returns a list of dependencies for a project (either Hugo Modules or local theme components).
|
||||
|
||||
Eeach dependency contains:
|
||||
Each dependency contains:
|
||||
|
||||
Path (string)
|
||||
: Returns the path to this module. This will either be the module path, e.g. "github.com/gohugoio/myshortcodes", or the path below your /theme folder, e.g. "mytheme".
|
||||
|
||||
Version (string)
|
||||
: The module version.
|
||||
|
||||
|
||||
Vendor (bool)
|
||||
: Whether this dependency is vendored.
|
||||
|
||||
|
||||
Time (time.Time)
|
||||
: Time version was created.
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ title: relURL
|
|||
description: Creates a baseURL-relative URL.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
|
@ -31,7 +30,7 @@ The last two examples may look strange but can be very useful. For example, the
|
|||
{{< code file="layouts/partials/schemaorg-metadata.html" download="schemaorg-metadata.html" >}}
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context" : "http://schema.org",
|
||||
"@context" : "https://schema.org",
|
||||
"@type" : "BlogPosting",
|
||||
"image" : {{ apply .Params.images "absURL" "." }}
|
||||
}
|
||||
|
@ -46,5 +45,5 @@ The above uses the [apply function][] and also exposes how the Go template parse
|
|||
|
||||
[apply function]: /functions/apply/
|
||||
[configuration]: /getting-started/configuration/
|
||||
[jsonld]: https://developers.google.com/search/docs/guides/intro-structured-data
|
||||
[jsonld]: https://developers.google.com/search/docs/advanced/structured-data/intro-structured-data
|
||||
[safejs]: /functions/safejs
|
||||
|
|
|
@ -23,7 +23,7 @@ If `SUBSTR` is an empty string, this function returns 1 plus the number of Unico
|
|||
|
||||
Example|Result
|
||||
:--|:--
|
||||
`{{ "aaabaab" | strings.Count "a" }}`|5
|
||||
`{{ "aaabaab" | strings.Count "aa" }}`|2
|
||||
`{{ "aaabaab" | strings.Count "aaa" }}`|1
|
||||
`{{ "aaabaab" | strings.Count "" }}`|8
|
||||
`{{ "aaabaab" \| strings.Count "a" }}`|5
|
||||
`{{ "aaabaab" \| strings.Count "aa" }}`|2
|
||||
`{{ "aaabaab" \| strings.Count "aaa" }}`|1
|
||||
`{{ "aaabaab" \| strings.Count "" }}`|8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue