Skip to content

Commit

Permalink
Clarify the distinction between resources and .Resources
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSD committed Oct 17, 2021
1 parent 39a7fac commit 89192b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions content/en/content-management/page-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ menu:
parent: "content-management"
weight: 31
---
Page resources are only accessible from [page bundles]({{< relref
"/content-management/page-bundles" >}}), those directories with `index.md` or
`_index.md` files at their root. Page resources are only available to the
page with which they are bundled.
Page resources are only accessible from [page bundles]({{< relref "/content-management/page-bundles" >}}), those directories with `index.md` or `_index.md` files at their root. Page resources are accessible through `.Resources`, but only on the page with which they are bundled. Page resources are separate from [asset resources]({{< relref "/hugo-pipes/introduction/" >}}) which are accessible through `resources`.

In this example, `first-post` is a page bundle with access to 10 page resources including audio, data, documents, images, and video. Although `second-post` is also a page bundle, it has no page resources and is unable to directly access the page resources associated with `first-post`.

Expand Down Expand Up @@ -75,6 +72,7 @@ MediaType.Suffixes
: A slice of possible suffixes for the resource's MIME type.

## Methods

ByType
: Returns the page resources of the given type.

Expand All @@ -91,6 +89,8 @@ Match
GetMatch
: Same as `Match` but will return the first match.

Note that unlike [asset resources]({{< relref "/hugo-pipes/introduction/" >}}) which support a `resources.Get` method, there is no `.Resources.Get` method for page resources. `.Resources.GetMatch` should be used for this purpose.

### Pattern Matching
```go
// Using Match/GetMatch to find this images/sunset.jpg ?
Expand Down
2 changes: 2 additions & 0 deletions content/en/hugo-pipes/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ In order to process an asset with Hugo Pipes, it must be retrieved as a resource
{{ $style := resources.Get "sass/main.scss" }}
```

Note that `resources` is separate from `.Resources`, which is used for [page resources]({{< relref "/content-management/page-resources/" >}}).

### Asset publishing

Assets will only be published (to `/public`) if `.Permalink` or `.RelPermalink` is used.
Expand Down

0 comments on commit 89192b6

Please sign in to comment.