It’s possible to display/import data from a page in another page with a shortcode, and it’s pretty cool! I didn’t find this type of usage, I hope that will be useful for other people
Here an example:
Chapter 1:
---
title: Chapter 1
chapter: 1
description: "A description for the chapter 1"
---
Here some text.
Chapter 2:
---
title: Chapter 2
chapter: 2
description: "Few words about chapter 2"
---
Here some text.
Like the chapter 1 {{< cross-ref chapter="1" >}}.
Shortcode cross-ref.html
:
{{ $chapter := .Get "chapter" | int }}
{{ range where .Site.Pages "Params.chapter" $chapter }}
<span><span>See {{ .Title }}</span><span>{{ .Description }}</span></span>
{{ end }}
Result for the chapter 2 page:
<h1>Chapter 2</h1>
<p>Here some text.</p>
<p>Like the chapter 1 <span><span>See Chapter 1</span><span>A description for the chapter 1</span></span>.
Important: don’t use variables like Summary
, Content
or ReadingTime
, it will create an infinite loop (thanks @razon for the warning)!