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