Get a specific Header with content for each book

I tried to create an index page that shows the back cover for each book. But can’t get it to work. Maybe somebody has a hint that leads me to the solution?

I found two threads for inspiration:

What I expect to see for each book is:

[description]
[Text(Content) of Header “Back Cover”]

Example:
Harry Potter Ep1
This is the info of the back cover of Harry Potter Episode 1
lorem ipsum dolor

This is what I currently get (some traces inside for testing)

name: test/books/harrypotter1
@page.name: test/books/index
@tpage: test/books/harrypotter1

    harrypotter1

                  This is the info of the back cover of Harry Potter Episode 1


lorem ipsum dolor
let2: test/books/harrypotter1
            '''
---name: test/books/harrypotter2
@page.name: test/books/index
@tpage: test/books/harrypotter2

    harrypotter2

                  This is the info of the back cover of Harry Potter Episode 2


lorem ipsum dolor
let2: test/books/harrypotter2
            '''
---

Files

File: test/books/harrypotter1

---
tags: book
description: Harry Potter Ep1
---

# Meta
## Back Cover
This is the info of the back cover of Harry Potter Episode 1
lorem ipsum dolor

File: test/books/harrypotter2

---
tags: book
description: Harry Potter Ep2
---

# Meta
## Back Cover
This is the info of the back cover of Harry Potter Episode 2
lorem ipsum dolor

File: test/books/index

{{#each @p in {book}}}
{{{page where name = @p.name select name render [[Library/Personal/Renders/HeaderContent]]}}}
{{/each}}

File: Library/Personal/Renders/HeaderContent

name: {{name}}
@page.name: {{@page.name}}
{{#let @tPage = name}}
@tpage: {{@tPage}}
{{/let}}
{{#let @tPage = name}}
{{{page where name = @tPage select name render [[Library/Core/Query/Page]] }}}
{{#let @startPos = at({header where page = @tPage and name ="Back Cover" select pos},0)}}
  {{#if @startPos}}
    {{#let @endPos = at({header where page = @tPage and pos > @startPos.pos select pos},0)}}
      {{#if @endPos}}
        {{#each {paragraph where page = @tPage and pos > @startPos.pos and pos < @endPos.pos}}}
{{text}}
let1: {{@tPage}}
{{/each}}
      {{else}}
        {{#each {paragraph where page = @tPage and pos > @startPos.pos}}}
{{text}}
let2: {{@tPage}}
{{/each}}
      {{/if}}
    {{/let}}
  {{/if}}
{{/let}}
{{/let}}

1 Like