Method: MarkdownExtension::Page#initialize

Defined in:
lib/markdown_extension/page.rb

#initialize(file, site, lang = nil) ⇒ Page

Returns a new instance of Page.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/markdown_extension/page.rb', line 9

def initialize(file, site, lang=nil)
    @site = site
    if File.exist?(file)
        @markdown = File.read(file)
    else
        @markdown = ""
    end
    if @markdown.start_with?("---\n")
        mds = @markdown.split("---\n")
        @meta = mds[1]
        @markdown = mds[2..-1].join("---\n")
    end
    @path = file.gsub(site.pages_path+lang.to_s+"/","").gsub(".md","")
    @item_name = file.split("/")[-1].gsub(".md","")
    @ctime = File::ctime(file)
    @mtime = File::mtime(file)
end