implement blog
This commit is contained in:
parent
b4dcd84581
commit
a52f258402
8 changed files with 77 additions and 2 deletions
|
@ -1,7 +1,22 @@
|
|||
class Pages::Blog < ::Phlex::HTML
|
||||
include Util::PostLoader
|
||||
|
||||
def view_template
|
||||
render ::Pages::Layout.new(:blog) {
|
||||
p { "under construction" }
|
||||
ul {
|
||||
posts.each { |post|
|
||||
meta = post[:data].front_matter
|
||||
|
||||
return unless meta.key?('published_on')
|
||||
|
||||
li {
|
||||
p {
|
||||
time(datetime: meta['published_on']) { meta['published_on'] }
|
||||
a(href: '/p/' + post[:slug], style: "padding-left: 10px;") { meta['title'] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,12 +17,18 @@ module Pages
|
|||
|
||||
def initialize(page)
|
||||
@page = page
|
||||
if @page.is_a? Symbol
|
||||
@page_info = pages[page]
|
||||
else
|
||||
@page_info = @page
|
||||
end
|
||||
end
|
||||
def view_template
|
||||
|
||||
doctype
|
||||
html {
|
||||
head {
|
||||
title { pages[@page][:title] + " | Aleks Rūtiņš" }
|
||||
title { @page_info[:title] + " | Aleks Rūtiņš" }
|
||||
meta(charset: "utf-8")
|
||||
meta(name: "viewport", content: "width=device-width, initial-scale=1.0")
|
||||
link(rel: "stylesheet", href: "/site.css")
|
||||
|
|
17
pages/post.rb
Normal file
17
pages/post.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class Pages::Post < ::Phlex::HTML
|
||||
def initialize(post)
|
||||
@slug = post[:slug]
|
||||
@post = post
|
||||
end
|
||||
def view_template
|
||||
meta = @post[:data].front_matter
|
||||
render ::Pages::Layout.new({title: meta['title']}) {
|
||||
p {
|
||||
h1 { meta['title'] }
|
||||
time(datetime: meta['published_on']) { meta['published_on'] }
|
||||
|
||||
render ::Phlex::Markdown.new(@post[:data].content)
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue