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:
23
build.rs
23
build.rs
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user