diff --git a/src/IndexJSON.jl b/src/IndexJSON.jl index 1694f5a..0dd9e8b 100644 --- a/src/IndexJSON.jl +++ b/src/IndexJSON.jl @@ -60,6 +60,13 @@ function json_data( # c === nothing ? nothing : [ # v for (k,v) in sort(pairs(c); by=((k,v)) -> parse(Int, k)) # ], + binder_url=settings.Export.offer_binder ? + something(settings.Export.binder_url, Pluto.default_binder_url) : + nothing, + slider_server_url=somethingornothing( + settings.Export.slider_server_url, + settings.SliderServer.enabled ? "." : nothing, + ), ) end @@ -76,4 +83,8 @@ function generate_index_json( end result = json_data(sessions; settings, start_dir, config_data) JSON.json(result) -end \ No newline at end of file +end + +somethingornothing() = nothing +somethingornothing(x::Nothing, y...) = somethingornothing(y...) +somethingornothing(x::Any, y...) = x diff --git a/test/static export.jl b/test/static export.jl index 8dc5c4d..94f279c 100644 --- a/test/static export.jl +++ b/test/static export.jl @@ -57,6 +57,10 @@ make_test_dir() = @test second_runtime < 1.0 @test occursin("slider_server_url = undefined", read("a.html", String)) + + jsonstr = read("pluto_export.json", String) + json = JSON.parse(jsonstr) + @test json["slider_server_url"] === nothing end @@ -167,6 +171,7 @@ end Export_cache_dir=cache_dir, Export_baked_state=false, Export_create_pluto_featured_index=fancy, + Export_slider_server_url="krat", ) @test sort(list_files_recursive()) == sort([ @@ -193,6 +198,7 @@ end @test occursin("", htmlstr) @test occursin("pluto_export.json", htmlstr) end + @test json["slider_server_url"] == "krat" nbs = ["subdir/c.plutojl", "b.pluto.jl", "a.jl"] for (i, p) in enumerate(nbs)