Would it be an option to just put the show rule after the outline?
stuff here
#outline()
more stuff
#show heading.where(depth: 1): ...
= My first heading
If this is not possible (maybe because you’re editing a template), you could use a state to store whether you are currently in the outline, and use that to determine whether you want to insert a page break:
#show outline: it => {
state("in-outline").update(true)
it
state("in-outline").update(false)
}
#show heading.where(depth: 1): it => {
if not state("in-outline", false).get() {
pagebreak(weak: true)
}
it
}
Since the outline itself isn’t outlined, it will not be affected. Of course, this is only an option if a) you have no other non-outlined level 1 headings or b) this is actually closer to what you want. If it’s only a), I would probably still prefer Eric’s solution.