I wonder if it’s possible to extract data from few shortcodes from different pages and put it in another page.
I have made several searches without luck, maybe I didn’t look hard enough.
Here is an example of what I have in mind:
First page’s source
---
title: First page
---
Some text.
{{< extr title="Extract 1" id="ex01" >}}
About extract 1.
{{< /extr >}}
Second page’s source
---
title: Second page
---
Some text, again
{{< extr title="Extract 2" id="ex02" >}}
About extract 2.
{{< /extr >}}
Rendering of the extracts page
(In another page, with a dedicate template or a partial.)
<section>
<h1>All the extracts</h1>
<ul>
<li id="ex01"><strong>Extract 1</strong>: About extract 1</li>
<li id="ex02"><strong>Extract 2</strong>: About extract 2</li>
</ul>
</section>
Take this for a spin. Extract summary is in the home page template.
git clone --single-branch -b hugo-forum-topic-43384 https://github.com/jmooring/hugo-testing hugo-forum-topic-43384
cd hugo-forum-topic-43384
hugo server
Wahoo! I dit not know .HasShortcode (source), can we say it is a hack in your implementation? Whatever it is, it is great! Huge thanks!
Just a question: {{ $noop := .WordCount }} is not useful here?
I will write a post about what I can do with that (in few weeks).
For the noop I don’t see the difference but I believe you, and thanks for the explanation.
I have another question: how can I retrieve other data/informations from the shortcode (in addition to the inner)? Like a title or an id, some parameters in my first example. I’m sure it’s possible but I don’t find the right way.