designing

This commit is contained in:
cbax 2024-10-24 02:00:01 -04:00
parent 0e20b1d53c
commit b21c492f54
10 changed files with 566 additions and 54 deletions

448
Cargo.lock generated
View file

@ -59,6 +59,55 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "anstream"
version = "0.6.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]]
name = "anstyle-parse"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
]
[[package]]
name = "arraydeque"
version = "0.5.1"
@ -258,6 +307,21 @@ dependencies = [
"serde",
]
[[package]]
name = "bit-set"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bitflags"
version = "1.3.2"
@ -291,12 +355,28 @@ dependencies = [
"alloc-stdlib",
]
[[package]]
name = "bumpalo"
version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "bytes"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
[[package]]
name = "caseless"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f"
dependencies = [
"regex",
"unicode-normalization",
]
[[package]]
name = "cbax_dev"
version = "0.1.0"
@ -305,8 +385,8 @@ dependencies = [
"askama_axum",
"axum",
"axum-server-timing",
"comrak",
"gray_matter",
"markdown",
"notify",
"serde",
"syntect",
@ -315,6 +395,7 @@ dependencies = [
"tower-http",
"tracing",
"tracing-subscriber",
"two-face",
"walkdir",
]
@ -334,6 +415,74 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
"terminal_size",
]
[[package]]
name = "clap_derive"
version = "4.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]]
name = "colorchoice"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]]
name = "comrak"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8c32ff8b21372fab0e9ecc4e42536055702dc5faa418362bffd1544f9d12637"
dependencies = [
"caseless",
"clap",
"derive_builder",
"entities",
"memchr",
"once_cell",
"regex",
"shell-words",
"slug",
"syntect",
"typed-arena",
"unicode_categories",
"xdg",
]
[[package]]
name = "crc32fast"
version = "1.3.2"
@ -358,6 +507,41 @@ version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "darling"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
dependencies = [
"darling_core",
"quote",
"syn",
]
[[package]]
name = "deranged"
version = "0.3.11"
@ -367,6 +551,43 @@ dependencies = [
"powerfmt",
]
[[package]]
name = "derive_builder"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947"
dependencies = [
"derive_builder_macro",
]
[[package]]
name = "derive_builder_core"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "derive_builder_macro"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
dependencies = [
"derive_builder_core",
"syn",
]
[[package]]
name = "deunicode"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00"
[[package]]
name = "encoding_rs"
version = "0.8.34"
@ -376,12 +597,38 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "entities"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "fancy-regex"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
dependencies = [
"bit-set",
"regex",
]
[[package]]
name = "filetime"
version = "0.2.25"
@ -522,6 +769,12 @@ dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.3.9"
@ -625,6 +878,12 @@ dependencies = [
"tower-service",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "indexmap"
version = "2.6.0"
@ -665,6 +924,12 @@ dependencies = [
"serde",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itoa"
version = "1.0.10"
@ -735,6 +1000,12 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
[[package]]
name = "lock_api"
version = "0.4.11"
@ -751,15 +1022,6 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "markdown"
version = "1.0.0-alpha.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6491e6c702bf7e3b24e769d800746d5f2c06a6c6a2db7992612e0f429029e81"
dependencies = [
"unicode-id",
]
[[package]]
name = "matchers"
version = "0.1.0"
@ -1114,6 +1376,19 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.38.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
dependencies = [
"bitflags 2.4.1",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
]
[[package]]
name = "rustversion"
version = "1.0.14"
@ -1203,6 +1478,12 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "signal-hook-registry"
version = "1.4.1"
@ -1221,6 +1502,16 @@ dependencies = [
"autocfg",
]
[[package]]
name = "slug"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724"
dependencies = [
"deunicode",
"wasm-bindgen",
]
[[package]]
name = "smallvec"
version = "1.11.2"
@ -1237,6 +1528,12 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.82"
@ -1268,6 +1565,7 @@ checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1"
dependencies = [
"bincode",
"bitflags 1.3.2",
"fancy-regex",
"flate2",
"fnv",
"once_cell",
@ -1282,6 +1580,16 @@ dependencies = [
"yaml-rust",
]
[[package]]
name = "terminal_size"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef"
dependencies = [
"rustix",
"windows-sys 0.59.0",
]
[[package]]
name = "thiserror"
version = "1.0.65"
@ -1343,6 +1651,21 @@ dependencies = [
"time-core",
]
[[package]]
name = "tinyvec"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.41.0"
@ -1531,6 +1854,23 @@ dependencies = [
"tracing-log",
]
[[package]]
name = "two-face"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ccd4843ea031c609fe9c16cae00e9657bad8a9f735a3cc2e420955d802b4268"
dependencies = [
"once_cell",
"serde",
"syntect",
]
[[package]]
name = "typed-arena"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "unicase"
version = "2.7.0"
@ -1540,18 +1880,33 @@ dependencies = [
"version_check",
]
[[package]]
name = "unicode-id"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10103c57044730945224467c09f71a4db0071c123a0648cc3e818913bde6b561"
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-normalization"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode_categories"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "uuid"
version = "1.6.1"
@ -1589,6 +1944,61 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
[[package]]
name = "winapi"
version = "0.3.9"
@ -1768,6 +2178,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "xdg"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546"
[[package]]
name = "yaml-rust"
version = "0.4.5"

View file

@ -10,8 +10,8 @@ askama = { version = "0.12.1", features = ["with-axum"] }
askama_axum = "0.4.0"
axum = "0.7.7"
axum-server-timing = "1.0.1"
comrak = "0.29.0"
gray_matter = "0.2.8"
markdown = "1.0.0-alpha.21"
notify = "6.1.1"
serde = { version = "1.0.213", features = ["derive"] }
syntect = "5.2.0"
@ -20,4 +20,5 @@ tower = "0.5.1"
tower-http = { version = "0.6.1", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
two-face = "0.4.0"
walkdir = "2.5.0"

View file

@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::hash::Hash;
use std::sync::{Arc, RwLock};
use askama::Template;
@ -10,14 +9,16 @@ use axum::{
routing::get,
Router,
};
use comrak::plugins::syntect::SyntectAdapterBuilder;
use comrak::{markdown_to_html_with_plugins, Options, Plugins};
use gray_matter::engine::YAML;
use gray_matter::Matter;
use notify::{RecursiveMode, Watcher};
use tower::ServiceBuilder;
use tower_http::services::ServeDir;
use tower_http::trace::TraceLayer;
use tracing::Instrument;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use two_face::theme::{extra, LazyThemeSet};
#[derive(Clone)]
pub struct Meta {
@ -108,7 +109,7 @@ async fn blog(State(state): State<Arc<RwLock<AppState>>>) -> Result<impl IntoRes
.read()
.unwrap()
.styles
.get("core.css")
.get("nord.css")
.unwrap()
.clone();
styles.push_str(
@ -116,7 +117,7 @@ async fn blog(State(state): State<Arc<RwLock<AppState>>>) -> Result<impl IntoRes
.read()
.unwrap()
.styles
.get("nord.css")
.get("colors.css")
.unwrap()
.as_str(),
);
@ -125,7 +126,7 @@ async fn blog(State(state): State<Arc<RwLock<AppState>>>) -> Result<impl IntoRes
.read()
.unwrap()
.styles
.get("colors.css")
.get("core.css")
.unwrap()
.as_str(),
);
@ -178,7 +179,7 @@ async fn blog_post(
.read()
.unwrap()
.styles
.get("core.css")
.get("nord.css")
.unwrap()
.clone();
styles.push_str(
@ -186,7 +187,7 @@ async fn blog_post(
.read()
.unwrap()
.styles
.get("nord.css")
.get("colors.css")
.unwrap()
.as_str(),
);
@ -195,7 +196,7 @@ async fn blog_post(
.read()
.unwrap()
.styles
.get("colors.css")
.get("core.css")
.unwrap()
.as_str(),
);
@ -240,7 +241,7 @@ async fn homelab(
.read()
.unwrap()
.styles
.get("core.css")
.get("nord.css")
.unwrap()
.clone();
styles.push_str(
@ -248,7 +249,7 @@ async fn homelab(
.read()
.unwrap()
.styles
.get("nord.css")
.get("colors.css")
.unwrap()
.as_str(),
);
@ -257,7 +258,7 @@ async fn homelab(
.read()
.unwrap()
.styles
.get("colors.css")
.get("core.css")
.unwrap()
.as_str(),
);
@ -290,7 +291,7 @@ async fn index(
.read()
.unwrap()
.styles
.get("core.css")
.get("nord.css")
.unwrap()
.clone();
styles.push_str(
@ -298,7 +299,7 @@ async fn index(
.read()
.unwrap()
.styles
.get("nord.css")
.get("colors.css")
.unwrap()
.as_str(),
);
@ -307,7 +308,7 @@ async fn index(
.read()
.unwrap()
.styles
.get("colors.css")
.get("core.css")
.unwrap()
.as_str(),
);
@ -364,6 +365,15 @@ async fn main() {
body: "this is a test post!".into(),
},
);
let builder = SyntectAdapterBuilder::new()
.theme_set(syntect::highlighting::ThemeSet::from(&LazyThemeSet::from(
extra(),
)))
.theme("Nord");
let adapter = builder.build();
let options = Options::default();
let mut plugins = Plugins::default();
plugins.render.codefence_syntax_highlighter = Some(&adapter);
for entry in walkdir::WalkDir::new("./posts") {
let entry = entry.unwrap();
if entry.file_type().is_file() {
@ -393,11 +403,11 @@ async fn main() {
Post {
meta,
cover_img_path: String::new(),
body: markdown::to_html_with_options(
body: markdown_to_html_with_plugins(
matter_result.content.as_str(),
&markdown::Options::gfm(),
)
.unwrap(),
&options,
&plugins,
),
},
);
}
@ -418,10 +428,16 @@ async fn main() {
let mut css_watcher =
notify::recommended_watcher(move |res: Result<notify::Event, notify::Error>| match res {
Ok(event) => {
println!("event triggered: {:?}", event);
if event.kind.is_create() || event.kind.is_modify() {
for path in event.paths.iter() {
for path in event.paths.iter().filter(|p| {
if p.extension().is_some() {
p.extension().unwrap() == "css"
} else {
false
}
}) {
println!("refreshing css: {}", path.to_string_lossy());
std::thread::sleep(std::time::Duration::from_millis(1));
let file: String = std::fs::read_to_string(&path).unwrap();
notify_state1.clone().write().unwrap().styles.insert(
path.file_name().unwrap().to_string_lossy().to_string(),
@ -438,6 +454,15 @@ async fn main() {
Ok(mut event) => {
if event.kind.is_create() || event.kind.is_modify() {
event.paths.dedup();
let builder = SyntectAdapterBuilder::new()
.theme_set(syntect::highlighting::ThemeSet::from(&LazyThemeSet::from(
extra(),
)))
.theme("Nord");
let adapter = builder.build();
let options = Options::default();
let mut plugins = Plugins::default();
plugins.render.codefence_syntax_highlighter = Some(&adapter);
for path in event.paths.iter().filter(|p| {
if p.extension().is_some() {
p.extension().unwrap() == "md"
@ -473,11 +498,11 @@ async fn main() {
Post {
meta,
cover_img_path: String::new(),
body: markdown::to_html_with_options(
body: markdown_to_html_with_plugins(
matter_result.content.as_str(),
&markdown::Options::gfm(),
)
.unwrap(),
&options,
&plugins,
),
},
);
}

View file

@ -7,9 +7,10 @@
--bg-color: var(--nord0);
--text-color: var(--nord4);
--article-color: var(--nord2);
--highlight-color: var(--nord8);
--highlight-color-rgb: 133, 64, 201;
--highlight-color-rgb: var(--nord8-rgb);
}
/* Detect which mode the user prefers */
@ -21,9 +22,10 @@
--bg-color: var(--nord0);
--text-color: var(--nord4);
--article-color: var(--nord2);
--highlight-color: var(--nord8);
--highlight-color-rgb: 133, 64, 201;
--highlight-color-rgb: var(--nord8-rgb);
}
}
@ -35,6 +37,7 @@
--bg-color: var(--nord4);
--text-color: var(--nord0);
--article-color: var(--nord6);
--highlight-color: var(--nord8);
--highlight_color-rgb: 181, 122, 240;

View file

@ -6,8 +6,11 @@
.flex-container {
display: flex;
flex-wrap: wrap;
align-items: stretch;
flex-wrap: stretch;
align-items: center;
align-content: space-between;
height: 100vh;
flex-direction: column;
}
@ -205,4 +208,44 @@
.box-stealth {
border: 0;
box-shadow: none;
}
}
/* -------- Fancy anchors -------- */
.fancy {
background-image: linear-gradient(
to right,
var(--highlight-color),
var(--highlight-color) 50%,
var(--text-color) 50%
);
text-decoration: underline var(--highlight-color);
background-size: 200% 100%;
background-position: -100%;
display: inline-block;
padding: 0px 0;
position: relative;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
transition: all 0.3s ease-in-out;
}
.fancy:before {
content: '';
background: var(--highlight-color);
display: block;
position: absolute;
bottom: 0px;
left: 0;
width: 0;
height: 3px;
transition: all 0.3s ease-in-out;
}
.fancy:hover {
background-position: 0;
}
.fancy:hover::before {
width: 100%;
}

View file

@ -33,7 +33,6 @@ b,
strong,
.bold {
font-weight: bold;
}
i,
@ -69,6 +68,15 @@ a {
text-decoration: dotted underline;
color: var(--highlight-color);
}
a {
font-weight: bold;
text-decoration: underline var(--highlight-color);
}
a:visited {
color: --text-color;
text-decoration: underline var(--highlight-color);
}
pre {
white-space: pre-wrap;
@ -82,6 +90,20 @@ code {
word-break: break-all;
}
article {
background-color: var(--article-color);
width: 90vw;
}
footer {
position: fixed;
bottom: 0;
}
nav, footer {
width: 100vw;
}
/* ---------------- Highlighting ---------------- */
@ -106,4 +128,4 @@ code {
.highlight-bg-15 {
background-color: rgba(var(--highlight-color-rgb), 0.15);
}
}

View file

@ -2,11 +2,11 @@
<html lang="en">
{% include "head.html" %}
<body>
<main>
<main class="flex-container">
{% include "nav.html" %}
{% block content %}
{% endblock %}
</main>
{% include "footer.html" %}
</main>
</body>
</html>

View file

@ -1,8 +1,10 @@
{% extends "base.html" %}
{% block content %}
<article class="box box-pop">
{% for (slug, post) in posts %}
{% if loop.first %}<div class="new_callout">NEW!</div>{% endif %}
<a href="/blog/{{ slug }}"><h2>{{ post.title }}</h2></a>
<a class="fancy" href="/blog/{{ slug }}"><h2>{{ post.title }}</h2></a>
<p>{{ post.description }}</p>
{% endfor %}
</article>
{% endblock %}

View file

@ -1,8 +1,8 @@
{% extends "base.html" %}
{% block content %}
<h1>{{ post.meta.title }}</h1>
<article class="box box-pop">
<img src="{{ post.cover_img_path }}"></img>
<article>
<h1>{{ post.meta.title }}</h1>
{{ post.body }}
</article>
{% endblock %}

View file

@ -1,3 +1,3 @@
<nav>
<a href="/">Home</a>
<a class="fancy" href="/">Home</a>
</nav>