mirror of
https://github.com/danbee/danbarber.me.hugo.git
synced 2025-03-04 08:59:18 +00:00
Commit fix images script
This commit is contained in:
parent
0400a75b18
commit
a127589bac
24
scripts/fix_images
Executable file
24
scripts/fix_images
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require "date"
|
||||||
|
require "fileutils"
|
||||||
|
require "front_matter_parser"
|
||||||
|
|
||||||
|
unsafe_yaml_loader = ->(string) { YAML.load(string) }
|
||||||
|
|
||||||
|
Dir.glob("content/photos/**/*.md").each do |file|
|
||||||
|
parsed_file = FrontMatterParser::Parser.
|
||||||
|
parse_file(file, loader: unsafe_yaml_loader)
|
||||||
|
|
||||||
|
image = parsed_file["image"].split("/").last
|
||||||
|
|
||||||
|
new_content = <<~CONTENT
|
||||||
|
#{parsed_file.front_matter.merge("image" => image).to_yaml}---
|
||||||
|
|
||||||
|
#{parsed_file.content}
|
||||||
|
CONTENT
|
||||||
|
|
||||||
|
File.open(file, "w") do |new_file|
|
||||||
|
new_file.write(new_content)
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue
Block a user