fix textilization of pages
This commit is contained in:
parent
33dbb78137
commit
2a82259fc9
|
@ -34,14 +34,14 @@ module AutoBlog
|
|||
end
|
||||
|
||||
def transform
|
||||
if self.ext == "textile"
|
||||
self.ext = "html"
|
||||
if self.ext == ".textile"
|
||||
self.ext = ".html"
|
||||
self.content = RedCloth.new(self.content).to_html
|
||||
end
|
||||
end
|
||||
|
||||
def add_layout(layouts)
|
||||
payload = {"page" => self.data}
|
||||
def add_layout(layouts, posts)
|
||||
payload = {"page" => self.data, "site" => {"posts" => posts}}
|
||||
self.content = Liquid::Template.parse(self.content).render(payload)
|
||||
|
||||
layout = layouts[self.data["layout"]] || self.content
|
||||
|
@ -53,7 +53,12 @@ module AutoBlog
|
|||
def write(dest)
|
||||
FileUtils.mkdir_p(File.join(dest, @dir))
|
||||
|
||||
path = File.join(dest, @dir, @name)
|
||||
name = @name
|
||||
if self.ext != ""
|
||||
name = @name.split(".")[0..-2].join('.') + self.ext
|
||||
end
|
||||
|
||||
path = File.join(dest, @dir, name)
|
||||
File.open(path, 'w') do |f|
|
||||
f.write(self.content)
|
||||
end
|
||||
|
|
|
@ -71,6 +71,12 @@ module AutoBlog
|
|||
f.write(self.content)
|
||||
end
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
{ "title" => self.data["title"] || "",
|
||||
"url" => self.url,
|
||||
"date" => self.date }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -63,7 +63,7 @@ module AutoBlog
|
|||
transform_pages(File.join(dir, f))
|
||||
else
|
||||
page = Page.new(self.source, dir, f)
|
||||
page.add_layout(self.layouts)
|
||||
page.add_layout(self.layouts, self.posts)
|
||||
page.write(self.dest)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue