From 4fcbf69eff8fe8c85a3cefbd784d6aabc06c50dc Mon Sep 17 00:00:00 2001 From: Thibaut Lienart Date: Tue, 9 May 2023 15:53:35 +0200 Subject: [PATCH] Sitemap fix for 404.md (#1026) * attempt fix for 404 md * fixing 404 sitemap * prep for patch release * removing 404 from sitemap --- Project.toml | 2 +- src/manager/dir_utils.jl | 6 +++--- src/manager/sitemap_generator.jl | 1 + src/utils/html.jl | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 21396ccc5..80de76940 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Franklin" uuid = "713c75ef-9fc9-4b05-94a9-213340da978e" authors = ["Thibaut Lienart "] -version = "0.10.82" +version = "0.10.83" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/manager/dir_utils.jl b/src/manager/dir_utils.jl index 911b39546..b6b46fa18 100644 --- a/src/manager/dir_utils.jl +++ b/src/manager/dir_utils.jl @@ -64,10 +64,10 @@ end function _keep_path(base, fname)::Bool rpath = get_rpath(joinpath(base, fname)) - keep = union(globvar(:keep_path)::Vector{String}, ["404.html"]) + keep = union(globvar(:keep_path)::Vector{String}, ["404.html", "404"]) isempty(keep) && return false - files = [f for f in keep if endswith(f, ".html")] - dirs = [d for d in keep if endswith(d, "/")] + files = [f for f in keep if endswith(f, ".html") || f == "404"] + dirs = [d for d in keep if endswith(d, "/")] spath = rpath * ".html" any(f -> f == spath, files) && return true any(d -> startswith(spath, d), dirs) && return true diff --git a/src/manager/sitemap_generator.jl b/src/manager/sitemap_generator.jl index 0bd711725..275ea90bb 100644 --- a/src/manager/sitemap_generator.jl +++ b/src/manager/sitemap_generator.jl @@ -44,6 +44,7 @@ Add an entry to `SITEMAP_DICT`. """ function add_sitemap_item(; html=false) loc = url_curpage() + endswith(loc, "404.html") && return nothing locvar(:sitemap_exclude)::Bool && return nothing if !html lastmod = locvar(:fd_mtime_raw) diff --git a/src/utils/html.jl b/src/utils/html.jl index 245d1f965..609691ae3 100644 --- a/src/utils/html.jl +++ b/src/utils/html.jl @@ -125,8 +125,8 @@ Helper function to get the relative url of the current page. function url_curpage() # get the relative path to current page and split extension (.md) rpath = locvar(:fd_rpath) - keep = union(globvar(:keep_path)::Vector{String}, ["404.html"]) - rpath in keep && return rpath + keep = union(globvar(:keep_path)::Vector{String}, ["404.html", "404.md"]) + rpath in keep && return replace(rpath, r"\.md$" => ".html") fn, ext = splitext(rpath) if ext != ".html"