Skip to content

Instantly share code, notes, and snippets.

@ellingen
Last active August 29, 2015 13:59
Show Gist options
  • Save ellingen/10849904 to your computer and use it in GitHub Desktop.
Save ellingen/10849904 to your computer and use it in GitHub Desktop.
# Render all Contentful stories as dynamic pages
contentful_middleman_client.entries(content_type: contentful_types[:story], include: 1).each do |story|
story_perma = story.fields[:title].to_slug.normalize.to_s
proxy "/story/#{story_perma}.html", "/templates/story.html", locals: { id: story.id, story: story }
story.fields[:blocks].each do |b|
block = contentful_middleman_client.entries('sys.id' => b['sys']['id'], :include => 1).first
proxy "/b/#{block.sys[:id]}/#{story_perma}.html", "/templates/shared-block.html", locals: { story: story, block: block }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment