Skip to content

Commit b23a8db

Browse files
authored
Merge pull request #34 from JuliaComputing/sp/absoute-urls
feat: allow absolute urls for scripts, styles, and brand image
2 parents 39a05f5 + f8a9c82 commit b23a8db

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/MultiDocumenter.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,16 @@ function make_global_stylesheet(custom_stylesheets, path)
231231
out = []
232232

233233
for stylesheet in custom_stylesheets
234+
stylesheet = startswith(stylesheet, r"https?://") ?
235+
stylesheet :
236+
replace(joinpath(path, stylesheet), raw"\\" => "/")
234237
style = Gumbo.HTMLElement{:link}(
235238
[],
236239
Gumbo.NullNode(),
237240
Dict(
238241
"rel" => "stylesheet",
239242
"type" => "text/css",
240-
"href" => string(path, "/", stylesheet),
243+
"href" => stylesheet,
241244
),
242245
)
243246
push!(out, style)
@@ -250,11 +253,14 @@ function make_global_scripts(custom_scripts, path)
250253
out = []
251254

252255
for script in custom_scripts
256+
script = startswith(script, r"https?://") ?
257+
script :
258+
replace(joinpath(path, script), raw"\\" => "/")
253259
js = Gumbo.HTMLElement{:script}(
254260
[],
255261
Gumbo.NullNode(),
256262
Dict(
257-
"src" => string(path, "/", script),
263+
"src" => script,
258264
"type" => "text/javascript",
259265
"charset" => "utf-8",
260266
),

src/renderers.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
render(::Nothing, args...) = nothing
22

33
function render(brand_image::BrandImage, dir, thispagepath)
4+
href = startswith(brand_image.path, "https?://") ?
5+
brand_image.path :
6+
relpath(joinpath(dir, brand_image.path), thispagepath)
7+
src = startswith(brand_image.imagepath, "https?://") ?
8+
brand_image.imagepath :
9+
relpath(joinpath(dir, brand_image.imagepath), thispagepath)
410
return @htl """
5-
<a class="brand" href="$(relpath(joinpath(dir, brand_image.path), thispagepath))">
6-
<img src="$(relpath(joinpath(dir, brand_image.imagepath), thispagepath))" alt="home">
11+
<a class="brand" href="$(href)">
12+
<img src="$(src)" alt="home">
713
</a>"""
814
end
915

0 commit comments

Comments
 (0)