Get first item of query
#3976
-
I'm trying to set up a template which requires me to make a page break before the first heading. What I was hoping to achieve was something like this: let headings = context query(heading.where(level: 1))
show headings.at(0): it => pagebreak(weak: true) + it but I always get this error message |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You're getting the error because the output of the But even if you put the whole show rule into the context, it's simply not possible currently to write a show rule based on a query result like this. You'd get an error like "this selector cannot be used with show". Maybe you can write the template in a simpler way and just include a pagebreak somewhere at a known position? |
Beta Was this translation helpful? Give feedback.
-
Here's an alternative solution I just thought of: #show heading: it => {
if query(heading).first().location() == it.location() {
pagebreak()
}
it
}
= Introduction
= World |
Beta Was this translation helpful? Give feedback.
Here's an alternative solution I just thought of: