mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Merge commit '7125ad401ad043e46262afc7eca8dceb6d54bb9e'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: resources.Concat
|
||||
description: Concatenates a slice of resources.
|
||||
description: Returns a concatenated slice of resources.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
@@ -10,12 +10,17 @@ action:
|
||||
signatures: ['resources.Concat TARGETPATH [RESOURCE...]']
|
||||
---
|
||||
|
||||
The `resources.Concat` function returns a concatenated slice of resources, caching the result using the target path as its cache key. Each resource must have the same [media type].
|
||||
|
||||
Hugo publishes the resource to the target path when you call its [`Publish`], [`Permalink`], or [`RelPermalink`] methods.
|
||||
|
||||
[media type]: https://en.wikipedia.org/wiki/Media_type
|
||||
[`publish`]: /methods/resource/publish
|
||||
[`permalink`]: /methods/resource/permalink
|
||||
[`relpermalink`]: /methods/resource/relpermalink
|
||||
|
||||
```go-html-template
|
||||
{{ $plugins := resources.Get "js/plugins.js" }}
|
||||
{{ $global := resources.Get "js/global.js" }}
|
||||
{{ $js := slice $plugins $global | resources.Concat "js/bundle.js" }}
|
||||
```
|
||||
|
||||
Asset files of the same [media type] can be bundled into one resource using the `resources.Concat` function which takes two arguments, the target path for the created resource bundle and a slice of resource objects to be concatenated.
|
||||
|
||||
[media type]: https://en.wikipedia.org/wiki/Media_type
|
||||
|
Reference in New Issue
Block a user