Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul van Brouwershaven <vanbroup@users.noreply.github.com>2021-11-30 13:49:51 +0300
committerGitHub <noreply@github.com>2021-11-30 13:49:51 +0300
commit8aa7257f652ebea70dfbb819c301800f5c25b567 (patch)
tree188863b9a6e35c0826ab765b499cb411747a2358 /docs/content/en
parent75a823a36a75781c0c5d89fe9f328e3b9322d95f (diff)
Add remote support to resources.Get
Closes #5255 Supports #9044
Diffstat (limited to 'docs/content/en')
-rwxr-xr-xdocs/content/en/hugo-pipes/introduction.md31
1 files changed, 29 insertions, 2 deletions
diff --git a/docs/content/en/hugo-pipes/introduction.md b/docs/content/en/hugo-pipes/introduction.md
index bd5bfdc4c..7a0ce5fc5 100755
--- a/docs/content/en/hugo-pipes/introduction.md
+++ b/docs/content/en/hugo-pipes/introduction.md
@@ -20,12 +20,39 @@ aliases: [/assets/]
Asset files must be stored in the asset directory. This is `/assets` by default, but can be configured via the configuration file's `assetDir` key.
-### From file to resource
+### From file or URL to resource
-In order to process an asset with Hugo Pipes, it must be retrieved as a resource using `resources.Get`, which takes one argument: the filepath of the file relative to the asset directory.
+In order to process an asset with Hugo Pipes, it must be retrieved as a resource using `resources.Get`. The first argument can be the filepath of the file relative to the asset directory or the URL of the file.
```go-html-template
{{ $style := resources.Get "sass/main.scss" }}
+{{ $remoteStyle := resources.Get "https://www.example.com/styles.scss" }}
+```
+
+#### Request options
+
+When using an URL, the `resources.Get` function takes an optional options map as the last argument, e.g.:
+
+```
+{{ $resource := resources.Get "https://example.org/api" (dict "headers" (dict "Authorization" "Bearer abcd")) }}
+```
+
+If you need multiple values for the same header key, use a slice:
+
+```
+{{ $resource := resources.Get "https://example.org/api" (dict "headers" (dict "X-List" (slice "a" "b" "c"))) }}
+```
+
+You can also change the request method and set the request body:
+
+```
+{{ $postResponse := resources.Get "https://example.org/api" (dict
+ "method" "post"
+ "body" `{"complete": true}`
+ "headers" (dict
+ "Content-Type" "application/json"
+ )
+)}}
```
### Asset publishing