After_build glossary help

I was trying to modify this Jekyll https://stackoverflow.com/questions/74626830/implementing-a-glossary-in-jekyll for adding a glossary (autolink terms to a page/hoverover). I did see this previous post re: manipulation post-build and tried some variations on manipulate_resource_list and the set of callbacks but I don’t think I understand enough about middleman to get what I need from the documentation. Any pointers either to resources or/and on the code would be great

module GlossaryData
  def glossary
    self['glossary']
  end
end

class GlossaryLinkGenerator < Middleman::Extension
  def after_configuration_eval
    app.data.extend(GlossaryData)

    glossary_terms = {}
    app.data.glossary.each do |entry|
      glossary_terms[entry['term'].downcase] = entry['definition']
      glossary_terms[entry['term']] = entry['definition']
    end

    # pages
    app.pages.each do |page|
      glossary_terms.each do |term, definition|
        page.content = page.content.gsub(term) do |match|
          "<a href='/glossary.html##{term}'>#{term}</a>"
        end
      end
    end

    # posts
    app.posts.docs.each do |post|
      glossary_terms.each do |term, definition|
        post.content = post.content.gsub(term) do |match|
          "<a href='/glossary.html##{term}'>#{term}</a>"
        end
      end
    end

  end
end

::Middleman::Extensions.register(:glossary_link_generator, GlossaryLinkGenerator)