1
Fork 0

Slightly different frontmatter now

This commit is contained in:
Jan-Erik Rediger 2018-01-10 12:24:54 +01:00
parent 742120c988
commit 69920d0f2f

View file

@ -5,10 +5,11 @@ OUTPUT_DIR = File.expand_path("~/projects/fnordig.de/_posts")
EDITOR = ENV['EDITOR'] || 'vim'
EXTENSION=".md"
HEADER = <<EOF
extends: post.liquid
permalink: "/{{ year }}/{{ month }}/{{ day }}/%s"
title: "%s"
date: %s
path: /:year/:month/:day/%s
published_date: "%s"
layout: post.liquid
data:
route: blog
---
@ -30,9 +31,9 @@ slug = slugify(ARGV)
filename = now.strftime("%Y-%m-%d-") + slug
title = ARGV.join(' ')
file = File.join(OUTPUT_DIR, "#{filename}#{EXTENSION}")
date = now.strftime("%d %b %Y %H:%M:%S %z")
date = now.strftime("%Y-%m-%d %H:%M:00 %z")
puts "new post: #{title}"
puts "file: #{filename}"
File.open(file, "w"){|f| f.write(HEADER % [title, date, slug]) }
File.open(file, "w"){|f| f.write(HEADER % [slug, title, date]) }
exec EDITOR, '+', file