mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
docs: Document page .GetPage function
This commit is contained in:
parent
299aa6cb5c
commit
602f5097d6
112
docs/kiln.1.scd
112
docs/kiln.1.scd
|
@ -207,7 +207,7 @@ Permalinks can be used to rewrite page paths. Permalinks are specified in the
|
||||||
\[permalinks] table of the configuration file. Keys denote a path to a directory,
|
\[permalinks] table of the configuration file. Keys denote a path to a directory,
|
||||||
and values use the Go templating language to rewrite the final path of pages in
|
and values use the Go templating language to rewrite the final path of pages in
|
||||||
that directory. The templates have the same data that page templates have
|
that directory. The templates have the same data that page templates have
|
||||||
available to them (see *PAGE TEMPLATES*).
|
available to them (see *PAGE VARIABLES*).
|
||||||
|
|
||||||
The following configuration will rewrite the paths of pages in the content/blog
|
The following configuration will rewrite the paths of pages in the content/blog
|
||||||
directory to /YYYY/MM/DD/slug. For example, the file
|
directory to /YYYY/MM/DD/slug. For example, the file
|
||||||
|
@ -435,84 +435,128 @@ Example feed configuration:
|
||||||
|
|
||||||
Templates have certain data and functions available to them.
|
Templates have certain data and functions available to them.
|
||||||
|
|
||||||
## SITE METADATA
|
## SITE VARIABLES
|
||||||
|
|
||||||
Site metadata contains the following data:
|
The following site-wide variables are available:
|
||||||
|
|
||||||
*Title*
|
*.Title*
|
||||||
The title of the site.
|
The title of the site.
|
||||||
|
|
||||||
*Params*
|
*.Params*
|
||||||
Extra parameters specified in configuration.
|
Extra parameters specified in configuration.
|
||||||
|
|
||||||
*Generated*
|
*.Generated*
|
||||||
Site generation time.
|
Site generation time.
|
||||||
|
|
||||||
*Root*
|
*.Root*
|
||||||
The root page of the site.
|
The root page of the site. See *PAGE VARIABLES*.
|
||||||
|
|
||||||
Site metadata can be accessed from templates with the *site* function. See
|
Some of these variables are defined in your site's configuration. See
|
||||||
|
*CONFIGURATION*.
|
||||||
|
|
||||||
|
Site variables can be accessed from templates with the *site* function. See
|
||||||
*TEMPLATE FUNCTIONS*.
|
*TEMPLATE FUNCTIONS*.
|
||||||
|
|
||||||
To configure these variables, see *CONFIGURATION*.
|
## PAGE VARIABLES
|
||||||
|
|
||||||
## PAGE TEMPLATES
|
The following page variables are available:
|
||||||
|
|
||||||
Page and index templates are provided with the following data:
|
*.Title*
|
||||||
|
|
||||||
*Title*
|
|
||||||
The title of the page
|
The title of the page
|
||||||
|
|
||||||
*Date*
|
*.Date*
|
||||||
The date of the page
|
The date of the page
|
||||||
|
|
||||||
*Weight*
|
*.Weight*
|
||||||
The weight of the page
|
The weight of the page
|
||||||
|
|
||||||
*Path*
|
*.Path*
|
||||||
The path to the page
|
The path to the page
|
||||||
|
|
||||||
*URL*
|
*.URL*
|
||||||
The URL of the page. If no base URL is configured, it is equivalent to
|
The URL of the page. If no base URL is configured, it is equivalent to
|
||||||
*Path*.
|
*.Path*.
|
||||||
|
|
||||||
*FilePath*
|
*.FilePath*
|
||||||
The path of the page file or directory relative to the content directory
|
The path of the page file or directory relative to the content directory
|
||||||
|
|
||||||
*Content*
|
*.Content*
|
||||||
The contents of the page
|
The contents of the page
|
||||||
|
|
||||||
*Params*
|
*.Params*
|
||||||
Extra parameters specified in frontmatter
|
Extra parameters specified in frontmatter
|
||||||
|
|
||||||
*Prev*
|
*.Prev*
|
||||||
The previous page in sorted order
|
The previous page in sorted order
|
||||||
|
|
||||||
*Next*
|
*.Next*
|
||||||
The next page in sorted order
|
The next page in sorted order
|
||||||
|
|
||||||
*Pages*
|
*.Pages*
|
||||||
List of pages in this directory
|
List of pages in this directory
|
||||||
|
|
||||||
*Dirs*
|
*.Dirs*
|
||||||
List of subdirectories in this directory
|
List of subdirectories in this directory
|
||||||
|
|
||||||
## FEED TEMPLATES
|
Some of these variables are defined in page frontmatter. See *FRONTMATTER*.
|
||||||
|
|
||||||
Feed templates are provided with the following data:
|
Page variables can be accessed from page and index templates.
|
||||||
|
|
||||||
*Title*
|
## PAGE FUNCTIONS
|
||||||
Title of the feed
|
|
||||||
|
|
||||||
*Path*
|
The following page functions are available:
|
||||||
|
|
||||||
|
*.GetPage* _path_
|
||||||
|
Retrieves the page in this directory with the given _path_, which may be
|
||||||
|
relative or absolute.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
{{/* Retrieve a directory relative to the root directory
|
||||||
|
and iterate over its pages */}}
|
||||||
|
{{ with site.Root.GetPage "/blog" }}
|
||||||
|
{{ range .Pages }}
|
||||||
|
{{ .Title }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* Retrieve a directory relative to the current directory
|
||||||
|
and iterate over its pages */}}
|
||||||
|
{{ with .GetPage "posts" }}
|
||||||
|
{{ range .Pages }}
|
||||||
|
{{ .Title }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* Retrieve a page relative to the current directory */}}
|
||||||
|
{{ with .GetPage "posts/hello-world.gmi" }}
|
||||||
|
{{ .Title }}
|
||||||
|
{{ end }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Page functions can be accessed from page and index templates.
|
||||||
|
|
||||||
|
## FEED VARIABLES
|
||||||
|
|
||||||
|
The following feed variables are available:
|
||||||
|
|
||||||
|
*.Title*
|
||||||
|
The title of the feed
|
||||||
|
|
||||||
|
*.Path*
|
||||||
The path to the feed directory
|
The path to the feed directory
|
||||||
|
|
||||||
*URL*
|
*.URL*
|
||||||
The URL of the feed directory
|
The URL of the feed directory
|
||||||
|
|
||||||
*Pages*
|
*.Pages*
|
||||||
List of pages in this feed
|
List of pages in this feed
|
||||||
|
|
||||||
|
Some of these variables are defined in feed configuration. See *FEEDS*.
|
||||||
|
|
||||||
|
Feed variables can be accessed from feed templates.
|
||||||
|
|
||||||
## PARTIAL TEMPLATES
|
## PARTIAL TEMPLATES
|
||||||
|
|
||||||
Partial templates can be placed in the templates/\_partials directory.
|
Partial templates can be placed in the templates/\_partials directory.
|
||||||
|
@ -644,7 +688,7 @@ All templates have the following functions available to them:
|
||||||
Encapsulates a known safe URL or URL substring.
|
Encapsulates a known safe URL or URL substring.
|
||||||
|
|
||||||
*site*
|
*site*
|
||||||
Returns site metadata (see *SITE METADATA*).
|
Returns site information (see *SITE VARIABLES*).
|
||||||
|
|
||||||
*slice* _list_, _args..._
|
*slice* _list_, _args..._
|
||||||
slice returns the result of slicing its first argument by the
|
slice returns the result of slicing its first argument by the
|
||||||
|
|
Loading…
Reference in a new issue