Skip to content

Commit

Permalink
fix for sitemap generation: loc of 404.html [#1011] (#1024)
Browse files Browse the repository at this point in the history
* closes #1011

* correct approach so that users redefining keep path don't have to add 404
  • Loading branch information
tlienart authored Apr 27, 2023
1 parent 943e988 commit c5e0246
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions demos/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<h1>
This is a 404 page, oops.
</h1>
</body>
</html>
2 changes: 2 additions & 0 deletions demos/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ mathjax = false
ignore = ["foo/content.md"]
weave = false

generate_sitemap = true

# supports question 001
members_from_csv = eachrow(readdlm("_assets/members.csv", ',', skipstart=1))
+++
Expand Down
4 changes: 2 additions & 2 deletions src/manager/dir_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function form_output_path(base::AS, file::AS, case::Symbol)
# file is index.html or 404.html or in keep_path --> keep the path
# file is page.html --> .../page/index.html
fname = splitext(file)[1]
if fname ("index", "404") && !endswith(fname, "/index") && !_keep_path(base, fname)
if fname != "index" && !endswith(fname, "/index") && !_keep_path(base, fname)
file = joinpath(fname, "index.html")
end
end
Expand Down Expand Up @@ -64,7 +64,7 @@ end

function _keep_path(base, fname)::Bool
rpath = get_rpath(joinpath(base, fname))
keep = globvar(:keep_path)::Vector{String}
keep = union(globvar(:keep_path)::Vector{String}, ["404.html"])
isempty(keep) && return false
files = [f for f in keep if endswith(f, ".html")]
dirs = [d for d in keep if endswith(d, "/")]
Expand Down
2 changes: 1 addition & 1 deletion src/utils/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ 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 = globvar(:keep_path)::Vector{String}
keep = union(globvar(:keep_path)::Vector{String}, ["404.html"])
rpath in keep && return rpath

fn, ext = splitext(rpath)
Expand Down

0 comments on commit c5e0246

Please sign in to comment.