Skip to content

Commit ed04081

Browse files
authored
Fix deploy path for custom URLs + correct MIME order (#54)
* Fix deploy path for custom URLs * Allow building without package.json * Fix MIME types defaulting to lowest and not highest priority * Fix extra / in deploy path which was causing this issue
1 parent 415f02f commit ed04081

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/vitepress_config.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ function modify_config_file(doc, settings, deploy_decision)
6060
deploy_abspath = if isnothing(settings.deploy_url)
6161
"/" * splitdir(settings.repo)[2]
6262
else
63-
s = splitdir(settings.deploy_url)[2]
63+
s_path = startswith(settings.deploy_url, r"http[s?]:\/\/") ? splitpath(settings.deploy_url)[2:end] : splitpath(settings.deploy_url)
64+
s = length(s_path) > 1 ? joinpath(s_path) : "" # ignore custom URL here
6465
isempty(s) ? "/" : "/$(s)"
6566
end
67+
68+
base_str = deploy_abspath == "/" ? "base: '$(deploy_abspath)$(deploy_relpath)'" : "base: '$(deploy_abspath)/$(deploy_relpath)'"
6669

67-
push!(replacers, "base: 'REPLACE_ME_DOCUMENTER_VITEPRESS'" => "base: '$(deploy_abspath)/$(deploy_relpath)'")
70+
push!(replacers, "base: 'REPLACE_ME_DOCUMENTER_VITEPRESS'" => base_str)
6871

6972
# # Vitepress output path
7073
push!(replacers, "outDir: 'REPLACE_ME_DOCUMENTER_VITEPRESS'" => "outDir: '../final_site'")

src/writer.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ function render(doc::Documenter.Document, settings::MarkdownVitepress=MarkdownVi
149149
end
150150

151151
cd(dirname(builddir)) do
152-
if settings.install_npm || should_remove_package_json
152+
if settings.install_npm || should_remove_package_json
153+
if !isfile(joinpath(dirname(builddir), "package.json"))
154+
cp(joinpath(dirname(@__DIR__), "template", "package.json"), joinpath(dirname(builddir), "package.json"))
155+
should_remove_package_json == true
156+
end
153157
run(`$(npm) install`)
154158
end
155159
run(`$(npm) run docs:build`)
@@ -538,7 +542,7 @@ function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Nod
538542
# Sort the available mimes by priority
539543
sorted_mimes = sort(collect(available_mimes), by = mime_priority)
540544
# Select the best MIME type for rendering
541-
best_mime = sorted_mimes[1]
545+
best_mime = sorted_mimes[end]
542546
# Render the best MIME type
543547
render_mime(io, best_mime, node, d[best_mime], page, doc; md_output_path, kwargs...)
544548
end

0 commit comments

Comments
 (0)