Merge commit '00c4484c7092181729f6f470805bc7d72e8ad17b'

This commit is contained in:
Bjørn Erik Pedersen
2022-11-17 16:16:19 +01:00
217 changed files with 2437 additions and 2821 deletions

View File

@@ -1,17 +1,15 @@
---
title : "Page Resources"
description : "Page resources -- images, other pages, documents, etc. -- have page-relative URLs and their own metadata."
date: 2018-01-24
categories: ["content management"]
title: Page Resources
linkTitle: Page Resources
description: Page resources -- images, other pages, documents, etc. -- have page-relative URLs and their own metadata.
categories: [content management]
keywords: [bundle,content,resources]
weight: 4003
draft: false
toc: true
linktitle: "Page Resources"
menu:
docs:
parent: "content-management"
weight: 31
parent: content-management
weight: 80
toc: true
weight: 80
---
Page resources are only accessible from [page bundles]({{< relref
"/content-management/page-bundles" >}}), those directories with `index.md` or
@@ -45,8 +43,6 @@ content
ResourceType
: The main type of the resource's [Media Type](/templates/output-formats/#media-types). For example, a file of MIME type `image/jpeg` has the ResourceType `image`. A `Page` will have `ResourceType` with value `page`.
{{< new-in "0.80.0" >}} Note that we in Hugo `v0.80.0` fixed a bug where non-image resources (e.g. video) would return the MIME sub type, e.g. `json`.
Name
: Default value is the filename (relative to the owning page). Can be set in front matter.
@@ -90,16 +86,17 @@ MediaType.Suffixes
: A slice of possible suffixes for the resource's MIME type.
## Methods
ByType
: Returns the page resources of the given type.
```go
```go-html-template
{{ .Resources.ByType "image" }}
```
Match
: Returns all the page resources (as a slice) whose `Name` matches the given Glob pattern ([examples](https://github.com/gobwas/glob/blob/master/readme.md)). The matching is case-insensitive.
```go
```go-html-template
{{ .Resources.Match "images/*" }}
```
@@ -107,6 +104,7 @@ GetMatch
: Same as `Match` but will return the first match.
### Pattern Matching
```go
// Using Match/GetMatch to find this images/sunset.jpg ?
.Resources.Match "images/sun*" ✅
@@ -140,8 +138,7 @@ title
params
: A map of custom key/values.
### Resources metadata example
### Resources metadata example
{{< code-toggle copy="false">}}
title: Application