Add draft link support to analyze.rb

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-08-08 17:54:25 -07:00
parent bf9b0aedf9
commit 7817c9a4ce

View File

@ -25,8 +25,9 @@ Dir['content/blog/**/*.md'].each do |file|
file = file.chomp file = file.chomp
files << file files << file
arr = refs[file] || (refs[file] = []) arr = refs[file] || (refs[file] = [])
File.open(file).read.scan(/< relref "([^"]+)" >/) do |ref| pattern = Regexp.union(/< relref "([^"]+)" >/, /< draftlink "[^"]+" "([^"]+)" >/)
ref = resolve_path(File.dirname(file), ref[0]) File.open(file).read.scan(pattern) do |ref|
ref = resolve_path(File.dirname(file), ref[0] || ref[1])
arr << ref arr << ref
files << ref files << ref
end end