badery.co Blog
A Wasm-based, low effort blog that loads MD/MDx files. Made with Trunk and Yew.
Posts are stored via posts/ in the project's root, which Trunk copies over on build. Wasm bindings are used to call fetch, where the post is rendered as HTML and displayed.
Note: please do not delete
metadata.json- it's used for loading posts! It is autogenerated on each build, where it parses each post's header:The
idmust also match the filename! (id: example->example.md)
---
title: Example title
id: example
date: Jan 1st 1900
author: example author
desc: Example!!
---For a more thorough explanation of Trunk and its features, please head over to the repository.
If you don't already have it installed, it's time to install Rust: https://www.rust-lang.org/tools/install.
The rest of this guide assumes a typical Rust installation which contains both rustup and Cargo.
To compile Rust to WASM, we need to have the wasm32-unknown-unknown target installed.
If you don't already have it, install it with the following command:
rustup target add wasm32-unknown-unknownNow that we have our basics covered, it's time to install the star of the show: Trunk. Simply run the following command to install it:
cargo install trunk wasm-bindgen-cliThat's it, we're done!
trunk serveRebuilds the app whenever a change is detected and runs a local server to host it.
There's also the trunk watch command which does the same thing but without hosting it.
trunk build --releaseThis builds the app in release mode similar to cargo build --release.
You can also pass the --release flag to trunk serve if you need to get every last drop of performance.
Unless overwritten, the output will be located in the dist directory.