function on_write(pg, fd_vars)
rpath = fd_vars["fd_rpath"].first
# convert .md to .html
rpath = rpath[1:end-2] * "html"
if startswith(rpath, "blog/")
new_name = replace(rpath, r"blog/\d{4}-\d{2}-\d{2}-" => "blog/")
if !isfile("__site/$new_name")
mkpath("__site/$new_name")
end
mv("__site/$rpath", "__site/$new_name"; force=true)
end
end
Kindly provided by Ole Kroger: