Get h2 tags from .Content

You could parse .Content after rendering. Related:
https://discourse.gohugo.io/t/splitting-content-into-sections-based-on-header-level/33749

Or use a heading render hook to store the headings in a page-level Scratch.