mirror of
https://git.coop/cotech/website.git
synced 2025-06-26 00:20:46 +00:00
Fix & normalize Coop frontmatter YAML
Also ensure newline at EOF. This was achieved by running the new normalize_coop_frontmatter.rb script which basically reads in the frontmatter, parses it and dumps it back out. I had to manually fix some telephone numbers which had been incorrectly parsed as some kind of number rather than as strings.
This commit is contained in:
12
scripts/normalize_coops_frontmatter.rb
Normal file
12
scripts/normalize_coops_frontmatter.rb
Normal file
@ -0,0 +1,12 @@
|
||||
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
|
Reference in New Issue
Block a user