Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Created July 21, 2017 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blairanderson/8015fc9901bd443f973edc7e656dc1de to your computer and use it in GitHub Desktop.
Save blairanderson/8015fc9901bd443f973edc7e656dc1de to your computer and use it in GitHub Desktop.
[Ruby][files,writing,frontmatter] How to create a frontmatter file for each week
start_date = Date.today + 1.month
end_date = start_date + 2.years
(start_date..end_date).group_by(&:wday)[1].each do |day|
pathname = "_drafts/weekly/#{day.year}/#{day.strftime("%m-%d")}.md"
open(pathname, 'w+') do |post|
post.puts "---"
post.puts "layout: weekly"
post.puts "title: Black River Weekly - #{day.strftime('%B %d %Y')}"
post.puts "category: weekly"
post.puts "---"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment