5
0
mirror of https://git.coop/cotech/website.git synced 2024-12-27 04:35:25 +00:00
cotech-website/scripts/normalize_coops_frontmatter.rb

13 lines
381 B
Ruby
Raw Normal View History

require 'bundler/setup'
require 'yaml'
root_path = Pathname.new(__dir__).join('..')
Dir[root_path.join('_coops/*.md')].each do |path|
content = File.read(path)
body = content.split("\n").reverse.take_while { |l| l != "---" }.reverse.join("\n")
metadata = YAML.safe_load(content)
frontmatter = YAML.dump(metadata)
File.write(path, frontmatter + "---" + "\n" + body)
end