tlienart / franklindocs

Website for Franklin.jl
https://franklinjl.org
MIT License
4 stars 15 forks source link

Example for on_write #32

Open tlienart opened 4 years ago

tlienart commented 4 years ago

Kindly provided by Ole Kroger:

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
tlienart commented 4 years ago
Wikunia commented 4 years ago

Same category as #3