Add frontend JS and improve post styling

Frontend is built with Bun. It uses Stimulus to progressively enhance
the server-built HTML. Currently, it only replaces UTC timestamps from
the server with the time in the browser's timezone.
This commit is contained in:
2023-06-27 14:03:52 -04:00
parent 7e06d23bba
commit 76cc87631f
15 changed files with 331 additions and 4 deletions

View File

@@ -1,3 +1,26 @@
use std::env;
use std::fs;
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=migrations");
let root_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let root_dir = Path::new(&root_dir);
let dir = root_dir.join("static/js");
let entries = fs::read_dir(&dir).unwrap();
let js_bundles: Vec<String> = entries
.filter_map(Result::ok)
.filter(|entry| entry.file_name().to_string_lossy().ends_with(".js"))
.map(|entry| {
Path::new("/")
.join(entry.path().strip_prefix(root_dir).unwrap())
.display()
.to_string()
})
.collect();
fs::write(dir.join("js_bundles.txt"), js_bundles.join("\n")).unwrap();
}