nyan.rs — Hikari's personal site: one Rust crate that is a Leptos 0.8 app, an axum SSR server, and a markdown-to-static-site compiler. https://nyan.rs
  • Rust 75.4%
  • CSS 21.1%
  • HTML 2%
  • Shell 1.5%
Find a file
Hikari c46eb2b87d
drop the CI workflow
nyan.rs has no Actions runner and does not need one: ./start.sh check
(tests + cargo check for server, hydrate and csr) is the whole pre-push
step, and it takes seconds.
2026-11-05 13:31:43 +00:00
assets nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
content/blog nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
deploy nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
src nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
.gitignore nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
Cargo.lock nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
Cargo.toml nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
index.html nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
index.hydrate.html nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
LICENSE nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
README.md drop the CI workflow 2026-11-05 13:31:43 +00:00
start.sh nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00
Trunk.toml nyan.rs: a personal site compiled from Rust 2026-11-05 12:41:20 +00:00

nyan.rs

Hikari's corner of the internet: one Rust crate that is a Leptos app, an axum server, and a static site generator at the same time. The blog is a folder of markdown compiled by an interpreter written for this repo — no CMS, no database, no analytics, no cookies.

content/blog/*.md  ──►  src/blog (front matter + pulldown-cmark)  ──►  Leptos views
                                                                     │
                                    ┌────────────────────────────────┼──────────────────────┐
                                    ▼                                ▼                      ▼
                              wasm (csr/hydrate)              axum server            static export
                              1.1 MB wasm                    127.0.0.1:8099           dist/*.html

Run it

./start.sh              # release wasm + static export, then serve on 0.0.0.0:8099
./start.sh dev          # trunk serve: csr wasm app with hot reload, :8099
./start.sh build        # dist/ only (release wasm bundle + flat HTML)
./start.sh serve        # axum server against the existing dist/pkg bundle
./start.sh check        # cargo test + cargo check for server, hydrate and csr targets

Port 8099 because 3000 is the forge, 8080 is trunk's default and 8005 is the local search box. Override with NYAN_ADDR=127.0.0.1:1234 ./start.sh serve.

Needs trunk and the wasm target for the browser builds:

cargo install trunk --locked
rustup target add wasm32-unknown-unknown

The server and the exporter need no wasm at all — cargo run --bin export --no-default-features --features ssr alone gives you a complete dist/ of plain HTML (the live GitHub panel degrades to a note instead of a spinner).

Three targets, one component tree

feature binary what it does
csr csr wasm app that renders the whole page into an empty <body> (dev, SPA)
hydrate hydrate wasm bundle that hydrates server-rendered HTML (the deployed site)
ssr server axum server: renders each request, serves dist/pkg, feeds, assets
ssr export walks the route list and writes flat files to dist/ (the deploy target)

src/render.rs::render_fragment is the single render path — the server and the exporter cannot drift apart, and render::routes() feeds both the exporter and the sitemap.

Blog

Drop a file in content/blog/; the folder is scanned recursively and, for wasm builds, embedded at compile time with include_dir! so the static site needs no backend to list posts.

---
title: Two machines, one keyboard
date: 2026-10-12
updated: 2026-10-14            # optional
tags: [rust, hardware]         # or: rust, hardware
summary: Short deck for the index and RSS.
slug: two-machines             # optional, derived from the title
draft: true                    # optional, kept out of the site
pinned: 1                      # optional, sorts first in the index
---

Markdown here. `##`/`###` headings get ids and a table of contents, tables and
code blocks get wrappers, external links get `rel="noopener noreferrer"`, and
raw HTML is sanitised (no `script`, no `on*`, no `javascript:`).

The interpreter lives in src/blog/: its own front-matter parser (no YAML dependency), a pulldown-cmark event sink that emits heading anchors, TOC, word count and reading time, an excerpt builder for the index, and an RSS 2.0 feed (Blog::feed). cargo test --lib covers it.

Layout

src/blog/       markdown → posts: front matter, markdown sink, TOC, RSS, tests
src/site.rs     all copy and data: links, projects, machines, ticker, colophon
src/art.rs      generated SVG (the nyan mark, rainbow rules, paws) — no image files
src/components.rs  nav, hero, about, rigs, projects, links, footer, live repo panel
src/pages.rs    routes: Home, BlogPage, BlogPostRoute, NotFound
src/lib.rs      App + router, the `<!>` hydration boundary
src/render.rs   the shared SSR entry point, route list, wasm bundle discovery
src/template.rs document shell: per-route meta, canonical, OG, hydration script
src/server.rs   axum: SSR + assets + feeds + 404, canonical trailing slashes
src/export.rs   static generator: pages, 404, feed.xml, sitemap.xml, robots.txt
assets/site.css the whole design system (night/dawn themes)

Deploy

The site is meant to be files. ./start.sh build produces dist/:

dist/index.html  dist/blog/index.html  dist/blog/<slug>/index.html
dist/404.html    dist/feed.xml         dist/sitemap.xml  dist/robots.txt
dist/assets/…    dist/pkg/hydrate-<hash>.{js,wasm}

Put dist/ behind any static host. Caddy needs one non-obvious thing — wasm MIME for instantiateStreaming:

nyan.rs {
    root * /srv/nyan.rs/dist
    encode zstd br
    header /pkg/* Cache-Control "public, max-age=31536000, immutable"
    @wasm path *.wasm
    header @wasm Content-Type "application/wasm"
    handle_errors { rewrite * /404.html; file_server }
    file_server
}
blog.nyan.rs { redir https://nyan.rs/blog{uri} permanent }

deploy/ also carries a systemd unit for the SSR server (same renderer, live feed.xml, no rebuild to publish a post) if you would rather run the binary.

Gotchas this repo already paid for

  • No whitespace between <body> and the rendered app. Leptos hydrates by walking <body>'s children; a stray newline means it finds a text node where it expects <header>, and with panic="abort" wasm dies silently.
  • A trunk --target web bundle does nothing when merely linked. The shell has to import init from "/pkg/x.js"; await init({ module_or_path: … }) (template.rs::hydration_script).
  • SSR and the client must render the same tree. Anything browser-only (the GitHub panel) has to start in a state the server can also render — see components::HasClient.
  • trunk's wasm-opt is off (data-wasm-opt="0"): wasm-opt v123/v129 rejects rustc 1.98 output without --enable-bulk-memory-opt and trunk passes no feature flags. 1.1 MB release wasm, ~350 KB brotli.
  • attr: prefixes are gone in Leptos 0.8 — attr:aria-pressed renders as an attribute literally called attr:aria-pressed. Bool attribute values are dropped, so pass strings for aria-*.
  • Release wasm hides hydration errors. Debug bundles log them in the console; a CDP driver (Runtime.exceptionThrown + Log.entryAdded) is how to see them.