Leptos + Axum SSR app powering phantie.dev.
cargo leptos watchBy default, cargo-leptos uses nightly Rust, cargo-generate, and sass. If you run into any trouble, you may need to install one or more of these tools.
rustup toolchain install nightly --allow-downgrade- make sure you have Rust nightlyrustup target add wasm32-unknown-unknown- add the ability to compile Rust to WebAssemblycargo install cargo-generate- installcargo-generatebinary (should be installed automatically in future)npm install -g sass- installdart-sass(should be optional in future- Run
npm installin end2end subdirectory before test
cargo leptos build --releaseWill generate your server binary in target/server/release and your site package in target/site
No server needed. Tests run on the host target with the ssr feature:
cargo test --features ssrWhat is covered:
-
features::articles::defs—ArticleCategorytry_frommaps all valid strings (engineering,life,poetry,noop) to the correct varianttry_fromreturnsErrfor unknown or wrong-case stringsto_string→try_fromroundtrip holds for every variant
-
features::articles::instances— article registry integrity- List is non-empty
- All article IDs are unique
- No article has an empty
id,title, orrelative_path written_onis never a later date thancreated_atget_not_found_article()carries the sentinel ID"not_found"Articles::get_by_idreturns the correct article for a known IDArticles::get_by_idreturns the not-found article for an unknown ID
-
features::articles::components::article—build_article_json_ld- Required JSON-LD fields are present (
@context,@type,headline,description,url,author) - Special characters in title/description are escaped (
",\, newlines) - Dates are formatted as ISO 8601 (
YYYY-MM-DD) datePublished/dateCreatedfields absent when dates areNone- Tags serialised as a JSON array under
keywords; field omitted when no tags
- Required JSON-LD fields are present (
Requires the dev server to be running:
cd misc && cargo leptos watchThen in a separate terminal:
# First time only
cd misc/end2end && npm install && npx playwright install
npx playwright test --project=chromiumTo run against a different origin (e.g. production):
BASE_URL=https://phantie.dev npx playwright test --project=chromiumWhat is covered (end2end/tests/seo.spec.ts):
robots.txt— correctContent-Type,User-agent: *,Allow: /,Sitemap:line presentsitemap.xml— correctContent-Type, valid XML structure, known article IDs present, all<loc>entries share a single origin (no mixed localhost/prod URLs)- Homepage — correct
<title>, canonical<link>present and well-formed, canonical origin matches the page origin after client-side hydration - Article page — title differs from site default, canonical contains article ID in SSR HTML, canonical origin matches page origin after hydration,
<script type="application/ld+json">present withBlogPostingtype,og:urlpresent in SSR HTML, article content present in SSR HTML (not dependent on JavaScript)
What is covered (end2end/tests/app.spec.ts):
- Homepage — all three category section links (Engineering, Poetry, Life) are visible
- Article list — engineering category renders at least one article link; unknown category redirects to home
- Article page — unknown article ID redirects to home; header home link points to
/; reading progress bar is present in the DOM
After running a cargo leptos build --release the minimum files needed are:
- The server binary located in
target/server/release - The
sitedirectory and all files within located intarget/site
Copy these files to your remote server. The directory structure should be:
misc
site/
Set the following environment variables (updating for your project as needed):
export LEPTOS_OUTPUT_NAME="misc"
export LEPTOS_SITE_ROOT="site"
export LEPTOS_SITE_PKG_DIR="pkg"
export LEPTOS_SITE_ADDR="127.0.0.1:3000"
export LEPTOS_RELOAD_PORT="3001"Finally, run the server binary.
This template itself is released under the Unlicense. You should replace the LICENSE for your own application with an appropriate license if you plan to release it publicly.