# coding: utf-8 require 'pathname' require 'date' require 'json' require 'time' module WriteDown module Model # 代表博文 class Post < Base def render template_file = File.expand_path('../../erb/post.erb', __FILE__) template = File.read(template_file) html_string = ERB.new(template).result(binding) end def build Layout.new(self, @target_file).render self end # 概览 def summary @meta['summary'] end # 标题 def title @meta['title'] end # 生成的链接 def url if @draft "posts/drafts/#{@base_name}/index.html" else "posts/#{@base_name}/index.html" end end def link_to "posts/#{@base_name}/" end end end end