Duplicating pages in 'onPagesInitialized' hook

Are there any plugins or examples of how to duplicate a page, manipulate its frontmatter content, and insert it into the pages collection?

I don’t think this has been done in any plugin. We have plugins that create a page object and set the current page to that, but nothing that dynamically creates a virtual page from another page, modifies it, and then injects that back into the pages structure to be used by other things. This is probably doable, but you would be the first to try it!

You could start off by seeing if clone() works for pages. You would definitely have to change the unique parts (path, slug, etc) or you will get collisions with the other pages.

I just looked and we do have a copy method on the Page class that is used by the admin plugin. You might be able to use that to do what you need.