Access sitemap from Extension

Hi everyone!

I’m working on a slate feature, which uses Middleman, for which I need a Middleman extension. To start, I’m an absolute Ruby noob, so go easy on me.

Here’s what I’ve got so far code wise:

class MyFeature < Middleman::Extension
  def initialize(app, options_hash={}, &block)
    super
    app.before_render do |body, path, locs, template_class|
      # Use sitemap here
      body
    end
  end
end

::Middleman::Extensions.register(:my_feature, MyFeature)
activate :my_feature

Inside before_render I need to access the front matter data for the page being processed. I tried accessing sitemap and app.sitemap but neither works.

Thanks for your help!

As far as it is my understanding (and I’m a noob too) this can be achieved creating a custom function that given a page can retrieve the content.

Perhaps this can be useful, but as per the author, I haven’t tested it.