Skip to content

Commit c200ff8

Browse files
authored
copy vitepress configs and fix url completely (#34)
* copy vitepress configs and fix url completely * modify `deploy_url` * update README
1 parent 9e617d3 commit c200ff8

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ makedocs(;
2929
```
3030
and enjoy the fruits of your labour!
3131

32+
> [!IMPORTANT]
33+
> If you are deploying from a custom URL, like `geo.makie.org`,
34+
> please provide the entire URL to the `deploy_url = "geo.makie.org"` keyword argument
35+
> of `MarkdownVitepress`!
36+
>
37+
> Otherwise, the documentation will not render correctly.
38+
3239
# Run locally
3340

3441
Because this is based on the Vitepress static site generator, you have to use NodeJS to view this site locally:

src/vitepress_config.jl

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
function modify_config_file(doc, settings, deploy_decision)
33

44
# Main.@infiltrate
5+
# Read in the config file,
6+
vitepress_config_file = joinpath(doc.user.build, settings.md_output_path, ".vitepress", "config.mts")
7+
if !isfile(vitepress_config_file)
8+
mkpath(splitdir(vitepress_config_file)[1])
9+
@warn "DocumenterVitepress: Did not detect `docs/src/.vitepress/config.mts` file. Substituting in the default file."
10+
if !isdir(joinpath(doc.user.build, settings.md_output_path, ".vitepress", "theme"))
11+
cp(joinpath(dirname(@__DIR__), "docs", "src", ".vitepress", "theme"), joinpath(doc.user.build, settings.md_output_path, ".vitepress", "theme"); follow_symlinks = true)
12+
end
13+
cp(joinpath(@__DIR__, "docs", "src", ".vitepress", "config.mts"), vitepress_config_file)
14+
end
515

16+
config = read(vitepress_config_file, String)
617
replacers = Vector{Pair{String, String}}()
718

819

@@ -15,10 +26,15 @@ function modify_config_file(doc, settings, deploy_decision)
1526
# So, after building the Markdown, we need to modify the config file to reflect the
1627
# correct base URL, and then build the VitePress site.
1728
folder = deploy_decision.subfolder
18-
19-
vitepress_config_file = joinpath(doc.user.build, settings.md_output_path, ".vitepress", "config.mts")
20-
config = read(vitepress_config_file, String)
21-
push!(replacers, "base: 'REPLACE_ME_DOCUMENTER_VITEPRESS'" => "base: '/DocumenterVitepress.jl/$(folder)$(isempty(folder) ? "" : "/")'")
29+
deploy_relpath = "$(folder)$(isempty(folder) ? "" : "/")"
30+
deploy_abspath = if isnothing(settings.deploy_url)
31+
"/" * splitdir(settings.repo)[2]
32+
else
33+
s = splitdir(settings.deploy_url)[2]
34+
isempty(s) ? "/" : "/$(s)"
35+
end
36+
37+
push!(replacers, "base: 'REPLACE_ME_DOCUMENTER_VITEPRESS'" => "base: '$(deploy_abspath)/$(deploy_relpath)'")
2238

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

src/writer.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ The `repo` kwarg is used to set the edit link for the documentation.
2828
The `devbranch` and `devurl` kwargs are used to set the path of the static site, which Vitepress expects in advance.
2929
"""
3030
Base.@kwdef struct MarkdownVitepress <: Documenter.Writer
31+
"*Required*: The URL of the repository to which the documentation will be deployed. This must be the full URL, like `rafaqz.github.io/Rasters.jl` or `geo.makie.jl`."
32+
deploy_url::Union{String, Nothing} = nothing
3133
"*Required*: The full URL of the repository to which the documentation will be deployed."
3234
repo::String
3335
"*Required*: The name of the development branch, like `master` or `main`."

0 commit comments

Comments
 (0)