Skip to content

Commit 2949cc0

Browse files
committed
feat: basic working blog w markdown content
0 parents  commit 2949cc0

20 files changed

+2073
-0
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8+
Cargo.lock
9+
10+
# These are backup files generated by rustfmt
11+
**/*.rs.bk
12+
13+
# MSVC Windows builds of rustc generate these, which store debugging information
14+
*.pdb
15+
16+
# IntelliJ IDEA files
17+
.idea/

Cargo.toml

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
[package]
2+
name = "miniref"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
crate-type = ["cdylib", "rlib"]
8+
9+
[dependencies]
10+
leptos = { version = "0.7.0", features = ["nightly"] }
11+
leptos_router = { version = "0.7.0", features = ["nightly"] }
12+
# Axum and leptos_axum must have a version match
13+
axum = { version = "0.7.0", optional = true }
14+
console_error_panic_hook = "0.1"
15+
leptos_axum = { version = "0.7.0", optional = true }
16+
leptos_meta = { version = "0.7.0" }
17+
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
18+
tower = { version = "0.5.2", optional = true }
19+
tower-http = { version = "0.6.2", features = ["fs"], optional = true }
20+
wasm-bindgen = "=0.2.99"
21+
thiserror = "1"
22+
http = "1"
23+
serde = { version = "1.0.217", features = ["derive"]}
24+
gray_matter = { version = "0.2.8", optional = true }
25+
reqwest = { version = "0.12.12", features = ["json"], optional = true }
26+
katex = { version = "0.4.6", features = ["quick-js"], optional = true }
27+
regex = { version = "1.11.1", optional = true }
28+
syntect = { version = "5.2.0", optional = true }
29+
html-escape = { version = "0.2.13", optional = true }
30+
web-sys = "0.3.76"
31+
js-sys = "0.3.76"
32+
33+
[dependencies.markdown]
34+
version = "1.0.0-alpha.21"
35+
optional = true
36+
37+
[dependencies.mime_guess]
38+
version = "2.0"
39+
optional = true
40+
41+
42+
[features]
43+
hydrate = ["leptos/hydrate"]
44+
ssr = [
45+
"dep:axum",
46+
"dep:gray_matter",
47+
"dep:katex",
48+
"dep:regex",
49+
"dep:syntect",
50+
"dep:html-escape",
51+
"dep:markdown",
52+
"dep:mime_guess",
53+
"dep:reqwest",
54+
"dep:tokio",
55+
"dep:tower",
56+
"dep:tower-http",
57+
"dep:leptos_axum",
58+
"leptos/ssr",
59+
"leptos_meta/ssr",
60+
"leptos_router/ssr",
61+
]
62+
63+
# Defines a size-optimized profile for the WASM bundle in release mode
64+
[profile.wasm-release]
65+
inherits = "release"
66+
opt-level = 'z'
67+
lto = true
68+
codegen-units = 1
69+
panic = "abort"
70+
71+
[package.metadata.leptos]
72+
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
73+
output-name = "miniref"
74+
75+
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
76+
site-root = "target/site"
77+
78+
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
79+
# Defaults to pkg
80+
site-pkg-dir = "pkg"
81+
82+
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
83+
style-file = "style/main.scss"
84+
# Assets source dir. All files found here will be copied and synchronized to site-root.
85+
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
86+
#
87+
# Optional. Env: LEPTOS_ASSETS_DIR.
88+
assets-dir = "public"
89+
90+
# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
91+
site-addr = "127.0.0.1:3000"
92+
93+
# The port to use for automatic reload monitoring
94+
reload-port = 3001
95+
96+
# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
97+
# [Windows] for non-WSL use "npx.cmd playwright test"
98+
# This binary name can be checked in Powershell with Get-Command npx
99+
end2end-cmd = "pnpm playwright test"
100+
end2end-dir = "end2end"
101+
102+
# The browserlist query used for optimizing the CSS.
103+
browserquery = "defaults"
104+
105+
# The environment Leptos will run in, usually either "DEV" or "PROD"
106+
env = "DEV"
107+
108+
# The features to use when compiling the bin target
109+
#
110+
# Optional. Can be over-ridden with the command line parameter --bin-features
111+
bin-features = ["ssr"]
112+
113+
# If the --no-default-features flag should be used when compiling the bin target
114+
#
115+
# Optional. Defaults to false.
116+
bin-default-features = false
117+
118+
# The features to use when compiling the lib target
119+
#
120+
# Optional. Can be over-ridden with the command line parameter --lib-features
121+
lib-features = ["hydrate"]
122+
123+
# If the --no-default-features flag should be used when compiling the lib target
124+
#
125+
# Optional. Defaults to false.
126+
lib-default-features = false
127+
128+
# The profile to use for the lib target when compiling for release
129+
#
130+
# Optional. Defaults to "release".
131+
lib-profile-release = "wasm-release"

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# MiniRef
2+
3+
An example project using leptos to build a full stack server side rendered web
4+
application which loads data from an API. It's called miniref because it's a
5+
minimal version of a zettlekasten reference system.
6+
7+
## Running the project
8+
9+
```bash
10+
cargo leptos watch
11+
```
12+
13+
## Installing Additional Tools
14+
15+
By default, `cargo-leptos` uses `nightly` Rust, `cargo-generate`, and `sass`. If you run into any trouble, you may need to install one or more of these tools.
16+
17+
1. `rustup toolchain install nightly --allow-downgrade` - make sure you have Rust nightly
18+
2. `rustup target add wasm32-unknown-unknown` - add the ability to compile Rust to WebAssembly
19+
3. `cargo install cargo-generate` - install `cargo-generate` binary (should be installed automatically in future)
20+
4. `npm install -g sass` - install `dart-sass` (should be optional in future
21+
5. Run `npm install` in end2end subdirectory before test
22+
23+
## Compiling for Release
24+
25+
```bash
26+
cargo leptos build --release
27+
```
28+
29+
Will generate your server binary in target/server/release and your site package in target/site
30+
31+
## Testing the Project
32+
33+
```bash
34+
cargo leptos end-to-end
35+
```
36+
37+
```bash
38+
cargo leptos end-to-end --release
39+
```
40+
41+
Cargo-leptos uses Playwright as the end-to-end test tool.
42+
Tests are located in end2end/tests directory.
43+
44+
## Executing a Server on a Remote Machine Without the Toolchain
45+
46+
After running a `cargo leptos build --release` the minimum files needed are:
47+
48+
1. The server binary located in `target/server/release`
49+
2. The `site` directory and all files within located in `target/site`
50+
51+
Copy these files to your remote server. The directory structure should be:
52+
53+
```text
54+
miniref
55+
site/
56+
```
57+
58+
Set the following environment variables (updating for your project as needed):
59+
60+
```sh
61+
export LEPTOS_OUTPUT_NAME="miniref"
62+
export LEPTOS_SITE_ROOT="site"
63+
export LEPTOS_SITE_PKG_DIR="pkg"
64+
export LEPTOS_SITE_ADDR="127.0.0.1:3000"
65+
export LEPTOS_RELOAD_PORT="3001"
66+
```
67+
68+
Finally, run the server binary.

end2end/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
playwright-report
3+
test-results

end2end/package-lock.json

+167
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)