(Sorry for not using code formatting but it’s not usable since the template starts with three `.
The code above prints "page: " followed by names of my pages, but for those that I add title: some different string here into the frontmatter, the printed line is “title: some different string here”.
What I don’t know is how to get the first H1. I see a need for some additional logic to print only the 1st H1 in case more of them are in the page. Maybe using Templates might help here?