這是翻譯後的內容:
---
title: 頁面
description: 返回從該短代碼調用的頁面物件。
categories: []
keywords: []
action:
related: []
returnType: hugolib.pageForShortcode
signatures: [SHORTCODE.Page]
---
與此內容:
content/books/les-miserables.md
---
author: 維克多·雨果
isbn: 978-0451419439
publication_year: 1862
title: 悲慘世界
---
+++
author = '維克多·雨果'
isbn = '978-0451419439'
publication_year = 1862
title = '悲慘世界'
+++
{
"author": "維克多·雨果",
"isbn": "978-0451419439",
"publication_year": 1862,
"title": "悲慘世界"
}
調用此短代碼:
{{< book-details >}}
我們可以使用 Page
方法來訪問前置內容的值:
layouts/shortcodes/book-details.html
<ul>
<li>標題: {{ .Page.Title }}</li>
<li>作者: {{ .Page.Params.author }}</li>
<li>出版年份: {{ .Page.Params.publication_year }}</li>
<li>ISBN: {{ .Page.Params.isbn }}</li>
</ul>