Unreact
A static site generation framework for Rust using Handlebars and Scss.
Submit issue here
Usage
For a quick start, check out Unreact Template
Add the latest version to your Cargo.toml
dependencies
= "*"
Run with --dev
or -d
arguments, for unreact::is_dev()
function to return true
Hot-reloading in dev mode
With the "watch"
feature enabled, the dev server will watch for changes in asset folders (templates
, styles
, and public
; Can be changed with config).
The client will reload if a change was detected.
NOTE: This will NOT reload the client if Rust files (in
src
) were changed! (See below)
Watching router in dev mode
This will watch file in src
, and reload the program. The client should automatically try to reconnect.
cargo watch -x "run -- --dev" -w src -w Cargo.toml
Ignoring "dev"
Feature in Production
Disable default features ("dev"
and "watch"
) for less to compile in production.
Code can be the same as in dev build.
[]
# Disabled `unreact/dev` by default
= { = "*", = false}
[]
# Override `unreact/dev` feature with default features
= ["unreact/dev"]
# Run with `unreact/dev` feature
# Run without `unreact/dev` (for a production server)
Small Example
Create an site with a single index page
use *;
Larger Example
use *;
Automatic Compilation with Github Pages
In .github/workflows/build.yaml
:
name: Build
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches:
pull_request:
branches:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout 🛎️
uses: actions/checkout@v3
# Run compilation script with Rust
- name: Build 🔧
run: cargo run --no-default-features
# Push changes with plugin
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
# This must be the build directory
folder: ./build