Page
返回調用 shortcode 的頁面對象。
Syntax
SHORTCODE.Page
Returns
hugolib.pageForShortcode
使用此內容:
---
author: Victor Hugo
isbn: 978-0451419439
publication_year: 1862
title: Les Misérables
---+++
author = 'Victor Hugo'
isbn = '978-0451419439'
publication_year = 1862
title = 'Les Misérables'
+++{
"author": "Victor Hugo",
"isbn": "978-0451419439",
"publication_year": 1862,
"title": "Les Misérables"
}
調用此 shortcode:
{{< book-details >}}我們可以使用 Page 方法訪問 front matter 值:
layouts/_shortcodes/book-details.html
<ul>
<li>Title: {{ .Page.Title }}</li>
<li>Author: {{ .Page.Params.author }}</li>
<li>Published: {{ .Page.Params.publication_year }}</li>
<li>ISBN: {{ .Page.Params.isbn }}</li>
</ul>