Skip to content

Commit

Permalink
improve links and back-navigation via updating to arctic v11.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBrewer317 committed Oct 22, 2024
1 parent 09aa6f4 commit 91b852e
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 9 deletions.
5 changes: 5 additions & 0 deletions arctic_build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
}
// SPA algorithm stolen from Hayleigh Thompson's wonderful Modem library
async function go_to(url, loader, back) {
if (url.pathname === window.location.pathname) {
if (url.hash) document.getElementById(url.hash.slice(1))?.scrollIntoView();
else document.body.scrollIntoView();
return;
}
const $app = document.getElementById('arctic-app');
if (loader) $app.innerHTML = '<div id="arctic-loader"></div>';
if (!back) window.history.pushState({}, '', url.href);
Expand Down
5 changes: 5 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
}
// SPA algorithm stolen from Hayleigh Thompson's wonderful Modem library
async function go_to(url, loader, back) {
if (url.pathname === window.location.pathname) {
if (url.hash) document.getElementById(url.hash.slice(1))?.scrollIntoView();
else document.body.scrollIntoView();
return;
}
const $app = document.getElementById('arctic-app');
if (loader) $app.innerHTML = '<div id="arctic-loader"></div>';
if (!back) window.history.pushState({}, '', url.href);
Expand Down
Binary file modified dist/priv/arctic/_gleam_artefacts/arctic.cache
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]_meta
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]_meta
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]
Binary file not shown.
Binary file modified dist/priv/arctic/_gleam_artefacts/[email protected]_meta
Binary file not shown.
6 changes: 3 additions & 3 deletions dist/priv/arctic/arctic/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ function spa(frame, home) {
$html.div(toList([$attribute.id("arctic-app")]), toList([home])),
$html.script(
toList([]),
"\nif (window.location.pathname !== '/') {\n go_to(new URL(window.location.href), true, true);\n}\n// SPA algorithm stolen from Hayleigh Thompson's wonderful Modem library\nasync function go_to(url, loader, back) {\n const $app = document.getElementById('arctic-app');\n if (loader) $app.innerHTML = '<div id=\"arctic-loader\"></div>';\n if (!back) window.history.pushState({}, '', url.href);\n window.requestAnimationFrame(() => {\n // scroll in #-link elements, as the browser would if we didn't preventDefault\n if (url.hash) {\n document.getElementById(url.hash.slice(1))?.scrollIntoView();\n }\n });\n // handle new path\n console.log(url.pathname);\n const response = await fetch('/__pages/' + url.pathname + '/index.html');\n if (!response.ok) response = await fetch('/__pages/404.html');\n if (!response.ok) return;\n const html = await response.text();\n $app.innerHTML = html;\n}\ndocument.addEventListener('click', async function(e) {\n const a = find_a(e.target);\n if (!a) return;\n try {\n const url = new URL(a.href);\n const is_external = url.host !== window.location.host;\n if (is_external) return;\n event.preventDefault();\n go_to(url, false, false);\n } catch {\n return;\n }\n});\nwindow.addEventListener('popstate', (e) => {\n e.preventDefault();\n const url = new URL(window.location.href);\n go_to(url, false, true);\n});\nfunction find_a(target) {\n if (!target || target.tagName === 'BODY') return null;\n if (target.tagName === 'A') return target;\n return find_a(target.parentElement);\n}\n ",
"\nif (window.location.pathname !== '/') {\n go_to(new URL(window.location.href), true, true);\n}\n// SPA algorithm stolen from Hayleigh Thompson's wonderful Modem library\nasync function go_to(url, loader, back) {\n if (url.pathname === window.location.pathname) {\n if (url.hash) document.getElementById(url.hash.slice(1))?.scrollIntoView();\n else document.body.scrollIntoView();\n return;\n }\n const $app = document.getElementById('arctic-app');\n if (loader) $app.innerHTML = '<div id=\"arctic-loader\"></div>';\n if (!back) window.history.pushState({}, '', url.href);\n window.requestAnimationFrame(() => {\n // scroll in #-link elements, as the browser would if we didn't preventDefault\n if (url.hash) {\n document.getElementById(url.hash.slice(1))?.scrollIntoView();\n }\n });\n // handle new path\n console.log(url.pathname);\n const response = await fetch('/__pages/' + url.pathname + '/index.html');\n if (!response.ok) response = await fetch('/__pages/404.html');\n if (!response.ok) return;\n const html = await response.text();\n $app.innerHTML = html;\n}\ndocument.addEventListener('click', async function(e) {\n const a = find_a(e.target);\n if (!a) return;\n try {\n const url = new URL(a.href);\n const is_external = url.host !== window.location.host;\n if (is_external) return;\n event.preventDefault();\n go_to(url, false, false);\n } catch {\n return;\n }\n});\nwindow.addEventListener('popstate', (e) => {\n e.preventDefault();\n const url = new URL(window.location.href);\n go_to(url, false, true);\n});\nfunction find_a(target) {\n if (!target || target.tagName === 'BODY') return null;\n if (target.tagName === 'A') return target;\n return find_a(target.parentElement);\n}\n ",
),
]),
),
Expand Down Expand Up @@ -403,7 +403,7 @@ function make_ssg_config(processed_collections, config, k) {
throw makeError(
"assignment_no_match",
"arctic/build",
363,
365,
"",
"Assignment pattern did not match",
{ value: $ }
Expand All @@ -420,7 +420,7 @@ function make_ssg_config(processed_collections, config, k) {
throw makeError(
"panic",
"arctic/build",
368,
370,
"",
cached_path,
{}
Expand Down
2 changes: 1 addition & 1 deletion dist/priv/arctic/arctic/config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as $option from "../../gleam_stdlib/gleam/option.mjs";
import { Some, None } from "../../gleam_stdlib/gleam/option.mjs";
import { None, Some } from "../../gleam_stdlib/gleam/option.mjs";
import * as $element from "../../lustre/lustre/element.mjs";
import { text } from "../../lustre/lustre/element.mjs";
import * as $html from "../../lustre/lustre/element/html.mjs";
Expand Down
9 changes: 7 additions & 2 deletions dist/priv/arctic/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,11 @@ if (window.location.pathname !== '/') {
}
// SPA algorithm stolen from Hayleigh Thompson's wonderful Modem library
async function go_to(url, loader, back) {
if (url.pathname === window.location.pathname) {
if (url.hash) document.getElementById(url.hash.slice(1))?.scrollIntoView();
else document.body.scrollIntoView();
return;
}
const $app = document.getElementById('arctic-app');
if (loader) $app.innerHTML = '<div id=\"arctic-loader\"></div>';
if (!back) window.history.pushState({}, '', url.href);
Expand Down Expand Up @@ -563,7 +568,7 @@ make_ssg_config(Processed_collections, Config, K) ->
value => _assert_fail,
module => <<"arctic/build"/utf8>>,
function => <<"make_ssg_config"/utf8>>,
line => 363}
line => 365}
)
end,
Cached_path = <<<<<<"arctic_build"/utf8,
Expand All @@ -580,7 +585,7 @@ make_ssg_config(Processed_collections, Config, K) ->
message => Cached_path,
module => <<"arctic/build"/utf8>>,
function => <<"make_ssg_config"/utf8>>,
line => 368})
line => 370})
end,
lustre@ssg:add_static_asset(
S@1,
Expand Down
Binary file not shown.
Binary file modified dist/priv/arctic_framework_org/_gleam_artefacts/demos.cache
Binary file not shown.
Binary file modified dist/priv/arctic_framework_org/_gleam_artefacts/parser.cache
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target = "javascript"

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
arctic = ">= 11.0.3 and < 12.0.0"
arctic = ">= 11.0.4 and < 12.0.0"
snag = ">= 0.3.0 and < 1.0.0"
lustre = ">= 4.3.2 and < 5.0.0"
gleam_crypto = ">= 1.4.0 and < 2.0.0"
Expand Down
4 changes: 2 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# You typically do not need to edit this file

packages = [
{ name = "arctic", version = "11.0.3", build_tools = ["gleam"], requirements = ["birl", "gleam_crypto", "gleam_stdlib", "gsv", "lustre", "lustre_ssg", "party", "simplifile", "snag"], otp_app = "arctic", source = "hex", outer_checksum = "115BDD35D9A1622979AF17E8B34F999AD97DBBEC49DADD3928098FD4FDC8F378" },
{ name = "arctic", version = "11.0.4", build_tools = ["gleam"], requirements = ["birl", "gleam_crypto", "gleam_stdlib", "gsv", "lustre", "lustre_ssg", "party", "simplifile", "snag"], otp_app = "arctic", source = "hex", outer_checksum = "89054C36E9455E310D566D07195E0275FA5A0CBC0D4C225AAFEBC3EBD95B9F8D" },
{ name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" },
{ name = "envoy", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "CFAACCCFC47654F7E8B75E614746ED924C65BD08B1DE21101548AC314A8B6A41" },
{ name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
Expand All @@ -27,7 +27,7 @@ packages = [
]

[requirements]
arctic = { version = ">= 11.0.3 and < 12.0.0" }
arctic = { version = ">= 11.0.4 and < 12.0.0" }
gleam_crypto = { version = ">= 1.4.0 and < 2.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
Expand Down

0 comments on commit 91b852e

Please sign in to comment.