Skip to content

Commit d9b500d

Browse files
authored
Copy, don't move, files in the assets folder (#66)
* Copy, don't move, files in the assets folder * Update writer.jl * Update writer.jl * Update writer.jl
1 parent e801f8e commit d9b500d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/writer.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ where `Eltype` is the type of the `element` field of the `node` object which you
8787
function render(doc::Documenter.Document, settings::MarkdownVitepress=MarkdownVitepress())
8888
# Main.@exfiltrate
8989
@info "DocumenterVitepress: rendering MarkdownVitepress pages."
90-
copy_assets(doc, settings.md_output_path)
90+
# copy_assets(doc, settings.md_output_path)
9191
# Handle the case where the site name has to be set...
9292
mime = MIME"text/plain"() # TODO: why?
9393
builddir = isabspath(doc.user.build) ? doc.user.build : joinpath(doc.user.root, doc.user.build)
@@ -105,7 +105,22 @@ function render(doc::Documenter.Document, settings::MarkdownVitepress=MarkdownVi
105105
# Documenter.jl wants assets in `assets/`, but Vitepress likes them in `public/`,
106106
# so we rename the folder.
107107
if isdir(joinpath(builddir, settings.md_output_path, "assets")) && !isdir(joinpath(builddir, settings.md_output_path, "public"))
108-
mv(joinpath(builddir, settings.md_output_path, "assets"), joinpath(builddir, settings.md_output_path, "public"))
108+
mkpath(joinpath(builddir, settings.md_output_path, "public"))
109+
files = readdir(joinpath(builddir, settings.md_output_path, "assets"); join = true)
110+
logo_files = contains.(last.(splitdir.(files)), "logo")
111+
favicon_files = contains.(last.(splitdir.(files)), "favicon")
112+
if any(logo_files)
113+
for file in files[logo_files]
114+
file_relpath = relpath(file, joinpath(builddir, settings.md_output_path, "assets"))
115+
cp(joinpath(builddir, settings.md_output_path, "assets", file_relpath), joinpath(builddir, settings.md_output_path, "public", file_relpath))
116+
end
117+
end
118+
if any(favicon_files)
119+
for file in files[favicon_files]
120+
file_relpath = relpath(file, joinpath(builddir, settings.md_output_path, "assets"))
121+
cp(joinpath(builddir, settings.md_output_path, "assets", file_relpath), joinpath(builddir, settings.md_output_path, "public", file_relpath))
122+
end
123+
end
109124
end
110125
# Main.@infiltrate
111126
# Iterate over the pages, render each page separately

0 commit comments

Comments
 (0)