diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index 199d962..be7ab56 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -68,11 +68,14 @@ jobs: stage=$(mktemp -d) cp "$CARGO_TARGET_DIR/release/portal" "$stage/portal" cp "$CARGO_TARGET_DIR/release/question_lint" "$stage/question_lint" + # hash-files = true: leptos resolves hash.txt next to the running + # binary, so it ships beside portal in the release dir. + cp "$CARGO_TARGET_DIR/release/hash.txt" "$stage/hash.txt" # site-root ("target/site" in Cargo.toml) is project-relative, # not affected by CARGO_TARGET_DIR - only the plain `cargo build` # outputs (release/, front/) move with that override. cp -r target/site "$stage/site" - tar -C "$stage" -czf "portal-$tag.tar.gz" portal question_lint site + tar -C "$stage" -czf "portal-$tag.tar.gz" portal question_lint hash.txt site rm -rf "$stage" # The run's own ephemeral token has write access to this repo - diff --git a/Cargo.toml b/Cargo.toml index f54c9c2..8f02864 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,6 +131,12 @@ bin-default-features = false lib-features = ["hydrate"] lib-default-features = false lib-profile-release = "wasm-release" +# Content-hashed pkg names (portal..js/wasm/css) + hash.txt: a +# freshly served page can never reference a stale cached bundle - an +# iPhone kept a heuristically-cached portal.js across three releases +# and paired it with new wasm, silently killing hydration. Runtime +# needs LEPTOS_HASH_FILES=true (set in each content repo's deploy env). +hash-files = true # cargo release is how a portal version is cut: bump, commit, # tag v{{version}}, push. CI (publish.yml) reacts to the tag and diff --git a/src/app.rs b/src/app.rs index fda01e7..bd08c6f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,5 +1,5 @@ use leptos::prelude::*; -use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title}; +use leptos_meta::{provide_meta_context, HashedStylesheet, MetaTags, Title}; use leptos_router::{ components::{Route, Router, Routes}, hooks::{use_location, use_navigate, use_query_map}, @@ -39,6 +39,9 @@ pub fn shell(options: LeptosOptions) -> impl IntoView { // once loaded via / on Safari/iOS. + // Server-side, so it can read hash.txt and link the + // content-hashed stylesheet (hash-files = true). + @@ -67,7 +70,6 @@ pub fn App() -> impl IntoView { provide_context(site); view! { - {move || { site.get()