There's no "good" solution, even this one. Generally the strategy for 'migrating' classic to modern pages is to rebuild them from scratch as there are far too many differences between the two and no good automated migration path.
Convert classic page to modern page
I have been trying to solve this problem. There are some pages (like 50) to be migrated from classic to modern experience. The pages are in "Pages Library" in classic SharePoint. The modern view uses "Site Pages" and the content types are different too. Is there a way to modernize these 50 pages using a script? I found an article that suggests that this could be done.
https://learn.microsoft.com/en-us/sharepoint/dev/transform/modernize-userinterface-site-pages
The script works when I try to convert pages in "Site Pages" but not on the "Pages library". The article says that the script supports converting publishing pages to modern pages but couldn't get that working. Did anyone try it before?