4
0
mirror of https://git.coop/cotech/website.git synced 2025-07-17 10:40:49 +00:00
Files
_clients
_coops
_includes
_layouts
_services
_technologies
_uploads
assets
docker
images
scripts
.gitignore
Gemfile
Gemfile.lock
README.md
coop.erb.md
coop.rb
geocode_coop_addresses.rb
migrate_clients.rb
migrate_coop_logos.rb
migrate_coop_pages.rb
migrate_services.rb
migrate_technologies.rb
normalize_coops_frontmatter.rb
.gitignore
.gitlab-ci.yml
.htaccess
.ruby-version
Gemfile
Gemfile.lock
README.md
_config.yml
about.md
docker-compose.yml
domains.coop.md
favicon.ico
index.html
join.md
cotech-website/scripts/normalize_coops_frontmatter.rb
James Mead 8780eca301 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.
2018-11-30 16:54:12 +00:00

13 lines
381 B
Ruby

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