m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-07-26 20:10:14 -0700
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-07-26 20:10:14 -0700
commita84badc9cb7c53aa739bd9792adce2601948762f (patch)
tree5946d5f2cfb030e0361152853ae7391da27e4303 /lib
parent1a6bac63e6ec22d8ff4029e98de23643003c259b (diff)
Allow for minute-grained date specifications
Diffstat (limited to 'lib')
-rw-r--r--lib/blog.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/blog.rb b/lib/blog.rb
index e4403a3..96e79dd 100644
--- a/lib/blog.rb
+++ b/lib/blog.rb
@@ -3,6 +3,7 @@ require 'date'
def parse_post filename
file_raw = File.read(src filename).force_encoding('UTF-8').split('---')
post = YAML.load file_raw[0]
+ post['date'] = DateTime.parse(post['date'])
post['content'] = file_raw[1].strip
post['filename'] = filename
post
@@ -16,10 +17,14 @@ def posts
Dir.new(src 'blog').children.map do |filename|
post = parse_post "blog/#{filename}"
end.sort do |a, b|
- Date.parse(b['date']) <=> Date.parse(a['date'])
+ b['date'] <=> a['date']
end
end
+def format_date date
+ date.strftime '%B %-d, %Y'
+end
+
def write_blog_files
posts.each do |post|
content = ERB.new(File.read(src 'post-template.html.erb')).result binding