Splitting heading functions in layout and show part

For a book I need Parts and Chapter headings, which start on new pages and are fancy. I also need to reset counters etc. which likely are better not done in “show” rules. What is the best solution, splitting between rules for heading layout and show rules?
My current code for level 1 is:

  show heading.where(level: 3): it => {
      // linebreak(); "NL!"
      let nums = counter(heading).get()
      // keep only level2.level3
      let n = if nums.len() >= 3 {
        str(nums.at(1)) + "." + str(nums.at(2))
      } // else {"??" }
      text(
        size: 1.3em,
        style: "italic",
        weight: "regular",
        )[#v(1em)
          #n 
          #h(.8em) 
          #it.body
          // xx heading level 3 xx
          #v(0.5em)
        ] 
    }

You can have look at the source code of bookly (I am the author of the template). The features you are looking for are implemented.