mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-15 02:17:05 +00:00
Some resource copy-edits
Also set the page about bundles as draft for now. Will handle that page later.
This commit is contained in:
2 files changed
+39
-38
No files matched your search
@@ -6,7 +6,7 @@ lastmod : 2018-01-28T22:26:40-05:00
|
|||||||
linktitle : "Page Bundles"
|
linktitle : "Page Bundles"
|
||||||
keywords : ["page", "bundle", "leaf", "branch"]
|
keywords : ["page", "bundle", "leaf", "branch"]
|
||||||
categories : ["content management", "bundle"]
|
categories : ["content management", "bundle"]
|
||||||
draft : false
|
draft : true
|
||||||
toc : true
|
toc : true
|
||||||
menu :
|
menu :
|
||||||
docs:
|
docs:
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
---
|
---
|
||||||
title : "Page Resources"
|
title : "Page Resources"
|
||||||
description : "Page Resources are files included in a page bundle. You can use them in your template and add metadata."
|
description : "Page Resources -- images, other pages etc. -- have page-relative URLs and their own metadata."
|
||||||
date : 2018-01-24T13:10:00-05:00
|
date: 2018-01-24
|
||||||
lastmod : 2018-01-26T13:45:08-05:00
|
categories: ["content management"]
|
||||||
categories : ["content management"]
|
weight: 4003
|
||||||
weight : 4003
|
draft: false
|
||||||
draft : false
|
toc: true
|
||||||
toc : true
|
linktitle: "Page Resources"
|
||||||
linktitle : "Page Resources"
|
menu:
|
||||||
menu :
|
|
||||||
docs:
|
docs:
|
||||||
parent : "content-management"
|
parent: "content-management"
|
||||||
weight : 31
|
weight: 31
|
||||||
---
|
---
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
@@ -20,33 +19,33 @@ ResourceType
|
|||||||
: The main type of the resource. For example, a file of MIME type `image/jpg` has for ResourceType `image`.
|
: The main type of the resource. For example, a file of MIME type `image/jpg` has for ResourceType `image`.
|
||||||
|
|
||||||
Name
|
Name
|
||||||
: The filename (relative path to the bundle). It can be overwritten with the resource's Front Matter metadata.
|
: Default value is the filename (relative to the owning page). Can be set in front matter.
|
||||||
|
|
||||||
Title
|
Title
|
||||||
: Same as filename. It can be overwritten with the resource's Front Matter metadata.
|
: Default blank. Can be set in front matter.
|
||||||
|
|
||||||
Permalink
|
Permalink
|
||||||
: The absolute URL of the resource. This gets a value only where the _ResourceType_ is **not** `page`.
|
: The absolute URL to the resource. Resources of type `page` will have no value.
|
||||||
|
|
||||||
RelPermalink
|
RelPermalink
|
||||||
: The relative URL of the resource. This gets a value only where the _ResourceType_ is **not** `page`.
|
: The relative URL to the resource. Resources of type `page` will have no value.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
ByType
|
ByType
|
||||||
: Retrieve the page resources of the passed type.
|
: Returns the page resources of the given type.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
{{ .Resources.ByType "image" }}
|
{{ .Resources.ByType "image" }}
|
||||||
```
|
```
|
||||||
Match
|
Match
|
||||||
: Retrieve all the page resources (as a slice) whose `Name` matches the Glob pattern ([examples](https://github.com/gobwas/glob/blob/master/readme.md)) passed as parameter. The matching is case-insensitive.
|
: 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
|
||||||
{{ .Resources.Match "images/*" }}
|
{{ .Resources.Match "images/*" }}
|
||||||
```
|
```
|
||||||
|
|
||||||
GetMatch
|
GetMatch
|
||||||
: Same as `Match` but will only retrieve the first matching resource.
|
: Same as `Match` but will return the first match.
|
||||||
|
|
||||||
### Pattern Matching
|
### Pattern Matching
|
||||||
```go
|
```go
|
||||||
@@ -61,33 +60,34 @@ GetMatch
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Metadata
|
## Page Resources Metadata
|
||||||
|
|
||||||
Page Resources metadata is managed from their page's Front Matter with an array/table parameter named `resources`. Batch assign is made possible using glob pattern matching.
|
Page Resources' metadata is managed from their page's front matter with an array/table parameter named `resources`. You can batch assign values using a glob pattern.
|
||||||
|
|
||||||
### Available metadata
|
{{% note %}}
|
||||||
|
Resources of type `page` get `Title` etc. from their own front matter.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
name
|
name
|
||||||
: Will overwrite Name
|
: Sets the value returned in `Name`.
|
||||||
|
|
||||||
{{% warning %}}
|
{{% warning %}}
|
||||||
The methods Match and GetMatch use Name to match the resource. Overwrite wisely.
|
The methods `Match` and `GetMatch` use `Name` to match the resources.
|
||||||
{{%/ warning %}}
|
{{%/ warning %}}
|
||||||
|
|
||||||
title
|
title
|
||||||
: Will overwrite Title
|
: Sets the value returned in `Title`
|
||||||
|
|
||||||
params
|
params
|
||||||
: An array of custom params to be retrieve much like page params
|
: A map of custom key/values.
|
||||||
`{{ .Params.credits }}`
|
|
||||||
|
|
||||||
### Example
|
|
||||||
#### `resources` parameter in YAML
|
### Resources metadata: YAML Example
|
||||||
~~~yaml
|
~~~yaml
|
||||||
title: Application
|
title: Application
|
||||||
date : 2018-01-25
|
date : 2018-01-25
|
||||||
resources :
|
resources :
|
||||||
- src : "images/header.*"
|
- src : "images/sunset.jpg"
|
||||||
name : "header"
|
name : "header"
|
||||||
- src : "documents/photo_specs.pdf"
|
- src : "documents/photo_specs.pdf"
|
||||||
title : "Photo Specifications"
|
title : "Photo Specifications"
|
||||||
@@ -108,12 +108,13 @@ resources :
|
|||||||
icon : "word"
|
icon : "word"
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
#### `resources` parameter in TOML
|
### Resources metadata: TOML Example
|
||||||
|
|
||||||
~~~toml
|
~~~toml
|
||||||
title = Application
|
title = Application
|
||||||
date : 2018-01-25
|
date : 2018-01-25
|
||||||
[[resources]]
|
[[resources]]
|
||||||
src = "images/header.*"
|
src = "images/sunset.jpg"
|
||||||
name = "header"
|
name = "header"
|
||||||
[[resources]]
|
[[resources]]
|
||||||
src = "documents/photo_specs.pdf"
|
src = "documents/photo_specs.pdf"
|
||||||
@@ -141,13 +142,13 @@ date : 2018-01-25
|
|||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
|
||||||
From the metadata example above:
|
From the example above:
|
||||||
|
|
||||||
- `header.jpg` will receive a new `Name` and won't be retrieved by `.Match "*/header.jpg"` anymore, but something like `.Match "header"`.
|
- `sunset.jpg` will receive a new `Name` and can now be found with `.GetMatch "header"`.
|
||||||
- `documents/photo_specs.pdf` will get the `photo` icon.
|
- `documents/photo_specs.pdf` will get the `photo` icon.
|
||||||
- `documents/checklist.pdf`, `documents/guide.pdf` and `documents/payment.docx` will receive `Title` as set by `title`.
|
- `documents/checklist.pdf`, `documents/guide.pdf` and `documents/payment.docx` will receive `Title` as set by `title`.
|
||||||
- Every pdf in the bundle except `documents/photo_specs.pdf` will receive the `pdf` icon.
|
- Every `PDF` in the bundle except `documents/photo_specs.pdf` will receive the `pdf` icon.
|
||||||
- All pdf files will get a new `Name`. The `name` parameter contains a special placeholder [`:counter`](#counter). That will cause the retrieved pdf files to have names `pdf-file-1`, `pdf-file-2`, `pdf-file-3`.
|
- All `PDF` files will get a new `Name`. The `name` parameter contains a special placeholder [`:counter`](#counter), so the `Name` will be `pdf-file-1`, `pdf-file-2`, `pdf-file-3`.
|
||||||
- Every docx in the bundle will receive the `word` icon.
|
- Every docx in the bundle will receive the `word` icon.
|
||||||
|
|
||||||
{{% warning %}}
|
{{% warning %}}
|
||||||
@@ -156,11 +157,11 @@ The __order matters__ --- Only the **first set** values of the `title`, `name` a
|
|||||||
|
|
||||||
### `:counter` placeholder in `name` and `title` {#counter}
|
### `:counter` placeholder in `name` and `title` {#counter}
|
||||||
|
|
||||||
The `:counter` is a special placeholder recognized in `name` and `title` parameters in the `resources` Front Matter.
|
The `:counter` is a special placeholder recognized in `name` and `title` parameters in the `resources` front matter.
|
||||||
|
|
||||||
If the `name` value contains the `":counter"` string, a "name-counter" is initialized to 1, and if the `title` value contains the same string, a separate "title-counter" is initialized to 1 as well.
|
If the `name` value contains the `":counter"` string, a "name-counter" is initialized to 1, and if the `title` value contains the same string, a separate "title-counter" is initialized to 1 as well.
|
||||||
|
|
||||||
For example, if a bundle has the resources `photo_specs.pdf`, `other_specs.pdf`, `guide.pdf` and `checklist.pdf`, and the Front Matter has specified the `resources` as:
|
For example, if a bundle has the resources `photo_specs.pdf`, `other_specs.pdf`, `guide.pdf` and `checklist.pdf`, and the front matter has specified the `resources` as:
|
||||||
|
|
||||||
~~~toml
|
~~~toml
|
||||||
[[resources]]
|
[[resources]]
|
||||||
|
|||||||
Reference in new issue
Block a user