Skip to content

Instantly share code, notes, and snippets.

@matthewowen
Created November 6, 2012 15:39
Show Gist options
  • Save matthewowen/4025507 to your computer and use it in GitHub Desktop.
Save matthewowen/4025507 to your computer and use it in GitHub Desktop.
access raw content in jekyll
module Jekyll
class RawContent < Generator
def generate(site)
site.posts.each do |post|
post.data['raw_content'] = post.content
end
end
end
end
@Convincible
Copy link

Convincible commented Mar 20, 2022

Do it to all collections:

module Jekyll

	class RawContent < Generator
  
	  def generate(site)
		site.collections.each do |collection|
			collection.each do |label, docs|
				if label.is_a?(Jekyll::Document)
					docs = [label]
				end
				docs.each do |doc|
					doc.data['raw_content'] = doc.content.dup
				end if !docs.nil?
			end
		end
	  end
	
	end
  
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment