Compare commits

..

75 Commits

Author SHA1 Message Date
nvrl 0bd27dd7ef modified blog posts
CI / frontend (pull_request) Successful in 36s
CI / backend (pull_request) Failing after 20s
2026-05-18 14:33:58 +02:00
nvrl 2cfd3ff779 added public api url
CI / frontend (pull_request) Successful in 55s
CI / backend (pull_request) Failing after 34s
2026-05-18 13:54:29 +02:00
nvrl 86f855493b added site modes 2026-05-18 13:51:33 +02:00
nvrl c3aa52ddfd updated markdown style 2026-05-18 12:34:12 +02:00
nvrl 5985f172a1 fixed editor buttons 2026-05-18 12:29:25 +02:00
nvrl a1e3c2329e disabled paralex 2026-05-18 12:22:23 +02:00
nvrl b38b86e5ab fixed justify and improved sigils 2026-05-18 12:14:28 +02:00
nvrl 2651b29d02 restored 4 corner sigils 2026-05-17 17:10:14 +02:00
nvrl b64cd2e85a updated sigil rendering 2026-05-17 16:11:36 +02:00
nvrl 04733eb00a edge sigil 2026-05-17 15:38:04 +02:00
nvrl dc8e3d55b1 fixed off center hover sigil 2026-05-17 15:34:15 +02:00
nvrl 3530055f59 changed parameter 2026-05-17 15:27:44 +02:00
nvrl 5d10f4c202 spiky cybersigils 2026-05-17 15:20:38 +02:00
nvrl 93fdb8d1fc split global.css 2026-05-17 14:44:45 +02:00
nvrl ac99cc724a split into posts 2026-05-16 23:52:20 +02:00
nvrl f1d5c4a4fd added testing 2026-05-16 23:48:57 +02:00
nvrl 23c62fb1e6 fixed blinking 2026-05-16 20:01:48 +02:00
nvrl ed0edc4c99 added redraw to other sigils 2026-05-16 18:45:49 +02:00
nvrl 9c82e7226c removed last leafs 2026-05-16 18:43:55 +02:00
nvrl 0039809199 removed transparency on images 2026-05-16 18:41:15 +02:00
nvrl 632f2977b1 no spin sigil, redraw continiously 2026-05-16 18:35:24 +02:00
nvrl a9ccd5d92b fixed buttons on mobile 2026-05-16 18:33:42 +02:00
nvrl a9a16b0887 added big sigil background 2026-05-16 18:30:42 +02:00
nvrl b9aa93912c added more complex cybersigilism generator 2026-05-16 18:16:49 +02:00
nvrl 2dc224abc4 added random cybersigilism generation 2026-05-16 17:48:52 +02:00
nvrl c576794951 removed cursor 2026-05-16 17:39:57 +02:00
nvrl 9a3d3c89f3 fixed assets manager spacing 2026-05-16 17:37:29 +02:00
nvrl a731a5f50f fixed cursor + search 2026-05-16 17:31:39 +02:00
nvrl 458ef7612d updated cybersigilism theme 2026-05-16 17:16:40 +02:00
nvrl 0ade5a7e37 added cybersigilism 2026-05-16 05:24:15 +02:00
nvrl 0bd63433c2 stylized breakcore/ 2026-05-15 19:38:13 +02:00
nvrl c3dba0f684 stylized back buttons 2026-05-15 19:34:07 +02:00
nvrl e8c6ce5a8a fixed cut names + hover tooltip 2026-05-15 19:25:58 +02:00
nvrl 86e2c9dbfa disable theme switching + fixed some visual bugs 2026-05-15 19:15:40 +02:00
nvrl dcec203378 bugs and fixes 2026-05-15 16:12:18 +02:00
nvrl ab6f6088f2 redesign 2026-05-15 15:57:00 +02:00
nvrl 7294dd47ef updated breakcore theme 2026-05-15 15:44:08 +02:00
nvrl 85b699739b plate badge fix 2026-05-15 14:53:18 +02:00
nvrl adad516a1e some bugs 2026-05-15 14:48:42 +02:00
nvrl 288bf890dc redesigned buttons 2026-05-15 14:40:08 +02:00
nvrl 59108835dd fixed top bar height issues and other styling 2026-05-15 14:32:22 +02:00
nvrl 2f99126c17 fixed posts width 2026-05-15 14:18:07 +02:00
nvrl 37d31fadff fixed spaced diamond 2026-05-15 14:11:23 +02:00
nvrl 4158968e1e fixed markdown render 2026-05-15 14:08:21 +02:00
nvrl 69ced29245 fixed markdown render 2026-05-15 14:00:08 +02:00
nvrl 31a38d59bc fixed missing tags after post creating 2026-05-14 22:26:04 +02:00
nvrl 70769a696d min image size in group 2026-05-14 22:21:34 +02:00
nvrl f94c70a45c image grouping 2026-05-14 22:17:12 +02:00
nvrl 9b53f15d14 added breakcore theme 2026-05-14 20:18:57 +02:00
nvrl 076375ad00 added drafts 2026-05-14 20:04:04 +02:00
nvrl 7d04b764d5 fixed compression 2026-05-14 19:54:46 +02:00
nvrl 2a6a4e6483 backend opti 2026-05-14 18:34:07 +02:00
nvrl 8f4556b968 fixed space on mobile 2026-05-14 18:33:56 +02:00
nvrl 7ec368ac41 implemented compression + renamed prev/next buttons 2026-05-14 18:22:53 +02:00
nvrl 43a9c26497 backend opti 2026-05-14 18:12:58 +02:00
nvrl 2ace527c9f added image size 2026-05-14 18:07:08 +02:00
nvrl ceb3750add client:load + lightweight markdown.ts 2026-05-14 18:00:53 +02:00
nvrl 5a0d847874 lean css 2026-05-14 17:57:49 +02:00
nvrl 046f60dcb6 performance improvements 2026-05-14 17:52:13 +02:00
nvrl 6bc51d6d14 made mail in contact notes clickable 2026-05-14 17:35:45 +02:00
nvrl 95829f04b2 fixed some build warnings + dynamic imports 2026-05-14 17:34:53 +02:00
nvrl 70aa8b4b3e moved contact, added admin login 2026-05-14 17:29:03 +02:00
nvrl 244dc076cb added admin login to frontend + obscurification for contact details 2026-05-14 17:21:34 +02:00
nvrl 0102c89d81 added contact page 2026-05-14 17:06:27 +02:00
nvrl b0f2634346 updated image adding process 2026-05-14 12:50:49 +02:00
nvrl 187970c929 updated empty page notification 2026-05-14 12:26:34 +02:00
nvrl 5c106b7e28 fixed theme issues in asset library 2026-05-14 12:22:29 +02:00
nvrl 9952fea6bf fixed dark mode input fields 2026-05-14 12:13:01 +02:00
nvrl 1c255ce908 title bar align fix 2026-05-14 12:08:42 +02:00
nvrl 12bf93c83b removed exhibition + renamed curator to artist 2026-05-14 12:06:01 +02:00
nvrl e722c9b4e7 respect aspect ration for works 2026-05-14 11:36:36 +02:00
nvrl d74f682155 removed numbers + card redesign 2026-05-14 11:30:04 +02:00
nvrl 64c455f584 removed index display 2026-05-14 11:23:44 +02:00
nvrl af70f743be removed legacy themes + added goth 2026-05-14 11:14:37 +02:00
nvrl 04b0326778 fixed main page admin button styling 2026-05-14 11:11:39 +02:00
74 changed files with 8176 additions and 1974 deletions
+7
View File
@@ -18,3 +18,10 @@ FRONTEND_ORIGIN=
# Frontend Configuration # Frontend Configuration
# URL of the backend API accessible from the frontend container. # URL of the backend API accessible from the frontend container.
PUBLIC_API_URL=http://backend:3000 PUBLIC_API_URL=http://backend:3000
# Presentation focus. Same skin either way (fonts, cybersigil/breakcore,
# paper grain, CyberFx). `atelier` = image-first gallery (justified plates,
# "plates" count). `blog` = writing-first (stacked rows, excerpt, reading
# time). Read server-side at render — no rebuild needed to switch.
# Anything other than `blog` falls back to atelier.
SITE_MODE=atelier
+51
View File
@@ -0,0 +1,51 @@
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: frontend/package-lock.json
- run: npm ci
- name: Type-check
run: npm run check
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Build
run: npm run build
backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: backend
- name: Format
run: cargo fmt --check
- name: Clippy
# Warnings are surfaced but not yet gating — ratchet to `-D warnings`
# once the existing ~10 style lints are cleared.
run: cargo clippy --all-targets
- name: Test
run: cargo test
+115
View File
@@ -2,6 +2,12 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "1.1.4" version = "1.1.4"
@@ -11,6 +17,21 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "alloc-no-stdlib"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
[[package]]
name = "alloc-stdlib"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece"
dependencies = [
"alloc-no-stdlib",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@@ -20,6 +41,18 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "async-compression"
version = "0.4.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0f9ee0f6e02ffd7ad5816e9464499fba7b3effd01123b515c41d1697c43dad1"
dependencies = [
"compression-codecs",
"compression-core",
"pin-project-lite",
"tokio",
]
[[package]] [[package]]
name = "atomic-waker" name = "atomic-waker"
version = "1.1.2" version = "1.1.2"
@@ -104,6 +137,7 @@ dependencies = [
"axum", "axum",
"chrono", "chrono",
"dotenvy", "dotenvy",
"imagesize",
"infer", "infer",
"serde", "serde",
"serde_json", "serde_json",
@@ -122,6 +156,27 @@ version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
[[package]]
name = "brotli"
version = "8.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
"brotli-decompressor",
]
[[package]]
name = "brotli-decompressor"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.20.2" version = "3.20.2"
@@ -181,12 +236,39 @@ dependencies = [
"windows-link", "windows-link",
] ]
[[package]]
name = "compression-codecs"
version = "0.4.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb7b51a7d9c967fc26773061ba86150f19c50c0d65c887cb1fbe295fd16619b7"
dependencies = [
"brotli",
"compression-core",
"flate2",
"memchr",
]
[[package]]
name = "compression-core"
version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75984efb6ed102a0d42db99afb6c1948f0380d1d91808d5529916e6c08b49d8d"
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.7" version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "crc32fast"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "deunicode" name = "deunicode"
version = "1.6.2" version = "1.6.2"
@@ -230,6 +312,16 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
[[package]]
name = "flate2"
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@@ -401,6 +493,12 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "imagesize"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09e54e57b4c48b40f7aec75635392b12b3421fa26fe8b4332e63138ed278459c"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.14.0" version = "2.14.0"
@@ -500,6 +598,16 @@ dependencies = [
"unicase", "unicase",
] ]
[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "1.1.1" version = "1.1.1"
@@ -759,6 +867,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "simd-adler32"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.12" version = "0.4.12"
@@ -892,6 +1006,7 @@ version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8"
dependencies = [ dependencies = [
"async-compression",
"bitflags", "bitflags",
"bytes", "bytes",
"futures-core", "futures-core",
+2 -1
View File
@@ -8,12 +8,13 @@ axum = { version = "0.8.8", features = ["multipart", "macros"] }
chrono = { version = "0.4.44", features = ["serde"] } chrono = { version = "0.4.44", features = ["serde"] }
dotenvy = "0.15.7" dotenvy = "0.15.7"
infer = "0.19.0" infer = "0.19.0"
imagesize = "0.14"
serde = { version = "1.0.228", features = ["derive"] } serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149" serde_json = "1.0.149"
serde_yaml = "0.9.34" serde_yaml = "0.9.34"
slug = "0.1.6" slug = "0.1.6"
subtle = "2.6.1" subtle = "2.6.1"
tokio = { version = "1.50.0", features = ["full"] } tokio = { version = "1.50.0", features = ["full"] }
tower-http = { version = "0.6.8", features = ["cors", "fs"] } tower-http = { version = "0.6.8", features = ["cors", "fs", "compression-br", "compression-gzip"] }
tracing = "0.1.44" tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
+2
View File
@@ -0,0 +1,2 @@
edition = "2024"
max_width = 100
+7 -1
View File
@@ -7,10 +7,12 @@ use tracing::error;
use crate::models::ErrorResponse; use crate::models::ErrorResponse;
#[derive(Debug)]
pub enum AppError { pub enum AppError {
Unauthorized, Unauthorized,
NotFound(String), NotFound(String),
BadRequest(String), BadRequest(String),
TooManyRequests(String),
/// (public_message, internal_details) — details are logged but not returned. /// (public_message, internal_details) — details are logged but not returned.
Internal(String, Option<String>), Internal(String, Option<String>),
} }
@@ -21,13 +23,17 @@ impl IntoResponse for AppError {
AppError::Unauthorized => (StatusCode::UNAUTHORIZED, "Unauthorized".to_string()), AppError::Unauthorized => (StatusCode::UNAUTHORIZED, "Unauthorized".to_string()),
AppError::NotFound(msg) => (StatusCode::NOT_FOUND, msg), AppError::NotFound(msg) => (StatusCode::NOT_FOUND, msg),
AppError::BadRequest(msg) => (StatusCode::BAD_REQUEST, msg), AppError::BadRequest(msg) => (StatusCode::BAD_REQUEST, msg),
AppError::TooManyRequests(msg) => (StatusCode::TOO_MANY_REQUESTS, msg),
AppError::Internal(msg, details) => { AppError::Internal(msg, details) => {
if let Some(d) = details { if let Some(d) = details {
error!("Internal error: {} — {}", msg, d); error!("Internal error: {} — {}", msg, d);
} else { } else {
error!("Internal error: {}", msg); error!("Internal error: {}", msg);
} }
(StatusCode::INTERNAL_SERVER_ERROR, "Internal error".to_string()) (
StatusCode::INTERNAL_SERVER_ERROR,
"Internal error".to_string(),
)
} }
}; };
+35 -10
View File
@@ -1,5 +1,6 @@
use axum::{Json, extract::State, http::HeaderMap, response::IntoResponse}; use axum::{Json, extract::State, http::HeaderMap, response::IntoResponse};
use std::{fs, sync::Arc}; use std::sync::Arc;
use tokio::fs;
use tracing::error; use tracing::error;
use crate::{ use crate::{
@@ -12,6 +13,7 @@ use crate::{
pub async fn get_config(State(state): State<Arc<AppState>>) -> impl IntoResponse { pub async fn get_config(State(state): State<Arc<AppState>>) -> impl IntoResponse {
let config_path = state.data_dir.join("config.json"); let config_path = state.data_dir.join("config.json");
let config = fs::read_to_string(&config_path) let config = fs::read_to_string(&config_path)
.await
.ok() .ok()
.and_then(|c| serde_json::from_str::<SiteConfig>(&c).ok()) .and_then(|c| serde_json::from_str::<SiteConfig>(&c).ok())
.unwrap_or_default(); .unwrap_or_default();
@@ -28,25 +30,48 @@ pub async fn update_config(
let config_path = state.data_dir.join("config.json"); let config_path = state.data_dir.join("config.json");
let mut config: SiteConfig = fs::read_to_string(&config_path) let mut config: SiteConfig = fs::read_to_string(&config_path)
.await
.ok() .ok()
.and_then(|c| serde_json::from_str(&c).ok()) .and_then(|c| serde_json::from_str(&c).ok())
.unwrap_or_default(); .unwrap_or_default();
if let Some(v) = patch.title { config.title = v; } if let Some(v) = patch.title {
if let Some(v) = patch.subtitle { config.subtitle = v; } config.title = v;
if let Some(v) = patch.welcome_title { config.welcome_title = v; } }
if let Some(v) = patch.welcome_subtitle { config.welcome_subtitle = v; } if let Some(v) = patch.subtitle {
if let Some(v) = patch.footer { config.footer = v; } config.subtitle = v;
if let Some(v) = patch.favicon { config.favicon = v; } }
if let Some(v) = patch.theme { config.theme = v; } if let Some(v) = patch.welcome_title {
if let Some(v) = patch.custom_css { config.custom_css = v; } config.welcome_title = v;
}
if let Some(v) = patch.welcome_subtitle {
config.welcome_subtitle = v;
}
if let Some(v) = patch.footer {
config.footer = v;
}
if let Some(v) = patch.favicon {
config.favicon = v;
}
if let Some(v) = patch.theme {
config.theme = v;
}
if let Some(v) = patch.custom_css {
config.custom_css = v;
}
if let Some(v) = patch.contact_intro {
config.contact_intro = v;
}
if let Some(v) = patch.contact_links {
config.contact_links = v;
}
let config_str = serde_json::to_string_pretty(&config).map_err(|e| { let config_str = serde_json::to_string_pretty(&config).map_err(|e| {
error!("Serialization error: {}", e); error!("Serialization error: {}", e);
AppError::Internal("Serialization error".to_string(), Some(e.to_string())) AppError::Internal("Serialization error".to_string(), Some(e.to_string()))
})?; })?;
fs::write(&config_path, config_str).map_err(|e| { fs::write(&config_path, config_str).await.map_err(|e| {
error!("Write error for config: {}", e); error!("Write error for config: {}", e);
AppError::Internal("Write error".to_string(), Some(e.to_string())) AppError::Internal("Write error".to_string(), Some(e.to_string()))
})?; })?;
+247
View File
@@ -0,0 +1,247 @@
use axum::{
Json,
extract::{Path, State},
http::HeaderMap,
response::IntoResponse,
};
use chrono::Utc;
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
sync::Arc,
};
use tokio::fs;
use tracing::{error, info, warn};
use crate::{
AppState,
auth::check_auth,
error::AppError,
models::{ContactResponse, ContactSubmission, Message},
};
const MIN_FILL_TIME_MS: i64 = 3_000;
const MAX_FORM_AGE_MS: i64 = 24 * 60 * 60 * 1000;
pub const RATE_LIMIT_WINDOW_MS: i64 = 60 * 60 * 1000;
const RATE_LIMIT_MAX: usize = 5;
const MAX_NAME: usize = 200;
const MAX_EMAIL: usize = 200;
const MAX_SUBJECT: usize = 300;
const MAX_BODY: usize = 10_000;
fn client_ip(headers: &HeaderMap) -> String {
if let Some(xff) = headers.get("x-forwarded-for").and_then(|h| h.to_str().ok()) {
if let Some(first) = xff.split(',').next() {
let s = first.trim();
if !s.is_empty() {
return s.to_string();
}
}
}
if let Some(real_ip) = headers.get("x-real-ip").and_then(|h| h.to_str().ok()) {
let s = real_ip.trim();
if !s.is_empty() {
return s.to_string();
}
}
"unknown".to_string()
}
fn hash_ip(ip: &str) -> String {
let mut h = DefaultHasher::new();
ip.hash(&mut h);
format!("{:x}", h.finish())
}
pub async fn submit_contact(
State(state): State<Arc<AppState>>,
headers: HeaderMap,
Json(sub): Json<ContactSubmission>,
) -> Result<Json<ContactResponse>, AppError> {
let now_ms = Utc::now().timestamp_millis();
let ip = client_ip(&headers);
let ip_hash = hash_ip(&ip);
{
let mut map = state.contact_rate_limit.lock().await;
let entry = map.entry(ip.clone()).or_default();
entry.retain(|t| now_ms - *t < RATE_LIMIT_WINDOW_MS);
if entry.len() >= RATE_LIMIT_MAX {
warn!("Contact rate limit hit for ip hash {}", ip_hash);
return Err(AppError::TooManyRequests(
"Too many submissions. Try again later.".into(),
));
}
entry.push(now_ms);
}
if sub
.website
.as_deref()
.map(|s| !s.trim().is_empty())
.unwrap_or(false)
{
info!("Contact honeypot triggered from ip hash {}", ip_hash);
return Ok(Json(ContactResponse { ok: true }));
}
let elapsed = now_ms - sub.started_at;
if elapsed < MIN_FILL_TIME_MS {
return Err(AppError::BadRequest(
"Submission too fast — please take a moment and try again.".into(),
));
}
if elapsed < 0 || elapsed > MAX_FORM_AGE_MS {
return Err(AppError::BadRequest(
"Form expired — refresh the page and try again.".into(),
));
}
let body = sub.message.trim().to_string();
if body.is_empty() {
return Err(AppError::BadRequest("Message cannot be empty.".into()));
}
if body.chars().count() > MAX_BODY {
return Err(AppError::BadRequest(format!(
"Message too long (max {} characters).",
MAX_BODY
)));
}
let name = sub
.name
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty());
let email = sub
.email
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty());
let subject = sub
.subject
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty());
if name.as_ref().is_some_and(|s| s.chars().count() > MAX_NAME) {
return Err(AppError::BadRequest("Name is too long.".into()));
}
if email
.as_ref()
.is_some_and(|s| s.chars().count() > MAX_EMAIL)
{
return Err(AppError::BadRequest("Email is too long.".into()));
}
if subject
.as_ref()
.is_some_and(|s| s.chars().count() > MAX_SUBJECT)
{
return Err(AppError::BadRequest("Subject is too long.".into()));
}
if let Some(ref e) = email {
if !e.contains('@') || !e.contains('.') {
return Err(AppError::BadRequest("Email looks invalid.".into()));
}
}
let received_at = now_ms;
let id = Utc::now()
.timestamp_nanos_opt()
.unwrap_or(received_at * 1_000_000)
.to_string();
let msg = Message {
id: id.clone(),
name,
email,
subject,
body,
received_at,
ip_hash: Some(ip_hash),
};
let messages_dir = state.data_dir.join("messages");
fs::create_dir_all(&messages_dir).await.map_err(|e| {
error!("Failed to create messages dir: {}", e);
AppError::Internal("Storage error".into(), Some(e.to_string()))
})?;
let path = messages_dir.join(format!("{}.json", id));
let json = serde_json::to_string_pretty(&msg)
.map_err(|e| AppError::Internal("Serialization error".into(), Some(e.to_string())))?;
fs::write(&path, json).await.map_err(|e| {
error!("Failed to write message {}: {}", id, e);
AppError::Internal("Storage error".into(), Some(e.to_string()))
})?;
info!("Stored contact message {}", id);
Ok(Json(ContactResponse { ok: true }))
}
pub async fn list_messages(
State(state): State<Arc<AppState>>,
headers: HeaderMap,
) -> impl IntoResponse {
if let Err(e) = check_auth(&headers, &state.admin_token) {
return e.into_response();
}
let messages_dir = state.data_dir.join("messages");
if !fs::try_exists(&messages_dir).await.unwrap_or(false) {
return Json(Vec::<Message>::new()).into_response();
}
let mut rd = match fs::read_dir(&messages_dir).await {
Ok(e) => e,
Err(e) => {
error!("Failed to read messages dir: {}", e);
return AppError::Internal("Read error".into(), Some(e.to_string())).into_response();
}
};
let mut messages: Vec<Message> = Vec::new();
loop {
match rd.next_entry().await {
Ok(Some(entry)) => {
let path = entry.path();
if path.extension().and_then(|e| e.to_str()) != Some("json") {
continue;
}
let content = match fs::read_to_string(&path).await {
Ok(c) => c,
Err(e) => {
error!("Failed to read {:?}: {}", path, e);
continue;
}
};
match serde_json::from_str::<Message>(&content) {
Ok(m) => messages.push(m),
Err(e) => error!("Malformed message {:?}: {}", path, e),
}
}
Ok(None) => break,
Err(e) => {
error!("Error iterating messages dir: {}", e);
break;
}
}
}
messages.sort_by(|a, b| b.received_at.cmp(&a.received_at));
Json(messages).into_response()
}
pub async fn delete_message(
State(state): State<Arc<AppState>>,
Path(id): Path<String>,
headers: HeaderMap,
) -> Result<Json<ContactResponse>, AppError> {
check_auth(&headers, &state.admin_token)?;
if id.contains('/') || id.contains('\\') || id.contains("..") || id.is_empty() {
return Err(AppError::BadRequest("Invalid id.".into()));
}
let path = state.data_dir.join("messages").join(format!("{}.json", id));
if !fs::try_exists(&path).await.unwrap_or(false) {
return Err(AppError::NotFound("Message not found.".into()));
}
fs::remove_file(&path)
.await
.map_err(|e| AppError::Internal("Delete failed".into(), Some(e.to_string())))?;
Ok(Json(ContactResponse { ok: true }))
}
+1
View File
@@ -1,4 +1,5 @@
pub mod auth; pub mod auth;
pub mod config; pub mod config;
pub mod contact;
pub mod posts; pub mod posts;
pub mod upload; pub mod upload;
+86 -251
View File
@@ -1,203 +1,43 @@
//! HTTP handlers for posts. Orchestration only — parsing, image handling,
//! and the cache live in [`crate::post`].
use axum::{ use axum::{
Json, Json,
extract::{Path, State}, extract::{Path, State},
http::{HeaderMap, StatusCode}, http::{HeaderMap, StatusCode},
}; };
use chrono::Utc; use chrono::Utc;
use std::{fs, sync::Arc}; use std::sync::Arc;
use tokio::fs;
use tracing::{error, info, warn}; use tracing::{error, info, warn};
use crate::post::cache::{neighbors_from_cache, rebuild_posts_cache};
use crate::post::images::{cover_from, dims_for_urls, extract_images};
use crate::post::parse::{reading_time, serialize_post, validate_slug};
use crate::{ use crate::{
AppState, AppState,
auth::is_authed, auth::is_authed,
error::AppError, error::AppError,
models::{CoverImage, CreatePostRequest, PostDetail, PostInfo, PostMeta}, models::{CreatePostRequest, PostDetail, PostInfo, PostMeta},
}; };
const WORDS_PER_MINUTE: u32 = 200; async fn write_post_atomic(state: &AppState, slug: &str, contents: &str) -> Result<(), AppError> {
const MAX_SLUG_LEN: usize = 100;
const WINDOWS_RESERVED: &[&str] = &[
"CON", "PRN", "AUX", "NUL",
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9",
];
fn validate_slug(s: &str) -> Result<(), AppError> {
if s.is_empty() {
return Err(AppError::BadRequest("Slug is empty".to_string()));
}
if s.len() > MAX_SLUG_LEN {
return Err(AppError::BadRequest(format!(
"Slug exceeds {} characters",
MAX_SLUG_LEN
)));
}
if s.starts_with('.') {
return Err(AppError::BadRequest(
"Slug cannot start with '.'".to_string(),
));
}
if s.ends_with('.') || s.ends_with(' ') {
return Err(AppError::BadRequest(
"Slug cannot end with '.' or space".to_string(),
));
}
if s.contains("..") {
return Err(AppError::BadRequest(
"Slug cannot contain '..'".to_string(),
));
}
for c in s.chars() {
if c.is_control() {
return Err(AppError::BadRequest(
"Slug contains control characters".to_string(),
));
}
if matches!(c, '/' | '\\' | '<' | '>' | ':' | '"' | '|' | '?' | '*') {
return Err(AppError::BadRequest(format!(
"Slug contains invalid character '{}'",
c
)));
}
}
let stem = s.split('.').next().unwrap_or("").to_ascii_uppercase();
if WINDOWS_RESERVED.iter().any(|r| *r == stem) {
return Err(AppError::BadRequest(
"Slug is a reserved name".to_string(),
));
}
Ok(())
}
fn split_frontmatter(raw: &str) -> Option<(&str, &str)> {
let raw = raw.strip_prefix("---\n").or_else(|| raw.strip_prefix("---\r\n"))?;
let end_marker = raw.find("\n---\n").or_else(|| raw.find("\r\n---\r\n"))?;
let yaml = &raw[..end_marker];
let body_start = end_marker
+ raw[end_marker..]
.find("---\n")
.or_else(|| raw[end_marker..].find("---\r\n"))?
+ "---\n".len();
let body = raw[body_start..].trim_start_matches('\n').trim_start_matches('\r');
Some((yaml, body))
}
fn parse_post(raw: &str) -> Result<(PostMeta, String), AppError> {
let (yaml, body) = split_frontmatter(raw).ok_or_else(|| {
AppError::Internal(
"Missing frontmatter".to_string(),
Some("post is missing the YAML --- block".to_string()),
)
})?;
let meta: PostMeta = serde_yaml::from_str(yaml).map_err(|e| {
AppError::Internal(
"Invalid frontmatter".to_string(),
Some(format!("YAML parse error: {}", e)),
)
})?;
Ok((meta, body.to_string()))
}
fn serialize_post(meta: &PostMeta, body: &str) -> Result<String, AppError> {
let yaml = serde_yaml::to_string(meta).map_err(|e| {
AppError::Internal(
"Serialization error".to_string(),
Some(e.to_string()),
)
})?;
Ok(format!("---\n{}---\n{}", yaml, body))
}
fn reading_time(body: &str) -> u32 {
let words = body.split_whitespace().count() as u32;
(words + WORDS_PER_MINUTE - 1) / WORDS_PER_MINUTE.max(1)
}
/// Scan markdown for `![alt](url)` images. Returns (alt, url) pairs in order.
/// Skips inside fenced code blocks. Tolerates titles like `![alt](url "title")`.
fn extract_images(body: &str) -> Vec<(String, String)> {
let mut out = Vec::new();
let mut in_fence = false;
for line in body.lines() {
let trimmed = line.trim_start();
if trimmed.starts_with("```") || trimmed.starts_with("~~~") {
in_fence = !in_fence;
continue;
}
if in_fence {
continue;
}
let bytes = line.as_bytes();
let mut i = 0;
while i + 1 < bytes.len() {
if bytes[i] == b'!' && bytes[i + 1] == b'[' {
if let Some(rel_close) = line[i + 2..].find(']') {
let close = i + 2 + rel_close;
if close + 1 < line.len() && bytes[close + 1] == b'(' {
if let Some(rel_paren) = line[close + 2..].find(')') {
let paren_end = close + 2 + rel_paren;
let alt = line[i + 2..close].to_string();
let url_field = line[close + 2..paren_end].trim();
let url = url_field
.split_once(|c: char| c.is_whitespace())
.map(|(u, _)| u)
.unwrap_or(url_field)
.trim_matches(|c| c == '<' || c == '>')
.to_string();
if !url.is_empty() {
out.push((alt, url));
}
i = paren_end + 1;
continue;
}
}
}
}
i += 1;
}
}
out
}
fn cover_from(images: &[(String, String)]) -> Option<CoverImage> {
images.first().map(|(alt, url)| CoverImage {
url: url.clone(),
alt: alt.clone(),
})
}
fn excerpt_from(meta: &PostMeta, body: &str) -> String {
if let Some(s) = meta.summary.as_ref() {
if !s.trim().is_empty() {
return s.trim().to_string();
}
}
let plain = body
.replace(['#', '*', '_', '`'], "")
.replace('\n', " ");
let mut out: String = plain.chars().take(200).collect();
if plain.chars().count() > 200 {
out.push_str("...");
}
out.trim().to_string()
}
async fn write_post_atomic(
state: &AppState,
slug: &str,
contents: &str,
) -> Result<(), AppError> {
let _guard = state.post_lock.lock().await; let _guard = state.post_lock.lock().await;
let final_path = state.data_dir.join("posts").join(format!("{}.md", slug)); let final_path = state.data_dir.join("posts").join(format!("{}.md", slug));
let tmp_path = state.data_dir.join("posts").join(format!(".{}.md.tmp", slug)); let tmp_path = state
fs::write(&tmp_path, contents).map_err(|e| { .data_dir
AppError::Internal("Write error".to_string(), Some(e.to_string())) .join("posts")
})?; .join(format!(".{}.md.tmp", slug));
fs::rename(&tmp_path, &final_path).map_err(|e| { fs::write(&tmp_path, contents)
let _ = fs::remove_file(&tmp_path); .await
AppError::Internal("Rename error".to_string(), Some(e.to_string())) .map_err(|e| AppError::Internal("Write error".to_string(), Some(e.to_string())))?;
})?; if let Err(e) = fs::rename(&tmp_path, &final_path).await {
let _ = fs::remove_file(&tmp_path).await;
return Err(AppError::Internal(
"Rename error".to_string(),
Some(e.to_string()),
));
}
Ok(()) Ok(())
} }
@@ -227,14 +67,14 @@ pub async fn create_post(
if let Some(ref old_slug) = payload.old_slug { if let Some(ref old_slug) = payload.old_slug {
if old_slug != &slug { if old_slug != &slug {
let old_path = posts_dir.join(format!("{}.md", old_slug)); let old_path = posts_dir.join(format!("{}.md", old_slug));
if old_path.exists() { if fs::try_exists(&old_path).await.unwrap_or(false) {
if file_path.exists() { if fs::try_exists(&file_path).await.unwrap_or(false) {
return Err(AppError::BadRequest( return Err(AppError::BadRequest(
"A post with this new title already exists".to_string(), "A post with this new title already exists".to_string(),
)); ));
} }
let _guard = state.post_lock.lock().await; let _guard = state.post_lock.lock().await;
fs::rename(&old_path, &file_path).map_err(|e| { fs::rename(&old_path, &file_path).await.map_err(|e| {
error!("Rename error from {} to {}: {}", old_slug, slug, e); error!("Rename error from {} to {}: {}", old_slug, slug, e);
AppError::Internal("Rename error".to_string(), Some(e.to_string())) AppError::Internal("Rename error".to_string(), Some(e.to_string()))
})?; })?;
@@ -247,13 +87,17 @@ pub async fn create_post(
let images = extract_images(&payload.content); let images = extract_images(&payload.content);
if images.is_empty() { if images.is_empty() {
return Err(AppError::BadRequest( return Err(AppError::BadRequest(
"A gallery entry must include at least one image (![](url) in the markdown body).".to_string(), "A gallery entry must include at least one image (![](url) in the markdown body)."
.to_string(),
)); ));
} }
let meta = PostMeta { let meta = PostMeta {
date: payload.date.unwrap_or_else(|| Utc::now().date_naive()), date: payload.date.unwrap_or_else(|| Utc::now().date_naive()),
title: payload.title.map(|t| t.trim().to_string()).filter(|t| !t.is_empty()), title: payload
.title
.map(|t| t.trim().to_string())
.filter(|t| !t.is_empty()),
summary: payload.summary.filter(|s| !s.trim().is_empty()), summary: payload.summary.filter(|s| !s.trim().is_empty()),
tags: payload.tags, tags: payload.tags,
draft: payload.draft, draft: payload.draft,
@@ -263,7 +107,20 @@ pub async fn create_post(
info!("Post saved: {}", slug); info!("Post saved: {}", slug);
let image_count = images.len() as u32; let image_count = images.len() as u32;
let cover = cover_from(&images); let mut cover = cover_from(&images);
rebuild_posts_cache(&state).await;
let (prev, next) = neighbors_from_cache(&state, &slug, true).await;
let image_urls: Vec<String> = images.iter().map(|(_, u)| u.clone()).collect();
let dimensions = dims_for_urls(&state, &image_urls).await;
if let Some(c) = cover.as_mut() {
if let Some(d) = dimensions.get(&c.url) {
c.w = Some(d.w);
c.h = Some(d.h);
}
}
Ok(Json(PostDetail { Ok(Json(PostDetail {
slug, slug,
date: meta.date, date: meta.date,
@@ -275,6 +132,9 @@ pub async fn create_post(
content: payload.content, content: payload.content,
cover_image: cover, cover_image: cover,
image_count, image_count,
prev,
next,
dimensions,
})) }))
} }
@@ -291,17 +151,19 @@ pub async fn delete_post(
let _guard = state.post_lock.lock().await; let _guard = state.post_lock.lock().await;
let file_path = state.data_dir.join("posts").join(format!("{}.md", slug)); let file_path = state.data_dir.join("posts").join(format!("{}.md", slug));
if !file_path.exists() { if !fs::try_exists(&file_path).await.unwrap_or(false) {
warn!("Post not found for deletion: {}", slug); warn!("Post not found for deletion: {}", slug);
return Err(AppError::NotFound("Post not found".to_string())); return Err(AppError::NotFound("Post not found".to_string()));
} }
fs::remove_file(file_path).map_err(|e| { fs::remove_file(file_path).await.map_err(|e| {
error!("Delete error for post {}: {}", slug, e); error!("Delete error for post {}: {}", slug, e);
AppError::Internal("Delete error".to_string(), Some(e.to_string())) AppError::Internal("Delete error".to_string(), Some(e.to_string()))
})?; })?;
drop(_guard);
info!("Post deleted: {}", slug); info!("Post deleted: {}", slug);
rebuild_posts_cache(&state).await;
Ok(StatusCode::NO_CONTENT) Ok(StatusCode::NO_CONTENT)
} }
@@ -310,48 +172,12 @@ pub async fn list_posts(
headers: HeaderMap, headers: HeaderMap,
) -> Json<Vec<PostInfo>> { ) -> Json<Vec<PostInfo>> {
let admin = is_authed(&headers, &state.admin_token); let admin = is_authed(&headers, &state.admin_token);
let posts_dir = state.data_dir.join("posts"); let cache = state.posts_cache.read().await;
let mut posts: Vec<PostInfo> = Vec::new(); let posts: Vec<PostInfo> = cache
.iter()
if let Ok(entries) = fs::read_dir(posts_dir) { .filter(|p| admin || !p.info.draft)
for entry in entries.flatten() { .map(|p| p.info.clone())
let path = entry.path(); .collect();
if path.extension().and_then(|e| e.to_str()) != Some("md") {
continue;
}
let Some(slug) = path.file_stem().and_then(|s| s.to_str()) else {
continue;
};
if slug.starts_with('.') {
continue;
}
let Ok(raw) = fs::read_to_string(&path) else {
continue;
};
let Ok((meta, body)) = parse_post(&raw) else {
warn!("Skipping post with bad frontmatter: {}", slug);
continue;
};
if meta.draft && !admin {
continue;
}
let images = extract_images(&body);
posts.push(PostInfo {
slug: slug.to_string(),
date: meta.date,
title: meta.title.clone(),
summary: meta.summary.clone(),
tags: meta.tags.clone(),
draft: meta.draft,
reading_time: reading_time(&body),
excerpt: excerpt_from(&meta, &body),
cover_image: cover_from(&images),
image_count: images.len() as u32,
});
}
}
posts.sort_by(|a, b| b.date.cmp(&a.date).then_with(|| a.slug.cmp(&b.slug)));
Json(posts) Json(posts)
} }
@@ -362,27 +188,36 @@ pub async fn get_post(
) -> Result<Json<PostDetail>, AppError> { ) -> Result<Json<PostDetail>, AppError> {
validate_slug(&slug)?; validate_slug(&slug)?;
let admin = is_authed(&headers, &state.admin_token); let admin = is_authed(&headers, &state.admin_token);
let file_path = state.data_dir.join("posts").join(format!("{}.md", slug));
let raw = fs::read_to_string(&file_path) let (info, body) = {
.map_err(|_| AppError::NotFound("Post not found".to_string()))?; let cache = state.posts_cache.read().await;
let (meta, body) = parse_post(&raw)?; let Some(p) = cache.iter().find(|p| p.info.slug == slug) else {
return Err(AppError::NotFound("Post not found".to_string()));
};
if p.info.draft && !admin {
return Err(AppError::NotFound("Post not found".to_string()));
}
(p.info.clone(), p.body.clone())
};
if meta.draft && !admin { let (prev, next) = neighbors_from_cache(&state, &slug, admin).await;
return Err(AppError::NotFound("Post not found".to_string()));
} let image_urls: Vec<String> = extract_images(&body).into_iter().map(|(_, u)| u).collect();
let dimensions = dims_for_urls(&state, &image_urls).await;
let images = extract_images(&body);
Ok(Json(PostDetail { Ok(Json(PostDetail {
slug, slug: info.slug,
date: meta.date, date: info.date,
title: meta.title, title: info.title,
summary: meta.summary, summary: info.summary,
tags: meta.tags, tags: info.tags,
draft: meta.draft, draft: info.draft,
reading_time: reading_time(&body), reading_time: info.reading_time,
content: body, content: body,
cover_image: cover_from(&images), cover_image: info.cover_image,
image_count: images.len() as u32, image_count: info.image_count,
prev,
next,
dimensions,
})) }))
} }
+51 -28
View File
@@ -4,7 +4,8 @@ use axum::{
http::{HeaderMap, StatusCode}, http::{HeaderMap, StatusCode},
}; };
use serde::Deserialize; use serde::Deserialize;
use std::{fs, sync::Arc}; use std::sync::Arc;
use tokio::fs;
use tracing::{error, info, warn}; use tracing::{error, info, warn};
use crate::{ use crate::{
@@ -22,10 +23,8 @@ pub struct UploadQuery {
/// Allowed upload extensions. SVG, HTML, JS, executables intentionally absent — /// Allowed upload extensions. SVG, HTML, JS, executables intentionally absent —
/// /uploads/* is served as-is, so any active content there is XSS waiting to happen. /// /uploads/* is served as-is, so any active content there is XSS waiting to happen.
const ALLOWED_EXTS: &[&str] = &[ const ALLOWED_EXTS: &[&str] = &[
"jpg", "jpeg", "png", "webp", "gif", "avif", "jpg", "jpeg", "png", "webp", "gif", "avif", "pdf", "txt", "md", "mp3", "wav", "ogg", "mp4",
"pdf", "txt", "md", "webm", "mov",
"mp3", "wav", "ogg",
"mp4", "webm", "mov",
]; ];
fn validate_filename(name: &str) -> Result<(), AppError> { fn validate_filename(name: &str) -> Result<(), AppError> {
@@ -76,18 +75,23 @@ pub async fn delete_upload(
let uploads_dir = state.data_dir.join("uploads"); let uploads_dir = state.data_dir.join("uploads");
let file_path = uploads_dir.join(&filename); let file_path = uploads_dir.join(&filename);
let canonical_dir = uploads_dir.canonicalize().map_err(|e| { let canonical_dir = fs::canonicalize(&uploads_dir)
AppError::Internal("Path resolution".to_string(), Some(e.to_string())) .await
})?; .map_err(|e| AppError::Internal("Path resolution".to_string(), Some(e.to_string())))?;
if let Ok(canonical_file) = file_path.canonicalize() { if let Ok(canonical_file) = fs::canonicalize(&file_path).await {
if !canonical_file.starts_with(&canonical_dir) { if !canonical_file.starts_with(&canonical_dir) {
warn!("Refused delete outside uploads dir: {}", filename); warn!("Refused delete outside uploads dir: {}", filename);
return Err(AppError::BadRequest("Invalid filename".to_string())); return Err(AppError::BadRequest("Invalid filename".to_string()));
} }
fs::remove_file(canonical_file).map_err(|e| { fs::remove_file(canonical_file).await.map_err(|e| {
error!("Delete error for file {}: {}", filename, e); error!("Delete error for file {}: {}", filename, e);
AppError::Internal("Delete error".to_string(), Some(e.to_string())) AppError::Internal("Delete error".to_string(), Some(e.to_string()))
})?; })?;
state
.image_dims_cache
.write()
.await
.remove(&format!("/uploads/{}", filename));
info!("Deleted file: {}", filename); info!("Deleted file: {}", filename);
Ok(StatusCode::NO_CONTENT) Ok(StatusCode::NO_CONTENT)
} else { } else {
@@ -104,15 +108,30 @@ pub async fn list_uploads(
let uploads_dir = state.data_dir.join("uploads"); let uploads_dir = state.data_dir.join("uploads");
let mut files = Vec::new(); let mut files = Vec::new();
if let Ok(entries) = fs::read_dir(uploads_dir) { if let Ok(mut rd) = fs::read_dir(&uploads_dir).await {
for entry in entries.flatten() { loop {
let path = entry.path(); match rd.next_entry().await {
if path.is_file() { Ok(Some(entry)) => {
if let Some(name) = path.file_name().and_then(|n| n.to_str()) { let path = entry.path();
files.push(FileInfo { let is_file = entry
name: name.to_string(), .file_type()
url: format!("/uploads/{}", name), .await
}); .map(|t| t.is_file())
.unwrap_or(false);
if !is_file {
continue;
}
if let Some(name) = path.file_name().and_then(|n| n.to_str()) {
files.push(FileInfo {
name: name.to_string(),
url: format!("/uploads/{}", name),
});
}
}
Ok(None) => break,
Err(e) => {
warn!("Error iterating uploads dir: {}", e);
break;
} }
} }
} }
@@ -178,7 +197,9 @@ pub async fn upload_file(
let uploads_dir = state.data_dir.join("uploads"); let uploads_dir = state.data_dir.join("uploads");
let target_path = uploads_dir.join(&final_name); let target_path = uploads_dir.join(&final_name);
let final_path = if target_path.exists() && !query.replace.unwrap_or(false) { let final_path = if fs::try_exists(&target_path).await.unwrap_or(false)
&& !query.replace.unwrap_or(false)
{
let timestamp = chrono::Utc::now().timestamp(); let timestamp = chrono::Utc::now().timestamp();
uploads_dir.join(format!("{}_{}", timestamp, final_name)) uploads_dir.join(format!("{}_{}", timestamp, final_name))
} else { } else {
@@ -186,11 +207,11 @@ pub async fn upload_file(
}; };
// Final containment check. // Final containment check.
let canonical_dir = uploads_dir.canonicalize().map_err(|e| { let canonical_dir = fs::canonicalize(&uploads_dir)
AppError::Internal("Path resolution".to_string(), Some(e.to_string())) .await
})?; .map_err(|e| AppError::Internal("Path resolution".to_string(), Some(e.to_string())))?;
if let Some(parent) = final_path.parent() { if let Some(parent) = final_path.parent() {
let canonical_parent = parent.canonicalize().map_err(|e| { let canonical_parent = fs::canonicalize(parent).await.map_err(|e| {
AppError::Internal("Path resolution".to_string(), Some(e.to_string())) AppError::Internal("Path resolution".to_string(), Some(e.to_string()))
})?; })?;
if canonical_parent != canonical_dir { if canonical_parent != canonical_dir {
@@ -204,15 +225,17 @@ pub async fn upload_file(
.unwrap_or(&final_name) .unwrap_or(&final_name)
.to_string(); .to_string();
fs::write(&final_path, &data).map_err(|e| { fs::write(&final_path, &data).await.map_err(|e| {
error!("Failed to write file to {:?}: {}", final_path, e); error!("Failed to write file to {:?}: {}", final_path, e);
AppError::Internal("Write error".to_string(), Some(e.to_string())) AppError::Internal("Write error".to_string(), Some(e.to_string()))
})?; })?;
let url = format!("/uploads/{}", final_name_str);
// Invalidate any stale dim cache entry (matters when replacing an existing file).
state.image_dims_cache.write().await.remove(&url);
info!("File uploaded successfully to {:?}", final_path); info!("File uploaded successfully to {:?}", final_path);
return Ok(Json(UploadResponse { return Ok(Json(UploadResponse { url }));
url: format!("/uploads/{}", final_name_str),
}));
} }
warn!("Upload failed: no file found in multipart stream"); warn!("Upload failed: no file found in multipart stream");
+65 -11
View File
@@ -2,6 +2,7 @@ pub mod auth;
pub mod error; pub mod error;
pub mod handlers; pub mod handlers;
pub mod models; pub mod models;
pub mod post;
use axum::{ use axum::{
Router, Router,
@@ -9,19 +10,31 @@ use axum::{
http::{HeaderValue, header}, http::{HeaderValue, header},
routing::{delete, get, post}, routing::{delete, get, post},
}; };
use std::{env, fs, path::PathBuf, sync::Arc}; use std::{collections::HashMap, env, path::PathBuf, sync::Arc, time::Duration};
use tokio::sync::Mutex; use tokio::sync::{Mutex, RwLock};
use tower_http::{ use tower_http::{
compression::CompressionLayer,
cors::{AllowOrigin, CorsLayer}, cors::{AllowOrigin, CorsLayer},
services::ServeDir, services::ServeDir,
}; };
use tracing::{error, info, warn}; use tracing::{error, info, warn};
use crate::handlers::contact::RATE_LIMIT_WINDOW_MS;
use crate::models::{ImageDim, PostInfo};
pub struct CachedPost {
pub info: PostInfo,
pub body: String,
}
pub struct AppState { pub struct AppState {
pub admin_token: String, pub admin_token: String,
pub data_dir: PathBuf, pub data_dir: PathBuf,
pub cookie_secure: bool, pub cookie_secure: bool,
pub post_lock: Mutex<()>, pub post_lock: Mutex<()>,
pub posts_cache: RwLock<Vec<CachedPost>>,
pub image_dims_cache: RwLock<HashMap<String, ImageDim>>,
pub contact_rate_limit: Mutex<HashMap<String, Vec<i64>>>,
} }
#[tokio::main] #[tokio::main]
@@ -35,9 +48,7 @@ async fn main() {
.filter(|t| !t.trim().is_empty()) .filter(|t| !t.trim().is_empty())
.expect("ADMIN_TOKEN must be set to a non-empty value"); .expect("ADMIN_TOKEN must be set to a non-empty value");
if admin_token.len() < 16 { if admin_token.len() < 16 {
warn!( warn!("ADMIN_TOKEN is shorter than 16 characters. Use a long random string in production.");
"ADMIN_TOKEN is shorter than 16 characters. Use a long random string in production."
);
} }
let data_dir_str = env::var("DATA_DIR").unwrap_or_else(|_| "../data".to_string()); let data_dir_str = env::var("DATA_DIR").unwrap_or_else(|_| "../data".to_string());
let data_dir = PathBuf::from(data_dir_str); let data_dir = PathBuf::from(data_dir_str);
@@ -49,10 +60,10 @@ async fn main() {
let posts_dir = data_dir.join("posts"); let posts_dir = data_dir.join("posts");
let uploads_dir = data_dir.join("uploads"); let uploads_dir = data_dir.join("uploads");
if let Err(e) = fs::create_dir_all(&posts_dir) { if let Err(e) = tokio::fs::create_dir_all(&posts_dir).await {
error!("Failed to create posts directory: {}", e); error!("Failed to create posts directory: {}", e);
} }
if let Err(e) = fs::create_dir_all(&uploads_dir) { if let Err(e) = tokio::fs::create_dir_all(&uploads_dir).await {
error!("Failed to create uploads directory: {}", e); error!("Failed to create uploads directory: {}", e);
} }
@@ -61,16 +72,27 @@ async fn main() {
data_dir, data_dir,
cookie_secure, cookie_secure,
post_lock: Mutex::new(()), post_lock: Mutex::new(()),
posts_cache: RwLock::new(Vec::new()),
image_dims_cache: RwLock::new(HashMap::new()),
contact_rate_limit: Mutex::new(HashMap::new()),
}); });
post::cache::rebuild_posts_cache(&state).await;
info!(
"Posts cache primed with {} entries",
state.posts_cache.read().await.len()
);
spawn_rate_limit_reaper(state.clone());
// CORS — locked down by default. Set FRONTEND_ORIGIN to the public URL of // CORS — locked down by default. Set FRONTEND_ORIGIN to the public URL of
// the frontend if you ever expose the backend directly to browsers. // the frontend if you ever expose the backend directly to browsers.
// Normal deployments hit the backend through the Astro proxy, which is // Normal deployments hit the backend through the Astro proxy, which is
// server-to-server and not subject to CORS. // server-to-server and not subject to CORS.
let cors = match env::var("FRONTEND_ORIGIN").ok().filter(|s| !s.is_empty()) { let cors = match env::var("FRONTEND_ORIGIN").ok().filter(|s| !s.is_empty()) {
Some(origin) => { Some(origin) => {
let value = HeaderValue::from_str(&origin) let value =
.expect("FRONTEND_ORIGIN must be a valid origin URL"); HeaderValue::from_str(&origin).expect("FRONTEND_ORIGIN must be a valid origin URL");
CorsLayer::new() CorsLayer::new()
.allow_origin(AllowOrigin::exact(value)) .allow_origin(AllowOrigin::exact(value))
.allow_methods([ .allow_methods([
@@ -85,6 +107,10 @@ async fn main() {
None => CorsLayer::new(), None => CorsLayer::new(),
}; };
// JSON routes get a tight 1 MB cap; the upload route keeps 50 MB.
const JSON_BODY_LIMIT: usize = 1024 * 1024;
const UPLOAD_BODY_LIMIT: usize = 50 * 1024 * 1024;
let app = Router::new() let app = Router::new()
.route("/api/auth/login", post(handlers::auth::login)) .route("/api/auth/login", post(handlers::auth::login))
.route("/api/auth/logout", post(handlers::auth::logout)) .route("/api/auth/logout", post(handlers::auth::logout))
@@ -106,10 +132,20 @@ async fn main() {
"/api/uploads/{filename}", "/api/uploads/{filename}",
delete(handlers::upload::delete_upload), delete(handlers::upload::delete_upload),
) )
.route("/api/upload", post(handlers::upload::upload_file)) .route(
"/api/upload",
post(handlers::upload::upload_file).layer(DefaultBodyLimit::max(UPLOAD_BODY_LIMIT)),
)
.route("/api/contact", post(handlers::contact::submit_contact))
.route("/api/messages", get(handlers::contact::list_messages))
.route(
"/api/messages/{id}",
delete(handlers::contact::delete_message),
)
.route("/healthz", get(|| async { "ok" })) .route("/healthz", get(|| async { "ok" }))
.nest_service("/uploads", ServeDir::new(uploads_dir)) .nest_service("/uploads", ServeDir::new(uploads_dir))
.layer(DefaultBodyLimit::max(50 * 1024 * 1024)) .layer(DefaultBodyLimit::max(JSON_BODY_LIMIT))
.layer(CompressionLayer::new().br(true).gzip(true))
.layer(cors) .layer(cors)
.with_state(state); .with_state(state);
@@ -118,3 +154,21 @@ async fn main() {
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app).await.unwrap(); axum::serve(listener, app).await.unwrap();
} }
/// Periodically prunes expired entries from the contact rate-limit map so it
/// can't grow unbounded across the lifetime of the process.
fn spawn_rate_limit_reaper(state: Arc<AppState>) {
tokio::spawn(async move {
let mut ticker = tokio::time::interval(Duration::from_secs(300));
ticker.tick().await;
loop {
ticker.tick().await;
let now_ms = chrono::Utc::now().timestamp_millis();
let mut map = state.contact_rate_limit.lock().await;
map.retain(|_, times| {
times.retain(|t| now_ms - *t < RATE_LIMIT_WINDOW_MS);
!times.is_empty()
});
}
});
}
+78 -4
View File
@@ -1,5 +1,13 @@
use chrono::NaiveDate; use chrono::NaiveDate;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Clone)]
pub struct ContactLink {
pub kind: String,
pub label: String,
pub value: String,
}
#[derive(Serialize, Deserialize, Clone)] #[derive(Serialize, Deserialize, Clone)]
pub struct SiteConfig { pub struct SiteConfig {
@@ -11,6 +19,10 @@ pub struct SiteConfig {
pub favicon: String, pub favicon: String,
pub theme: String, pub theme: String,
pub custom_css: String, pub custom_css: String,
#[serde(default)]
pub contact_intro: String,
#[serde(default)]
pub contact_links: Vec<ContactLink>,
} }
impl Default for SiteConfig { impl Default for SiteConfig {
@@ -19,13 +31,14 @@ impl Default for SiteConfig {
title: "Ela's Atelier".to_string(), title: "Ela's Atelier".to_string(),
subtitle: "Works on paper, canvas, and elsewhere".to_string(), subtitle: "Works on paper, canvas, and elsewhere".to_string(),
welcome_title: "Works on view".to_string(), welcome_title: "Works on view".to_string(),
welcome_subtitle: welcome_subtitle: "An ongoing arrangement of pieces, sketches, and stray observations."
"An ongoing arrangement of pieces, sketches, and stray observations." .to_string(),
.to_string(),
footer: "Hand-arranged with care".to_string(), footer: "Hand-arranged with care".to_string(),
favicon: "/favicon.svg".to_string(), favicon: "/favicon.svg".to_string(),
theme: "salon".to_string(), theme: "salon".to_string(),
custom_css: "".to_string(), custom_css: "".to_string(),
contact_intro: "".to_string(),
contact_links: Vec::new(),
} }
} }
} }
@@ -48,6 +61,10 @@ pub struct SiteConfigPatch {
pub theme: Option<String>, pub theme: Option<String>,
#[serde(default)] #[serde(default)]
pub custom_css: Option<String>, pub custom_css: Option<String>,
#[serde(default)]
pub contact_intro: Option<String>,
#[serde(default)]
pub contact_links: Option<Vec<ContactLink>>,
} }
#[derive(Serialize, Deserialize, Clone, Default)] #[derive(Serialize, Deserialize, Clone, Default)]
@@ -63,13 +80,23 @@ pub struct PostMeta {
pub draft: bool, pub draft: bool,
} }
#[derive(Serialize, Clone, Copy)]
pub struct ImageDim {
pub w: u32,
pub h: u32,
}
#[derive(Serialize, Clone)] #[derive(Serialize, Clone)]
pub struct CoverImage { pub struct CoverImage {
pub url: String, pub url: String,
pub alt: String, pub alt: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub w: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub h: Option<u32>,
} }
#[derive(Serialize)] #[derive(Serialize, Clone)]
pub struct PostInfo { pub struct PostInfo {
pub slug: String, pub slug: String,
pub date: NaiveDate, pub date: NaiveDate,
@@ -86,6 +113,13 @@ pub struct PostInfo {
pub image_count: u32, pub image_count: u32,
} }
#[derive(Serialize, Clone)]
pub struct PostNeighbor {
pub slug: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
#[derive(Serialize)] #[derive(Serialize)]
pub struct PostDetail { pub struct PostDetail {
pub slug: String, pub slug: String,
@@ -101,6 +135,12 @@ pub struct PostDetail {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub cover_image: Option<CoverImage>, pub cover_image: Option<CoverImage>,
pub image_count: u32, pub image_count: u32,
#[serde(skip_serializing_if = "Option::is_none")]
pub prev: Option<PostNeighbor>,
#[serde(skip_serializing_if = "Option::is_none")]
pub next: Option<PostNeighbor>,
#[serde(skip_serializing_if = "HashMap::is_empty")]
pub dimensions: HashMap<String, ImageDim>,
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@@ -121,6 +161,40 @@ pub struct CreatePostRequest {
pub content: String, pub content: String,
} }
#[derive(Deserialize)]
pub struct ContactSubmission {
#[serde(default)]
pub name: Option<String>,
#[serde(default)]
pub email: Option<String>,
#[serde(default)]
pub subject: Option<String>,
pub message: String,
#[serde(default)]
pub website: Option<String>,
pub started_at: i64,
}
#[derive(Serialize, Deserialize, Clone)]
pub struct Message {
pub id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub subject: Option<String>,
pub body: String,
pub received_at: i64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ip_hash: Option<String>,
}
#[derive(Serialize)]
pub struct ContactResponse {
pub ok: bool,
}
#[derive(Serialize)] #[derive(Serialize)]
pub struct ErrorResponse { pub struct ErrorResponse {
pub error: String, pub error: String,
+113
View File
@@ -0,0 +1,113 @@
//! The in-memory posts cache: rebuilt from disk at startup and after every
//! mutation, plus prev/next neighbour lookup over the visible set.
use tokio::fs;
use tracing::warn;
use crate::models::{PostInfo, PostMeta, PostNeighbor};
use crate::post::images::{cover_from, dim_for_url, extract_images};
use crate::post::parse::{excerpt_from, parse_post, reading_time};
use crate::{AppState, CachedPost};
fn build_post_info(slug: &str, meta: &PostMeta, body: &str) -> PostInfo {
let images = extract_images(body);
PostInfo {
slug: slug.to_string(),
date: meta.date,
title: meta.title.clone(),
summary: meta.summary.clone(),
tags: meta.tags.clone(),
draft: meta.draft,
reading_time: reading_time(body),
excerpt: excerpt_from(meta, body),
cover_image: cover_from(&images),
image_count: images.len() as u32,
}
}
/// Scans the posts directory and replaces the in-memory cache.
/// Called at startup and after any mutation (create/rename/delete).
pub(crate) async fn rebuild_posts_cache(state: &AppState) {
let posts_dir = state.data_dir.join("posts");
let mut posts: Vec<CachedPost> = Vec::new();
let mut rd = match fs::read_dir(&posts_dir).await {
Ok(rd) => rd,
Err(_) => {
*state.posts_cache.write().await = posts;
return;
}
};
loop {
match rd.next_entry().await {
Ok(Some(entry)) => {
let path = entry.path();
if path.extension().and_then(|e| e.to_str()) != Some("md") {
continue;
}
let Some(slug) = path.file_stem().and_then(|s| s.to_str()) else {
continue;
};
if slug.starts_with('.') {
continue;
}
let Ok(raw) = fs::read_to_string(&path).await else {
continue;
};
let Ok((meta, body)) = parse_post(&raw) else {
warn!("Skipping post with bad frontmatter: {}", slug);
continue;
};
let mut info = build_post_info(slug, &meta, &body);
if let Some(cover) = info.cover_image.as_mut() {
if let Some(d) = dim_for_url(state, &cover.url).await {
cover.w = Some(d.w);
cover.h = Some(d.h);
}
}
posts.push(CachedPost { info, body });
}
Ok(None) => break,
Err(e) => {
warn!("Error iterating posts dir: {}", e);
break;
}
}
}
posts.sort_by(|a, b| {
b.info
.date
.cmp(&a.info.date)
.then_with(|| a.info.slug.cmp(&b.info.slug))
});
*state.posts_cache.write().await = posts;
}
pub(crate) async fn neighbors_from_cache(
state: &AppState,
slug: &str,
admin: bool,
) -> (Option<PostNeighbor>, Option<PostNeighbor>) {
let cache = state.posts_cache.read().await;
let visible: Vec<&PostInfo> = cache
.iter()
.filter(|p| admin || !p.info.draft)
.map(|p| &p.info)
.collect();
let Some(i) = visible.iter().position(|p| p.slug == slug) else {
return (None, None);
};
let to_neighbor = |p: &PostInfo| PostNeighbor {
slug: p.slug.clone(),
title: p.title.clone(),
};
let prev = if i > 0 {
Some(to_neighbor(visible[i - 1]))
} else {
None
};
let next = visible.get(i + 1).map(|p| to_neighbor(p));
(prev, next)
}
+166
View File
@@ -0,0 +1,166 @@
//! Markdown image extraction, cover selection, and the on-disk
//! image-dimension probe (header-only read, cached on `AppState`).
use std::collections::HashMap;
use crate::AppState;
use crate::models::{CoverImage, ImageDim};
/// Scan markdown for `![alt](url)` images. Returns (alt, url) pairs in order.
/// Skips inside fenced code blocks. Tolerates titles like `![alt](url "title")`.
pub(crate) fn extract_images(body: &str) -> Vec<(String, String)> {
let mut out = Vec::new();
let mut in_fence = false;
for line in body.lines() {
let trimmed = line.trim_start();
if trimmed.starts_with("```") || trimmed.starts_with("~~~") {
in_fence = !in_fence;
continue;
}
if in_fence {
continue;
}
let bytes = line.as_bytes();
let mut i = 0;
while i + 1 < bytes.len() {
if bytes[i] == b'!' && bytes[i + 1] == b'[' {
if let Some(rel_close) = line[i + 2..].find(']') {
let close = i + 2 + rel_close;
if close + 1 < line.len() && bytes[close + 1] == b'(' {
if let Some(rel_paren) = line[close + 2..].find(')') {
let paren_end = close + 2 + rel_paren;
let alt = line[i + 2..close].to_string();
let url_field = line[close + 2..paren_end].trim();
let url = url_field
.split_once(|c: char| c.is_whitespace())
.map(|(u, _)| u)
.unwrap_or(url_field)
.trim_matches(|c| c == '<' || c == '>')
.to_string();
if !url.is_empty() {
out.push((alt, url));
}
i = paren_end + 1;
continue;
}
}
}
}
i += 1;
}
}
out
}
pub(crate) fn cover_from(images: &[(String, String)]) -> Option<CoverImage> {
images.first().map(|(alt, url)| CoverImage {
url: url.clone(),
alt: alt.clone(),
w: None,
h: None,
})
}
/// Probe an uploads-relative URL for image dimensions. Reads only header
/// bytes via `imagesize::size`, off the runtime via `spawn_blocking`.
async fn compute_dim_from_url(state: &AppState, url: &str) -> Option<ImageDim> {
let name = url.strip_prefix("/uploads/")?;
if name.is_empty() || name.contains("..") || name.contains('\\') || name.starts_with('/') {
return None;
}
let path = state.data_dir.join("uploads").join(name);
tokio::task::spawn_blocking(move || imagesize::size(&path).ok())
.await
.ok()
.flatten()
.map(|s| ImageDim {
w: s.width as u32,
h: s.height as u32,
})
}
/// Returns cached dim if present, else probes the file and caches the result.
pub(crate) async fn dim_for_url(state: &AppState, url: &str) -> Option<ImageDim> {
{
let cache = state.image_dims_cache.read().await;
if let Some(d) = cache.get(url) {
return Some(*d);
}
}
let d = compute_dim_from_url(state, url).await?;
state
.image_dims_cache
.write()
.await
.insert(url.to_string(), d);
Some(d)
}
/// Returns a map of `url -> ImageDim` for the given URLs, using the cache
/// and probing only the URLs that aren't cached yet.
pub(crate) async fn dims_for_urls(state: &AppState, urls: &[String]) -> HashMap<String, ImageDim> {
let mut out: HashMap<String, ImageDim> = HashMap::new();
let mut missing: Vec<String> = Vec::new();
{
let cache = state.image_dims_cache.read().await;
for url in urls {
if out.contains_key(url) {
continue;
}
if let Some(d) = cache.get(url) {
out.insert(url.clone(), *d);
} else {
missing.push(url.clone());
}
}
}
if missing.is_empty() {
return out;
}
let mut newly: Vec<(String, ImageDim)> = Vec::new();
for url in &missing {
if let Some(d) = compute_dim_from_url(state, url).await {
newly.push((url.clone(), d));
}
}
if !newly.is_empty() {
let mut cache = state.image_dims_cache.write().await;
for (url, d) in &newly {
cache.insert(url.clone(), *d);
out.insert(url.clone(), *d);
}
}
out
}
#[cfg(test)]
mod tests {
use super::{cover_from, extract_images};
#[test]
fn extract_images_skips_fences_and_strips_titles() {
let md = "intro\n\
![a](/u/one.png)\n\
```\n\
![skip](/u/hidden.png)\n\
```\n\
![c](/u/two.png \"a title\")";
let imgs = extract_images(md);
assert_eq!(
imgs,
vec![
("a".to_string(), "/u/one.png".to_string()),
("c".to_string(), "/u/two.png".to_string()),
]
);
}
#[test]
fn cover_from_takes_first_or_none() {
assert!(cover_from(&[]).is_none());
let imgs = vec![("alt".to_string(), "/u/first.png".to_string())];
let cover = cover_from(&imgs).unwrap();
assert_eq!(cover.url, "/u/first.png");
assert_eq!(cover.alt, "alt");
}
}
+13
View File
@@ -0,0 +1,13 @@
//! Post domain logic, split out of the HTTP layer.
//!
//! - [`parse`] — slug validation, frontmatter split/parse/serialize, reading
//! time, excerpt. Pure, no I/O.
//! - [`images`] — markdown image extraction, cover selection, and the
//! filesystem image-dimension probe + cache.
//! - [`cache`] — the in-memory posts cache (rebuild + neighbour lookup).
//!
//! `handlers::posts` stays thin and only orchestrates these.
pub mod cache;
pub mod images;
pub mod parse;
+179
View File
@@ -0,0 +1,179 @@
//! Pure post parsing: slug validation, YAML frontmatter, reading time,
//! excerpt. No filesystem or network access — trivially unit-testable.
use crate::error::AppError;
use crate::models::PostMeta;
const WORDS_PER_MINUTE: u32 = 200;
const MAX_SLUG_LEN: usize = 100;
const WINDOWS_RESERVED: &[&str] = &[
"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8",
"COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9",
];
pub(crate) fn validate_slug(s: &str) -> Result<(), AppError> {
if s.is_empty() {
return Err(AppError::BadRequest("Slug is empty".to_string()));
}
if s.len() > MAX_SLUG_LEN {
return Err(AppError::BadRequest(format!(
"Slug exceeds {} characters",
MAX_SLUG_LEN
)));
}
if s.starts_with('.') {
return Err(AppError::BadRequest(
"Slug cannot start with '.'".to_string(),
));
}
if s.ends_with('.') || s.ends_with(' ') {
return Err(AppError::BadRequest(
"Slug cannot end with '.' or space".to_string(),
));
}
if s.contains("..") {
return Err(AppError::BadRequest("Slug cannot contain '..'".to_string()));
}
for c in s.chars() {
if c.is_control() {
return Err(AppError::BadRequest(
"Slug contains control characters".to_string(),
));
}
if matches!(c, '/' | '\\' | '<' | '>' | ':' | '"' | '|' | '?' | '*') {
return Err(AppError::BadRequest(format!(
"Slug contains invalid character '{}'",
c
)));
}
}
let stem = s.split('.').next().unwrap_or("").to_ascii_uppercase();
if WINDOWS_RESERVED.iter().any(|r| *r == stem) {
return Err(AppError::BadRequest("Slug is a reserved name".to_string()));
}
Ok(())
}
pub(crate) fn split_frontmatter(raw: &str) -> Option<(&str, &str)> {
let raw = raw
.strip_prefix("---\n")
.or_else(|| raw.strip_prefix("---\r\n"))?;
let end_marker = raw.find("\n---\n").or_else(|| raw.find("\r\n---\r\n"))?;
let yaml = &raw[..end_marker];
let body_start = end_marker
+ raw[end_marker..]
.find("---\n")
.or_else(|| raw[end_marker..].find("---\r\n"))?
+ "---\n".len();
let body = raw[body_start..]
.trim_start_matches('\n')
.trim_start_matches('\r');
Some((yaml, body))
}
pub(crate) fn parse_post(raw: &str) -> Result<(PostMeta, String), AppError> {
let (yaml, body) = split_frontmatter(raw).ok_or_else(|| {
AppError::Internal(
"Missing frontmatter".to_string(),
Some("post is missing the YAML --- block".to_string()),
)
})?;
let meta: PostMeta = serde_yaml::from_str(yaml).map_err(|e| {
AppError::Internal(
"Invalid frontmatter".to_string(),
Some(format!("YAML parse error: {}", e)),
)
})?;
Ok((meta, body.to_string()))
}
pub(crate) fn serialize_post(meta: &PostMeta, body: &str) -> Result<String, AppError> {
let yaml = serde_yaml::to_string(meta)
.map_err(|e| AppError::Internal("Serialization error".to_string(), Some(e.to_string())))?;
Ok(format!("---\n{}---\n{}", yaml, body))
}
pub(crate) fn reading_time(body: &str) -> u32 {
let words = body.split_whitespace().count() as u32;
(words + WORDS_PER_MINUTE - 1) / WORDS_PER_MINUTE.max(1)
}
pub(crate) fn excerpt_from(meta: &PostMeta, body: &str) -> String {
if let Some(s) = meta.summary.as_ref() {
if !s.trim().is_empty() {
return s.trim().to_string();
}
}
let plain = body.replace(['#', '*', '_', '`'], "").replace('\n', " ");
let mut out: String = plain.chars().take(200).collect();
if plain.chars().count() > 200 {
out.push_str("...");
}
out.trim().to_string()
}
#[cfg(test)]
mod tests {
use super::{parse_post, reading_time, split_frontmatter, validate_slug};
use crate::error::AppError;
#[test]
fn validate_slug_accepts_normal_slugs() {
assert!(validate_slug("hello-world").is_ok());
assert!(validate_slug("a_b.c-123").is_ok());
}
#[test]
fn validate_slug_rejects_traversal_and_bad_chars() {
for bad in [
"",
"../etc",
"with/slash",
"back\\slash",
"ends.",
"trailing ",
".hidden",
] {
assert!(
matches!(validate_slug(bad), Err(AppError::BadRequest(_))),
"expected {bad:?} to be rejected"
);
}
let too_long = "x".repeat(101);
assert!(validate_slug(&too_long).is_err());
assert!(matches!(validate_slug("CON"), Err(AppError::BadRequest(_))));
}
#[test]
fn split_frontmatter_handles_lf_and_crlf() {
let (yaml, body) = split_frontmatter("---\ndate: 2026-05-16\n---\nHello").unwrap();
assert_eq!(yaml, "date: 2026-05-16");
assert_eq!(body, "Hello");
let (y2, b2) = split_frontmatter("---\r\ndate: 2026-05-16\r\n---\r\nHi").unwrap();
assert!(y2.contains("date: 2026-05-16"));
assert_eq!(b2, "Hi");
assert!(split_frontmatter("no frontmatter here").is_none());
}
#[test]
fn parse_post_reads_meta_and_body() {
let raw = "---\ndate: 2026-05-16\ntitle: Hello\ndraft: true\n---\nBody text";
let (meta, body) = parse_post(raw).unwrap();
assert_eq!(meta.title.as_deref(), Some("Hello"));
assert!(meta.draft);
assert_eq!(meta.date.to_string(), "2026-05-16");
assert_eq!(body, "Body text");
assert!(parse_post("no frontmatter").is_err());
}
#[test]
fn reading_time_rounds_up_by_wpm() {
assert_eq!(reading_time(""), 0);
assert_eq!(reading_time("one"), 1);
assert_eq!(reading_time(&"word ".repeat(200)), 1);
assert_eq!(reading_time(&"word ".repeat(201)), 2);
}
}
+2 -1
View File
@@ -41,7 +41,8 @@ services:
ports: ports:
- "4322:4321" - "4322:4321"
environment: environment:
- PUBLIC_API_URL=http://backend:3000 - PUBLIC_API_URL=${PUBLIC_API_URL:-}
- SITE_MODE=${SITE_MODE:-atelier}
depends_on: depends_on:
backend: backend:
condition: service_healthy condition: service_healthy
+4 -1
View File
@@ -21,7 +21,10 @@ export default defineConfig({
service: { entrypoint: 'astro/assets/services/noop' } service: { entrypoint: 'astro/assets/services/noop' }
}, },
vite: { vite: {
plugins: [tailwindcss()] plugins: [tailwindcss()],
build: {
chunkSizeWarningLimit: 600,
},
}, },
adapter: node({ adapter: node({
+56
View File
@@ -0,0 +1,56 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["src/**/*.{ts,tsx,js,jsx,json}", "*.{ts,js,json}", "!**/dist", "!**/.astro"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off",
"noControlCharactersInRegex": "warn",
"noArrayIndexKey": "warn"
},
"correctness": {
"useExhaustiveDependencies": "warn"
},
"security": {
"noDangerouslySetInnerHtml": "warn"
},
"a11y": {
"noLabelWithoutControl": "warn",
"noSvgWithoutTitle": "warn",
"useKeyWithClickEvents": "warn",
"useButtonType": "warn",
"noStaticElementInteractions": "warn",
"useSemanticElements": "warn"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "always"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
+632 -6
View File
@@ -21,7 +21,8 @@
"@fontsource-variable/fraunces": "^5.2.9", "@fontsource-variable/fraunces": "^5.2.9",
"@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/inter": "^5.2.5",
"@fontsource-variable/jetbrains-mono": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5",
"@fontsource/caveat": "^5.2.8", "@fontsource/space-mono": "^5.2.9",
"@fontsource/vt323": "^5.2.7",
"@replit/codemirror-vim": "^6.3.0", "@replit/codemirror-vim": "^6.3.0",
"@tailwindcss/vite": "^4.2.2", "@tailwindcss/vite": "^4.2.2",
"astro": "^6.0.8", "astro": "^6.0.8",
@@ -40,11 +41,13 @@
}, },
"devDependencies": { "devDependencies": {
"@astrojs/check": "^0.9.9", "@astrojs/check": "^0.9.9",
"@biomejs/biome": "^2.0.0",
"@types/katex": "^0.16.8", "@types/katex": "^0.16.8",
"@types/node": "^25.5.0", "@types/node": "^25.5.0",
"@types/react": "^19.2.14", "@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"typescript": "^5.9.3" "typescript": "^5.9.3",
"vitest": "^3.0.0"
}, },
"engines": { "engines": {
"node": ">=22.12.0" "node": ">=22.12.0"
@@ -607,6 +610,181 @@
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@biomejs/biome": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.4.15.tgz",
"integrity": "sha512-j5VH3a/h/HXTKBM50MDMxRCzkeLv9S2XJcW2WgnZT1+xyisi+0bISrXR82gCX+8S9lvK0skEvHJRN+3Ktr2hlw==",
"dev": true,
"license": "MIT OR Apache-2.0",
"bin": {
"biome": "bin/biome"
},
"engines": {
"node": ">=14.21.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/biome"
},
"optionalDependencies": {
"@biomejs/cli-darwin-arm64": "2.4.15",
"@biomejs/cli-darwin-x64": "2.4.15",
"@biomejs/cli-linux-arm64": "2.4.15",
"@biomejs/cli-linux-arm64-musl": "2.4.15",
"@biomejs/cli-linux-x64": "2.4.15",
"@biomejs/cli-linux-x64-musl": "2.4.15",
"@biomejs/cli-win32-arm64": "2.4.15",
"@biomejs/cli-win32-x64": "2.4.15"
}
},
"node_modules/@biomejs/cli-darwin-arm64": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.4.15.tgz",
"integrity": "sha512-rF3PPqLq1yoST79zaQbDjVJwsuIeci/O+9bgNmC5QpgOqz6aqYuzA4abyAGx+mgyiDXn4A049xAN8gijbuR1Qg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-darwin-x64": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.4.15.tgz",
"integrity": "sha512-/5KHXYMfSJs1fNXiX30xFtI8JcCFV6zaVVLxOa0M2sfqBKHkpQhRTv94yxQWxeTY2lzo2OuTlNvPC+hDQt2wcQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-arm64": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.4.15.tgz",
"integrity": "sha512-owaAMZD/T4LrD0ELNCk0Km3qrRHuM0X6EAyVE1FSqGY0rbLoiDLrO4Us2tllm6cAeB2Ioa9C2C08NZPdr8+0Ug==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-arm64-musl": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.4.15.tgz",
"integrity": "sha512-ZPcxznxm0pogHBLZhYntyR3sR+MrZjqJIKEr7ZqVen0Rl+P/4upVmfYXjftizi9RoqZntg33fv/1fbdhbYXpEQ==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-x64": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.4.15.tgz",
"integrity": "sha512-0jj7THz12GbUOLmMibktK6DZjqz2zV64KFxyBtcFTKPiiOIY0a7vns1elpO1dERvxpsZ5ik0oFfz0oGwFde1+g==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-x64-musl": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.4.15.tgz",
"integrity": "sha512-CNq/9W38SYSH023lfcQ4KKU8K0YX8T//FZUhcgtMMRABDojx5XsMV7jlweAvGSl389wJQB29Qo6Zb/a+jdvt+w==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-win32-arm64": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.4.15.tgz",
"integrity": "sha512-ouhkYdlhp/1GghEJPdWwD/Vi3gQ1nFxuSpMolWsbq3Lsq3QUR4jl6UdhhscdCugKU5vOEuMiJhvKj66O0OCq+w==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-win32-x64": {
"version": "2.4.15",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.4.15.tgz",
"integrity": "sha512-zBrGq5mx5wwpnow4+2BxUvleDM+GNd4sLbPaMapsSLQLD0NGRCquqPBTgN+7XkUteHvj7M+BstuI8tmnV7+HgQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@bramus/specificity": { "node_modules/@bramus/specificity": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz", "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz",
@@ -1723,10 +1901,19 @@
"url": "https://github.com/sponsors/ayuhito" "url": "https://github.com/sponsors/ayuhito"
} }
}, },
"node_modules/@fontsource/caveat": { "node_modules/@fontsource/space-mono": {
"version": "5.2.8", "version": "5.2.9",
"resolved": "https://registry.npmjs.org/@fontsource/caveat/-/caveat-5.2.8.tgz", "resolved": "https://registry.npmjs.org/@fontsource/space-mono/-/space-mono-5.2.9.tgz",
"integrity": "sha512-9fUUfFE2IQFKbx+xOcaeQxxmh8iJguEb8z+j1PeueO4UUx+XfT4pRm/B04ZDvFA794/iRxY/IibmP8ZKtIf4rw==", "integrity": "sha512-b61faFOHEISQ/pD25G+cfGY9o/WW6lRv6hBQQfpWvEJ4y1V+S4gmth95EVyBE2VL3qDYHeVQ8nBzrplzdXTDDg==",
"license": "OFL-1.1",
"funding": {
"url": "https://github.com/sponsors/ayuhito"
}
},
"node_modules/@fontsource/vt323": {
"version": "5.2.7",
"resolved": "https://registry.npmjs.org/@fontsource/vt323/-/vt323-5.2.7.tgz",
"integrity": "sha512-8JTMM23vMhQxin9Cn/ijty8cNwXW4INrln0VAJ2227Rz0CVfkzM3qr3l/CqudZJ6BXCnbCGUTdf2ym3cTNex8A==",
"license": "OFL-1.1", "license": "OFL-1.1",
"funding": { "funding": {
"url": "https://github.com/sponsors/ayuhito" "url": "https://github.com/sponsors/ayuhito"
@@ -3295,6 +3482,17 @@
"@babel/types": "^7.28.2" "@babel/types": "^7.28.2"
} }
}, },
"node_modules/@types/chai": {
"version": "5.2.3",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
"integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/deep-eql": "*",
"assertion-error": "^2.0.1"
}
},
"node_modules/@types/debug": { "node_modules/@types/debug": {
"version": "4.1.13", "version": "4.1.13",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz",
@@ -3304,6 +3502,13 @@
"@types/ms": "*" "@types/ms": "*"
} }
}, },
"node_modules/@types/deep-eql": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
"integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/estree": { "node_modules/@types/estree": {
"version": "1.0.8", "version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
@@ -3417,6 +3622,131 @@
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
} }
}, },
"node_modules/@vitest/expect": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz",
"integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/chai": "^5.2.2",
"@vitest/spy": "3.2.4",
"@vitest/utils": "3.2.4",
"chai": "^5.2.0",
"tinyrainbow": "^2.0.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/mocker": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz",
"integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/spy": "3.2.4",
"estree-walker": "^3.0.3",
"magic-string": "^0.30.17"
},
"funding": {
"url": "https://opencollective.com/vitest"
},
"peerDependencies": {
"msw": "^2.4.9",
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
},
"peerDependenciesMeta": {
"msw": {
"optional": true
},
"vite": {
"optional": true
}
}
},
"node_modules/@vitest/mocker/node_modules/estree-walker": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "^1.0.0"
}
},
"node_modules/@vitest/pretty-format": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz",
"integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==",
"dev": true,
"license": "MIT",
"dependencies": {
"tinyrainbow": "^2.0.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/runner": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz",
"integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/utils": "3.2.4",
"pathe": "^2.0.3",
"strip-literal": "^3.0.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/snapshot": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz",
"integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/pretty-format": "3.2.4",
"magic-string": "^0.30.17",
"pathe": "^2.0.3"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/spy": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz",
"integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==",
"dev": true,
"license": "MIT",
"dependencies": {
"tinyspy": "^4.0.3"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/utils": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz",
"integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vitest/pretty-format": "3.2.4",
"loupe": "^3.1.4",
"tinyrainbow": "^2.0.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@volar/kit": { "node_modules/@volar/kit": {
"version": "2.4.28", "version": "2.4.28",
"resolved": "https://registry.npmjs.org/@volar/kit/-/kit-2.4.28.tgz", "resolved": "https://registry.npmjs.org/@volar/kit/-/kit-2.4.28.tgz",
@@ -3632,6 +3962,16 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/assertion-error": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
"integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
}
},
"node_modules/astro": { "node_modules/astro": {
"version": "6.0.8", "version": "6.0.8",
"resolved": "https://registry.npmjs.org/astro/-/astro-6.0.8.tgz", "resolved": "https://registry.npmjs.org/astro/-/astro-6.0.8.tgz",
@@ -3789,6 +4129,16 @@
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
} }
}, },
"node_modules/cac": {
"version": "6.7.14",
"resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
"integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001781", "version": "1.0.30001781",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001781.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001781.tgz",
@@ -3819,6 +4169,23 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/chai": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz",
"integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==",
"dev": true,
"license": "MIT",
"dependencies": {
"assertion-error": "^2.0.1",
"check-error": "^2.1.1",
"deep-eql": "^5.0.1",
"loupe": "^3.1.0",
"pathval": "^2.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/character-entities": { "node_modules/character-entities": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz",
@@ -3849,6 +4216,16 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/check-error": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz",
"integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 16"
}
},
"node_modules/chokidar": { "node_modules/chokidar": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
@@ -4150,6 +4527,16 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/deep-eql": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz",
"integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/defu": { "node_modules/defu": {
"version": "6.1.4", "version": "6.1.4",
"resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz",
@@ -4473,6 +4860,16 @@
"integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==", "integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/expect-type": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz",
"integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/extend": { "node_modules/extend": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
@@ -5426,6 +5823,13 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/loupe": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz",
"integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==",
"dev": true,
"license": "MIT"
},
"node_modules/lru-cache": { "node_modules/lru-cache": {
"version": "11.2.7", "version": "11.2.7",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.7.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.7.tgz",
@@ -6570,6 +6974,23 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/pathe": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
"dev": true,
"license": "MIT"
},
"node_modules/pathval": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz",
"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 14.16"
}
},
"node_modules/piccolore": { "node_modules/piccolore": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/piccolore/-/piccolore-0.1.3.tgz", "resolved": "https://registry.npmjs.org/piccolore/-/piccolore-0.1.3.tgz",
@@ -7162,6 +7583,13 @@
"node": ">=20" "node": ">=20"
} }
}, },
"node_modules/siginfo": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
"integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",
"dev": true,
"license": "ISC"
},
"node_modules/sisteransi": { "node_modules/sisteransi": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
@@ -7199,6 +7627,13 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/stackback": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
"integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",
"dev": true,
"license": "MIT"
},
"node_modules/statuses": { "node_modules/statuses": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
@@ -7208,6 +7643,13 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/std-env": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz",
"integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==",
"dev": true,
"license": "MIT"
},
"node_modules/string-width": { "node_modules/string-width": {
"version": "4.2.3", "version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
@@ -7250,6 +7692,26 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/strip-literal": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz",
"integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==",
"dev": true,
"license": "MIT",
"dependencies": {
"js-tokens": "^9.0.1"
},
"funding": {
"url": "https://github.com/sponsors/antfu"
}
},
"node_modules/strip-literal/node_modules/js-tokens": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz",
"integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==",
"dev": true,
"license": "MIT"
},
"node_modules/style-mod": { "node_modules/style-mod": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz", "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",
@@ -7312,6 +7774,13 @@
"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==", "integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/tinybench": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
"integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==",
"dev": true,
"license": "MIT"
},
"node_modules/tinyclip": { "node_modules/tinyclip": {
"version": "0.1.12", "version": "0.1.12",
"resolved": "https://registry.npmjs.org/tinyclip/-/tinyclip-0.1.12.tgz", "resolved": "https://registry.npmjs.org/tinyclip/-/tinyclip-0.1.12.tgz",
@@ -7346,6 +7815,36 @@
"url": "https://github.com/sponsors/SuperchupuDev" "url": "https://github.com/sponsors/SuperchupuDev"
} }
}, },
"node_modules/tinypool": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz",
"integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^18.0.0 || >=20.0.0"
}
},
"node_modules/tinyrainbow": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz",
"integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/tinyspy": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.4.tgz",
"integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/tldts": { "node_modules/tldts": {
"version": "7.0.30", "version": "7.0.30",
"resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.30.tgz", "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.30.tgz",
@@ -7904,6 +8403,36 @@
} }
} }
}, },
"node_modules/vite-node": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz",
"integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==",
"dev": true,
"license": "MIT",
"dependencies": {
"cac": "^6.7.14",
"debug": "^4.4.1",
"es-module-lexer": "^1.7.0",
"pathe": "^2.0.3",
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
},
"bin": {
"vite-node": "vite-node.mjs"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/vite-node/node_modules/es-module-lexer": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
"integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==",
"dev": true,
"license": "MIT"
},
"node_modules/vitefu": { "node_modules/vitefu": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.2.tgz", "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.2.tgz",
@@ -7923,6 +8452,86 @@
} }
} }
}, },
"node_modules/vitest": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz",
"integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/chai": "^5.2.2",
"@vitest/expect": "3.2.4",
"@vitest/mocker": "3.2.4",
"@vitest/pretty-format": "^3.2.4",
"@vitest/runner": "3.2.4",
"@vitest/snapshot": "3.2.4",
"@vitest/spy": "3.2.4",
"@vitest/utils": "3.2.4",
"chai": "^5.2.0",
"debug": "^4.4.1",
"expect-type": "^1.2.1",
"magic-string": "^0.30.17",
"pathe": "^2.0.3",
"picomatch": "^4.0.2",
"std-env": "^3.9.0",
"tinybench": "^2.9.0",
"tinyexec": "^0.3.2",
"tinyglobby": "^0.2.14",
"tinypool": "^1.1.1",
"tinyrainbow": "^2.0.0",
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0",
"vite-node": "3.2.4",
"why-is-node-running": "^2.3.0"
},
"bin": {
"vitest": "vitest.mjs"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
},
"peerDependencies": {
"@edge-runtime/vm": "*",
"@types/debug": "^4.1.12",
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
"@vitest/browser": "3.2.4",
"@vitest/ui": "3.2.4",
"happy-dom": "*",
"jsdom": "*"
},
"peerDependenciesMeta": {
"@edge-runtime/vm": {
"optional": true
},
"@types/debug": {
"optional": true
},
"@types/node": {
"optional": true
},
"@vitest/browser": {
"optional": true
},
"@vitest/ui": {
"optional": true
},
"happy-dom": {
"optional": true
},
"jsdom": {
"optional": true
}
}
},
"node_modules/vitest/node_modules/tinyexec": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz",
"integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==",
"dev": true,
"license": "MIT"
},
"node_modules/volar-service-css": { "node_modules/volar-service-css": {
"version": "0.0.70", "version": "0.0.70",
"resolved": "https://registry.npmjs.org/volar-service-css/-/volar-service-css-0.0.70.tgz", "resolved": "https://registry.npmjs.org/volar-service-css/-/volar-service-css-0.0.70.tgz",
@@ -8247,6 +8856,23 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/why-is-node-running": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",
"integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",
"dev": true,
"license": "MIT",
"dependencies": {
"siginfo": "^2.0.0",
"stackback": "0.0.2"
},
"bin": {
"why-is-node-running": "cli.js"
},
"engines": {
"node": ">=8"
}
},
"node_modules/wrap-ansi": { "node_modules/wrap-ansi": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
+14 -3
View File
@@ -9,7 +9,15 @@
"dev": "astro dev", "dev": "astro dev",
"build": "astro build", "build": "astro build",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro",
"check": "astro check",
"lint": "biome lint .",
"lint:fix": "biome lint --write .",
"format": "biome format --write .",
"format:check": "biome format .",
"test": "vitest run",
"test:watch": "vitest",
"verify": "astro check && biome lint . && vitest run"
}, },
"dependencies": { "dependencies": {
"@astrojs/node": "^10.0.3", "@astrojs/node": "^10.0.3",
@@ -25,7 +33,8 @@
"@fontsource-variable/fraunces": "^5.2.9", "@fontsource-variable/fraunces": "^5.2.9",
"@fontsource-variable/inter": "^5.2.5", "@fontsource-variable/inter": "^5.2.5",
"@fontsource-variable/jetbrains-mono": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5",
"@fontsource/caveat": "^5.2.8", "@fontsource/space-mono": "^5.2.9",
"@fontsource/vt323": "^5.2.7",
"@replit/codemirror-vim": "^6.3.0", "@replit/codemirror-vim": "^6.3.0",
"@tailwindcss/vite": "^4.2.2", "@tailwindcss/vite": "^4.2.2",
"astro": "^6.0.8", "astro": "^6.0.8",
@@ -44,10 +53,12 @@
}, },
"devDependencies": { "devDependencies": {
"@astrojs/check": "^0.9.9", "@astrojs/check": "^0.9.9",
"@biomejs/biome": "^2.0.0",
"@types/katex": "^0.16.8", "@types/katex": "^0.16.8",
"@types/node": "^25.5.0", "@types/node": "^25.5.0",
"@types/react": "^19.2.14", "@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"typescript": "^5.9.3" "typescript": "^5.9.3",
"vitest": "^3.0.0"
} }
} }
+125
View File
@@ -0,0 +1,125 @@
---
/*
* CyberFx — ambient + interactive layer for the `.cybersigil` theme.
*
* Renders an aria-hidden overlay root on every page. All visuals are CSS,
* scoped to `.cybersigil .cs-fx*` in global.css, so this is an inert,
* display:none no-op under every other theme. The bundled script only wires
* the scroll-entry databend on images and self-disables off-theme or under
* prefers-reduced-motion.
*/
---
<div class="cs-fx" aria-hidden="true">
<div class="cs-fx-halftone"></div>
<div class="cs-fx-wire"></div>
<div class="cs-fx-tear"></div>
<i class="cs-fx-corner cs-fx-corner--tl"></i>
<i class="cs-fx-corner cs-fx-corner--tr"></i>
<i class="cs-fx-corner cs-fx-corner--bl"></i>
<i class="cs-fx-corner cs-fx-corner--br"></i>
</div>
<script>
import { buildCybersigil } from '../lib/cybersigil';
let teardown: (() => void) | null = null;
function initCyberFx() {
const root = document.documentElement;
if (!root.classList.contains('cybersigil')) return;
const fx = document.querySelector<HTMLElement>('.cs-fx');
if (!fx) return;
const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
/* ─── Generated sigil growths in the four corners ─── */
/* One sigil per page load; the four corner transforms in global.css
* (scaleX / scaleY / scale) splay it into each corner. */
const corners = document.querySelectorAll<HTMLElement>('.cs-fx-corner');
if (corners.length) {
const svg = buildCybersigil();
corners.forEach((c) => {
if (c.classList.contains('cs-fx-corner--sig')) return;
c.innerHTML = svg;
c.classList.add('cs-fx-corner--sig');
});
}
/* ─── One sigil filling the background. count:6 (was 9) — fewer branch
* nodes ⇒ far fewer perpetually-animating strokes, same silhouette. ─── */
const wire = document.querySelector<HTMLElement>('.cs-fx-wire');
if (wire && !wire.classList.contains('cs-fx-wire--sig')) {
wire.innerHTML = buildCybersigil({ count: 6 });
wire.classList.add('cs-fx-wire--sig');
}
/* ─── Scroll-entry databend on images ─── */
if (!reduced && 'IntersectionObserver' in window) {
const targets = document.querySelectorAll<HTMLElement>(
'.prose img, .prose figure img, .plate-image img'
);
if (targets.length) {
const io = new IntersectionObserver(
(entries) => {
for (const en of entries) {
if (!en.isIntersecting) continue;
const el = en.target as HTMLElement;
el.classList.remove('cs-databent');
// reflow so the animation can retrigger
void el.offsetWidth;
el.classList.add('cs-databent');
io.unobserve(el);
}
},
{ rootMargin: '0px 0px -12% 0px', threshold: 0.15 }
);
targets.forEach((t) => io.observe(t));
}
}
/* ─── Ambient: entrance fade-in (opacity:0 → target via the CSS
* transition on first apply) + scroll-depth recede. Parallax is
* disabled for now — the --cs-px/py/cx/cy vars default to 0px so the
* wire/corner transforms stay put; re-enable by driving those vars
* from scroll/pointer here again. ─── */
if (teardown) teardown();
const off: Array<() => void> = [];
let depth = 0, raf = 0;
const apply = () => {
raf = 0;
fx.style.opacity = String(1 - 0.5 * depth);
};
const schedule = () => { if (!raf) raf = requestAnimationFrame(apply); };
const onScroll = () => {
const vh = window.innerHeight || 1;
depth = Math.max(0, Math.min(1, window.scrollY / vh));
schedule();
};
window.addEventListener('scroll', onScroll, { passive: true });
window.addEventListener('resize', onScroll);
off.push(() => window.removeEventListener('scroll', onScroll));
off.push(() => window.removeEventListener('resize', onScroll));
onScroll();
/* Freeze every loop while the tab is hidden — idle-battery win. */
const onVis = () => fx.classList.toggle('is-paused', document.hidden);
document.addEventListener('visibilitychange', onVis);
off.push(() => document.removeEventListener('visibilitychange', onVis));
onVis();
teardown = () => {
if (raf) cancelAnimationFrame(raf);
off.forEach((fn) => fn());
teardown = null;
};
}
initCyberFx();
// MPA back/forward restores: re-arm if needed.
window.addEventListener('pageshow', (e) => {
if (e.persisted) initCyberFx();
});
</script>
+12 -9
View File
@@ -4,11 +4,13 @@ import AssetManager from './admin/AssetManager';
interface Props { interface Props {
className?: string; className?: string;
label?: string; label?: string;
iconSize?: number;
} }
export default function AssetsButton({ export default function AssetsButton({
className = 'inline-flex items-center gap-2 bg-surface0 hover:bg-surface1 text-subtext1 hover:text-text px-3 py-2 rounded-lg border border-surface1 transition-colors text-sm', className = 'btn btn--ghost',
label = 'Assets', label = 'Assets',
iconSize = 14,
}: Props) { }: Props) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -31,8 +33,8 @@ export default function AssetsButton({
<button type="button" onClick={() => setOpen(true)} className={className}> <button type="button" onClick={() => setOpen(true)} className={className}>
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="14" width={iconSize}
height="14" height={iconSize}
viewBox="0 0 24 24" viewBox="0 0 24 24"
fill="none" fill="none"
stroke="currentColor" stroke="currentColor"
@@ -56,12 +58,13 @@ export default function AssetsButton({
aria-label="Asset library" aria-label="Asset library"
onClick={() => setOpen(false)} onClick={() => setOpen(false)}
> >
<div className="absolute inset-0 bg-crust/80 backdrop-blur-md" aria-hidden="true" /> <div className="absolute inset-0 bg-[var(--crust)]/80 backdrop-blur-md" aria-hidden="true" />
<div <div
className="relative w-full max-w-5xl max-h-[90vh] bg-mantle border border-surface1 rounded-2xl shadow-2xl overflow-hidden flex flex-col animate-in fade-in slide-in-from-bottom-4 duration-200" className="relative w-full max-w-5xl max-h-[90vh] bg-[var(--base)] border border-[var(--surface2)] shadow-2xl overflow-hidden flex flex-col animate-in fade-in slide-in-from-bottom-4 duration-200"
style={{ borderRadius: 2 }}
onClick={e => e.stopPropagation()} onClick={e => e.stopPropagation()}
> >
<div className="flex items-center justify-between px-5 py-4 border-b border-surface1"> <div className="flex items-center justify-between px-5 py-4 border-b border-[var(--surface2)]/60">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -73,20 +76,20 @@ export default function AssetsButton({
strokeWidth="2" strokeWidth="2"
strokeLinecap="round" strokeLinecap="round"
strokeLinejoin="round" strokeLinejoin="round"
className="text-mauve" className="text-[var(--mauve)]"
aria-hidden="true" aria-hidden="true"
> >
<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /> <rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
<circle cx="9" cy="9" r="2" /> <circle cx="9" cy="9" r="2" />
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" /> <path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />
</svg> </svg>
<h2 className="text-lg font-semibold text-lavender">Asset Library</h2> <h2 className="font-display italic text-xl text-[var(--text)]">Asset Library</h2>
</div> </div>
<button <button
type="button" type="button"
onClick={() => setOpen(false)} onClick={() => setOpen(false)}
aria-label="Close" aria-label="Close"
className="p-1.5 rounded-md text-subtext0 hover:text-text hover:bg-surface0 transition-colors" className="btn btn--ghost btn--icon btn--sm"
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -0,0 +1,178 @@
import { useEffect, useRef, useState } from 'react';
import { submitContact, ApiError } from '../../lib/api';
type Status = 'idle' | 'sending' | 'sent' | 'error';
export default function ContactForm() {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [subject, setSubject] = useState('');
const [message, setMessage] = useState('');
const [website, setWebsite] = useState('');
const [status, setStatus] = useState<Status>('idle');
const [errorMsg, setErrorMsg] = useState('');
const startedAt = useRef<number>(Date.now());
useEffect(() => {
startedAt.current = Date.now();
}, []);
async function handleSubmit(e: React.SyntheticEvent) {
e.preventDefault();
if (status === 'sending') return;
if (!message.trim()) {
setStatus('error');
setErrorMsg('Please write a message before sending.');
return;
}
setStatus('sending');
setErrorMsg('');
try {
await submitContact({
name: name.trim() || undefined,
email: email.trim() || undefined,
subject: subject.trim() || undefined,
message: message.trim(),
website,
started_at: startedAt.current,
});
setStatus('sent');
setName('');
setEmail('');
setSubject('');
setMessage('');
setWebsite('');
} catch (err) {
setStatus('error');
if (err instanceof ApiError) {
setErrorMsg(err.message || 'Something went wrong. Please try again.');
} else {
setErrorMsg('Could not reach the server. Please try again.');
}
}
}
if (status === 'sent') {
return (
<div
className="glass p-8 text-center"
role="status"
aria-live="polite"
>
<div className="font-display italic text-[var(--green)] text-xs tracking-[0.3em] uppercase mb-3">
Delivered
</div>
<p className="font-display italic text-[var(--text)] text-xl md:text-2xl mb-4">
Your message is on its way.
</p>
<p className="font-sans text-sm text-[var(--subtext1)] mb-6">
Thank you for writing in. A reply will follow when time allows.
</p>
<button
type="button"
onClick={() => {
setStatus('idle');
startedAt.current = Date.now();
}}
className="chip chip-accent uppercase"
>
Send another
</button>
</div>
);
}
return (
<form onSubmit={handleSubmit} className="space-y-6" noValidate>
<div
aria-hidden="true"
style={{ position: 'absolute', left: '-10000px', top: 'auto', width: '1px', height: '1px', overflow: 'hidden' }}
>
<label>
Website (leave empty)
<input
type="text"
tabIndex={-1}
autoComplete="off"
value={website}
onChange={e => setWebsite(e.target.value)}
/>
</label>
</div>
{status === 'error' && (
<div
className="p-4 text-sm font-display italic text-center border bg-[var(--red)]/15 text-[var(--red)] border-[var(--red)]/30"
style={{ borderRadius: 1 }}
role="alert"
>
{errorMsg}
</div>
)}
<div className="grid md:grid-cols-2 gap-6">
<div>
<label className="field-label" htmlFor="contact-name">Name <span className="text-[var(--subtext0)] italic normal-case tracking-normal">(optional)</span></label>
<input
id="contact-name"
type="text"
value={name}
onChange={e => setName(e.target.value)}
className="field-input"
autoComplete="name"
maxLength={200}
/>
</div>
<div>
<label className="field-label" htmlFor="contact-email">Email <span className="text-[var(--subtext0)] italic normal-case tracking-normal">(for a reply)</span></label>
<input
id="contact-email"
type="email"
value={email}
onChange={e => setEmail(e.target.value)}
className="field-input"
autoComplete="email"
maxLength={200}
/>
</div>
</div>
<div>
<label className="field-label" htmlFor="contact-subject">Subject <span className="text-[var(--subtext0)] italic normal-case tracking-normal">(optional)</span></label>
<input
id="contact-subject"
type="text"
value={subject}
onChange={e => setSubject(e.target.value)}
className="field-input"
maxLength={300}
/>
</div>
<div>
<label className="field-label" htmlFor="contact-message">Message</label>
<textarea
id="contact-message"
value={message}
onChange={e => setMessage(e.target.value)}
rows={7}
className="field-input"
required
maxLength={10000}
placeholder="What's on your mind?"
/>
<p className="text-[10px] font-display italic text-[var(--subtext0)] mt-2 tracking-wider">
{message.length} / 10000
</p>
</div>
<button
type="submit"
disabled={status === 'sending'}
className="btn btn--primary"
>
{status === 'sending' ? 'Sending…' : 'Send message'}
</button>
</form>
);
}
@@ -1,24 +1,34 @@
import { useState } from 'react'; import { useState } from 'react';
import { deletePost } from '../../lib/api'; import { deletePost } from '../../lib/api';
import { confirmDialog, notify } from '../../lib/confirm';
import { type SiteMode, copy } from '../../lib/siteMode';
interface Props { interface Props {
slug: string; slug: string;
title: string; title: string;
variant?: 'icon' | 'full'; variant?: 'icon' | 'full';
mode?: SiteMode;
} }
export default function DeletePostButton({ slug, title, variant = 'full' }: Props) { export default function DeletePostButton({ slug, title, variant = 'full', mode = 'atelier' }: Props) {
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
const c = copy(mode);
async function handleClick() { async function handleClick() {
if (busy) return; if (busy) return;
if (!window.confirm(`Delete "${title}"? This cannot be undone.`)) return; const ok = await confirmDialog({
title: c.deletePostTitle,
message: c.deletePostMsg(title),
confirmLabel: 'Delete',
cancelLabel: 'Cancel',
});
if (!ok) return;
setBusy(true); setBusy(true);
try { try {
await deletePost(slug); await deletePost(slug);
window.location.href = '/'; window.location.href = '/';
} catch (e) { } catch (e) {
window.alert(`Failed to delete: ${e instanceof Error ? e.message : 'unknown error'}`); notify(`Failed to delete: ${e instanceof Error ? e.message : 'unknown error'}`);
setBusy(false); setBusy(false);
} }
} }
@@ -31,7 +41,7 @@ export default function DeletePostButton({ slug, title, variant = 'full' }: Prop
disabled={busy} disabled={busy}
title="Delete post" title="Delete post"
aria-label="Delete post" aria-label="Delete post"
className="p-2 rounded-md bg-surface0/80 hover:bg-red/20 text-subtext0 hover:text-red border border-surface1 transition-colors disabled:opacity-50" className="btn btn--danger btn--icon btn--sm"
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -60,7 +70,7 @@ export default function DeletePostButton({ slug, title, variant = 'full' }: Prop
type="button" type="button"
onClick={handleClick} onClick={handleClick}
disabled={busy} disabled={busy}
className="inline-flex items-center gap-2 bg-surface0 hover:bg-red/15 text-subtext1 hover:text-red px-3 py-1.5 md:px-4 md:py-2 rounded-md border border-surface1 hover:border-red/30 transition-colors text-sm disabled:opacity-50" className="btn btn--danger"
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -22,12 +22,10 @@ export default function LogoutButton() {
disabled={busy} disabled={busy}
title="Sign out" title="Sign out"
aria-label="Sign out" aria-label="Sign out"
className="text-subtext0 hover:text-red transition-colors p-1.5 rounded-md hover:bg-surface0/60 disabled:opacity-50" className="topbar-control topbar-control--danger tc-collapse-sm"
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24" viewBox="0 0 24 24"
fill="none" fill="none"
stroke="currentColor" stroke="currentColor"
@@ -40,6 +38,7 @@ export default function LogoutButton() {
<polyline points="16 17 21 12 16 7" /> <polyline points="16 17 21 12 16 7" />
<line x1="21" x2="9" y1="12" y2="12" /> <line x1="21" x2="9" y1="12" y2="12" />
</svg> </svg>
<span className="tc-label">{busy ? 'Signing out…' : 'Sign out'}</span>
</button> </button>
); );
} }
+386 -142
View File
@@ -1,11 +1,36 @@
import { useEffect, useRef, useState } from 'react'; import { useEffect, useLayoutEffect, useRef, useState } from 'react';
// useLayoutEffect warns when React renders this island on the server; the
// measurement only matters on the client anyway.
const useIsoLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
import { deletePost } from '../../lib/api'; import { deletePost } from '../../lib/api';
import { confirmDialog, notify } from '../../lib/confirm';
import { buildCybersigil } from '../../lib/cybersigil';
import { type SiteMode, copy } from '../../lib/siteMode';
// Per-plate sigil accent. Built post-mount (not during render) so the random
// markup never differs between SSR and hydration. Inert/display:none off the
// cybersigil theme; carves over the image on plate hover/focus via global.css.
function PlateSigil() {
const [html, setHtml] = useState('');
useEffect(() => { setHtml(buildCybersigil()); }, []);
if (!html) return null;
return (
<div
className="cs-plate-sig"
aria-hidden="true"
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}
const PAGE_SIZE = 9; const PAGE_SIZE = 9;
interface CoverImage { interface CoverImage {
url: string; url: string;
alt: string; alt: string;
w?: number;
h?: number;
} }
interface Post { interface Post {
@@ -24,6 +49,7 @@ interface Post {
interface Props { interface Props {
posts: Post[]; posts: Post[];
isAdmin?: boolean; isAdmin?: boolean;
mode?: SiteMode;
} }
function formatSlug(slug: string) { function formatSlug(slug: string) {
@@ -42,48 +68,116 @@ function formatMonth(date: string) {
return new Date(date).toLocaleDateString('en-US', { month: 'short' }).toUpperCase(); return new Date(date).toLocaleDateString('en-US', { month: 'short' }).toUpperCase();
} }
function toRoman(n: number): string { // Blog rows want a human date, not the gallery's terse MONTH / YEAR split.
const map: [number, string][] = [ function formatLongDate(date: string) {
[1000, 'M'], [900, 'CM'], [500, 'D'], [400, 'CD'], return new Date(date).toLocaleDateString('en-US', {
[100, 'C'], [90, 'XC'], [50, 'L'], [40, 'XL'], day: 'numeric',
[10, 'X'], [9, 'IX'], [5, 'V'], [4, 'IV'], [1, 'I'], month: 'long',
]; year: 'numeric',
let out = ''; });
for (const [val, sym] of map) {
while (n >= val) { out += sym; n -= val; }
}
return out;
} }
// Deterministic salon-hang layout. Each tile gets a col-span (out of 12) and an aspect ratio. // ── Justified-gallery layout ────────────────────────────────────────────────
// The cycle is chosen so the room reads asymmetric but balanced. // Every cover keeps its true aspect ratio (no crop). Tiles are packed left to
const LAYOUT_CYCLE: Array<{ col: number; aspect: string; tilt: number }> = [ // right; once a tentative row is at least as wide as the container it is
{ col: 7, aspect: '4 / 3', tilt: -0.4 }, // finalized and its height solved so the row fills the width exactly. The
{ col: 5, aspect: '3 / 4', tilt: 0.3 }, // trailing partial row stays at the target height (left-aligned), only shrunk
{ col: 4, aspect: '4 / 5', tilt: -0.2 }, // if a lone wide image would overflow. Result: variable widths, one shared
{ col: 4, aspect: '1 / 1', tilt: 0.5 }, // image height per visual row, no wasted space.
{ col: 4, aspect: '4 / 5', tilt: -0.6 },
{ col: 5, aspect: '1 / 1', tilt: 0.2 },
{ col: 7, aspect: '5 / 4', tilt: -0.3 },
{ col: 8, aspect: '16 / 10', tilt: 0.4 },
{ col: 4, aspect: '3 / 4', tilt: -0.5 },
];
export default function PostList({ posts: initialPosts, isAdmin = false }: Props) { const GAP = 18; // horizontal gap between tiles in a row (px)
const ROW_GAP = 40; // vertical gap between rows (px)
const MIN_H = 150; // floor so a wide-only row never collapses
// Covers with no usable dimensions (or no cover at all) cycle through a set of
// pleasant ratios so the placeholder tiles still read as an arranged hang.
const FALLBACK_RATIOS = [1.5, 0.78, 1, 1.33, 0.8, 1.6, 0.9];
function aspectOf(post: Post, idx: number): number {
const ci = post.cover_image;
if (ci && ci.w && ci.h && ci.w > 0 && ci.h > 0) {
const r = ci.w / ci.h;
if (Number.isFinite(r) && r > 0) return r;
}
return FALLBACK_RATIOS[idx % FALLBACK_RATIOS.length];
}
function targetRowHeight(cw: number): number {
if (cw < 560) return Math.round(cw * 0.72);
if (cw < 900) return 260;
if (cw < 1280) return 300;
return 340;
}
interface Cell { post: Post; idx: number; aspect: number; w: number; h: number }
function buildRows(
tiles: Array<{ post: Post; idx: number; aspect: number }>,
cw: number,
targetH: number,
chromeX: number,
): Cell[][] {
const rows: Cell[][] = [];
let cur: typeof tiles = [];
let aspSum = 0;
const finalize = (items: typeof tiles, h: number) => {
const rh = Math.round(Math.max(MIN_H, h));
rows.push(
items.map(t => ({ ...t, w: Math.round(t.aspect * rh), h: rh })),
);
};
for (const t of tiles) {
cur = [...cur, t];
aspSum += t.aspect;
const k = cur.length;
const projected = targetH * aspSum + k * chromeX + (k - 1) * GAP;
if (projected >= cw) {
const avail = cw - k * chromeX - (k - 1) * GAP;
const h = Math.min(avail / aspSum, targetH * 1.5);
finalize(cur, h);
cur = [];
aspSum = 0;
}
}
if (cur.length) {
const k = cur.length;
const projected = targetH * aspSum + k * chromeX + (k - 1) * GAP;
let h = targetH;
if (projected > cw) h = (cw - k * chromeX - (k - 1) * GAP) / aspSum;
finalize(cur, Math.min(h, targetH * 1.5));
}
return rows;
}
export default function PostList({ posts: initialPosts, isAdmin = false, mode = 'atelier' }: Props) {
const isBlog = mode === 'blog';
const c = copy(mode);
const [posts, setPosts] = useState(initialPosts); const [posts, setPosts] = useState(initialPosts);
const [deleting, setDeleting] = useState<string | null>(null); const [deleting, setDeleting] = useState<string | null>(null);
const [visible, setVisible] = useState(() => Math.min(PAGE_SIZE, initialPosts.length)); const [visible, setVisible] = useState(() => Math.min(PAGE_SIZE, initialPosts.length));
const sentinelRef = useRef<HTMLDivElement>(null); const sentinelRef = useRef<HTMLDivElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
// null until measured on the client — keeps SSR and first hydration render
// identical (CSS-only fallback), then the precise layout swaps in.
const [rows, setRows] = useState<Cell[][] | null>(null);
const [chrome, setChrome] = useState(30); // plate mat+border width (px)
async function handleDelete(slug: string, title: string) { async function handleDelete(slug: string, title: string) {
if (deleting) return; if (deleting) return;
if (!window.confirm(`Take "${title}" off the wall? This cannot be undone.`)) return; const ok = await confirmDialog({
title: c.deleteListTitle,
message: c.deleteListMsg(title),
confirmLabel: c.deleteListConfirm,
cancelLabel: c.deleteListCancel,
});
if (!ok) return;
setDeleting(slug); setDeleting(slug);
try { try {
await deletePost(slug); await deletePost(slug);
setPosts(p => p.filter(x => x.slug !== slug)); setPosts(p => p.filter(x => x.slug !== slug));
} catch (e) { } catch (e) {
window.alert(`Failed to remove: ${e instanceof Error ? e.message : 'unknown error'}`); notify(`Failed to delete: ${e instanceof Error ? e.message : 'unknown error'}`);
} finally { } finally {
setDeleting(null); setDeleting(null);
} }
@@ -109,139 +203,289 @@ export default function PostList({ posts: initialPosts, isAdmin = false }: Props
return () => io.disconnect(); return () => io.disconnect();
}, [visible, posts.length]); }, [visible, posts.length]);
if (posts.length === 0) {
return null;
}
const shown = posts.slice(0, visible); const shown = posts.slice(0, visible);
const hasMore = visible < posts.length; const hasMore = visible < posts.length;
return ( // Measure the container + plate chrome and (re)compute the justified rows.
<> // Re-runs on resize and whenever the shown set changes (infinite scroll).
<div className="grid grid-cols-1 md:grid-cols-12 gap-8 md:gap-x-10 md:gap-y-16"> useIsoLayoutEffect(() => {
{shown.map((post, idx) => { if (isBlog) return; // blog mode renders a plain stack — no justified math
const displayTitle = post.title || formatSlug(post.slug); const container = containerRef.current;
const isDeleting = deleting === post.slug; if (!container) return;
const layout = LAYOUT_CYCLE[idx % LAYOUT_CYCLE.length];
const exhibitNumber = toRoman(idx + 1);
const hasCover = !!post.cover_image?.url;
return ( let frame = 0;
<article const measure = () => {
key={post.slug} const cw = container.clientWidth;
className={`relative plate-enter md-col-span ${isDeleting ? 'opacity-40 pointer-events-none' : ''}`} if (cw <= 0) return;
style={{ // Mat + border are fixed px regardless of tile size — read once from a
animationDelay: `${Math.min(idx * 80, 480)}ms`, // live plate so the row-fill math is exact for whatever theme is on.
['--col-span' as any]: layout.col, let chromeX = 30;
}} const plate = container.querySelector<HTMLElement>('.plate');
> if (plate) {
<a const cs = getComputedStyle(plate);
href={`/posts/${encodeURIComponent(post.slug)}`} chromeX =
className="block plate group" parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight) +
style={{ transform: `rotate(${layout.tilt}deg)` }} parseFloat(cs.borderLeftWidth) + parseFloat(cs.borderRightWidth);
aria-label={`View ${displayTitle}`} if (!Number.isFinite(chromeX)) chromeX = 30;
> }
<span className="plate-tag"> {exhibitNumber}</span> setChrome(chromeX);
const tiles = shown.map((post, idx) => ({ post, idx, aspect: aspectOf(post, idx) }));
setRows(buildRows(tiles, cw, targetRowHeight(cw), chromeX));
};
const schedule = () => {
cancelAnimationFrame(frame);
frame = requestAnimationFrame(measure);
};
measure();
const ro = new ResizeObserver(schedule);
ro.observe(container);
return () => {
cancelAnimationFrame(frame);
ro.disconnect();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible, posts]);
if (posts.length === 0) return null;
let cellIdx = 0; // running stagger index across all rows
const renderCell = (cell: Cell | null, post: Post, idx: number) => {
const displayTitle = post.title || formatSlug(post.slug);
const isDeleting = deleting === post.slug;
const hasCover = !!post.cover_image?.url;
const stagger = Math.min(cellIdx++ * 70, 480);
// Precise layout: tile sized to outer (image + mat) width with flex-grow so
// sub-pixel rounding redistributes and the row fills the width exactly —
// no crop, no wrap. Fallback (pre-measure / no JS): grow proportional to
// aspect so it still reads as a justified hang.
const aspect = cell ? cell.aspect : aspectOf(post, idx);
const ow = cell ? cell.w + chrome : 0;
const articleStyle: React.CSSProperties = cell
? { flex: `${ow} ${ow} ${ow}px`, minWidth: 0, animationDelay: `${stagger}ms` }
: { flex: `${aspect.toFixed(4)} 1 ${Math.round(aspect * 220)}px`, animationDelay: `${stagger}ms` };
const imageStyle: React.CSSProperties = cell
? { height: `${cell.h}px` }
: { aspectRatio: `${aspect}` };
return (
<article
key={post.slug}
className={`relative plate-enter ${isDeleting ? 'opacity-40 pointer-events-none' : ''}`}
style={articleStyle}
>
<a
href={`/posts/${encodeURIComponent(post.slug)}`}
className="block plate group"
aria-label={`View ${displayTitle}`}
>
<div className="plate-image" style={imageStyle}>
{hasCover ? (
<img
src={post.cover_image!.url}
alt={post.cover_image!.alt || displayTitle}
width={post.cover_image!.w}
height={post.cover_image!.h}
loading={idx < 3 ? 'eager' : 'lazy'}
decoding={idx === 0 ? 'sync' : 'async'}
fetchPriority={idx === 0 ? 'high' : undefined}
/>
) : (
<div <div
className="plate-image" className="w-full h-full flex items-center justify-center text-[var(--rosewater)]"
style={{ aspectRatio: layout.aspect }} style={{ background: `linear-gradient(135deg, var(--mauve), var(--mantle))` }}
> >
{hasCover ? ( <span className="font-display italic text-3xl opacity-70">untitled</span>
<img
src={post.cover_image!.url}
alt={post.cover_image!.alt || displayTitle}
loading={idx < 3 ? 'eager' : 'lazy'}
/>
) : (
<div
className="w-full h-full flex items-center justify-center text-[var(--rosewater)]"
style={{
background: `linear-gradient(135deg, var(--mauve), var(--mantle))`,
}}
>
<span className="font-display italic text-3xl opacity-70">
untitled
</span>
</div>
)}
{post.image_count > 1 && (
<span className="plate-tag-mini">
{post.image_count} plates
</span>
)}
{post.draft && (
<span className="plate-tag-mini" style={{ left: 18, right: 'auto', background: 'var(--peach)', color: 'var(--crust)' }}>
Sketch
</span>
)}
</div> </div>
)}
{post.image_count > 1 && (
<span className="plate-tag-mini">{post.image_count} plates</span>
)}
{post.draft && (
<span className="plate-tag-mini plate-tag-mini--draft">Sketch</span>
)}
<PlateSigil />
</div>
<div className="plate-caption"> <div className="plate-caption">
<div className="min-w-0"> <div className="plate-caption-title">{displayTitle}</div>
<div className="plate-caption-title truncate">{displayTitle}</div> {post.summary && (
{post.summary && ( <div className="plate-caption-summary">{post.summary}</div>
<div className="mt-1 text-xs text-[var(--subtext0)] font-sans italic line-clamp-1"> )}
{post.summary} <div className="plate-caption-meta">
</div> <span>{formatMonth(post.date)}</span>
)} <span className="plate-caption-sep" aria-hidden="true">·</span>
</div> <span>{formatYear(post.date)}</span>
<div className="plate-caption-meta"> </div>
<span>{formatMonth(post.date)}</span> </div>
<span className="opacity-50 mx-1">·</span> </a>
<span>{formatYear(post.date)}</span>
</div> {post.tags && post.tags.length > 0 && (
</div> <div className="flex flex-wrap gap-1.5 mt-3 px-1">
{post.tags.slice(0, 4).map(tag => (
<span key={tag} className="chip">{tag}</span>
))}
</div>
)}
{isAdmin && (
<div className="absolute top-3 right-3 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity">
<a
href={`/admin/editor?edit=${encodeURIComponent(post.slug)}`}
onClick={e => e.stopPropagation()}
title="Edit"
aria-label={`Edit ${displayTitle}`}
className="btn btn--ghost btn--icon btn--sm"
>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" /><path d="m15 5 4 4" /></svg>
</a> </a>
<button
type="button"
onClick={e => { e.preventDefault(); e.stopPropagation(); handleDelete(post.slug, displayTitle); }}
disabled={isDeleting}
title="Remove"
aria-label={`Remove ${displayTitle}`}
className="btn btn--danger btn--icon btn--sm"
>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h18" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><line x1="10" x2="10" y1="11" y2="17" /><line x1="14" x2="14" y1="11" y2="17" /></svg>
</button>
</div>
)}
</article>
);
};
// ── Blog mode: one writing-first row per post ──────────────────────────
const renderRow = (post: Post, idx: number) => {
const displayTitle = post.title || formatSlug(post.slug);
const isDeleting = deleting === post.slug;
const hasCover = !!post.cover_image?.url;
const blurb = post.summary || post.excerpt;
const stagger = Math.min(idx * 55, 420);
return (
<article
key={post.slug}
className={`post-row plate-enter ${isDeleting ? 'opacity-40 pointer-events-none' : ''}`}
style={{ animationDelay: `${stagger}ms` }}
>
<a
href={`/posts/${encodeURIComponent(post.slug)}`}
className="post-row-link group"
aria-label={`Read ${displayTitle}`}
>
<div className="post-row-body">
<h2 className="post-row-title">{displayTitle}</h2>
<div className="post-row-meta">
<span>{formatLongDate(post.date)}</span>
<span className="sep" aria-hidden="true">·</span>
<span>{post.reading_time} min read</span>
{post.draft && (
<span className="chip chip-draft post-row-draft">{c.draftShort}</span>
)}
</div>
{blurb && <p className="post-row-excerpt">{blurb}</p>}
{post.tags && post.tags.length > 0 && ( {post.tags && post.tags.length > 0 && (
<div className="flex flex-wrap gap-1.5 mt-3 px-1"> <div className="post-row-tags">
{post.tags.slice(0, 4).map(tag => ( {post.tags.slice(0, 4).map(tag => (
<span key={tag} className="chip"> <span key={tag} className="chip">{tag}</span>
{tag}
</span>
))} ))}
</div> </div>
)} )}
</div>
{isAdmin && ( {hasCover && (
<div className="absolute top-3 right-3 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity"> <div className="post-row-thumb">
<a <img
href={`/admin/editor?edit=${encodeURIComponent(post.slug)}`} src={post.cover_image!.url}
onClick={e => e.stopPropagation()} alt={post.cover_image!.alt || displayTitle}
title="Edit" width={post.cover_image!.w}
aria-label={`Edit ${displayTitle}`} height={post.cover_image!.h}
className="p-1.5 bg-[var(--mantle)] text-[var(--rosewater)] hover:bg-[var(--blue)] border border-[var(--surface2)] transition-colors" loading={idx < 4 ? 'eager' : 'lazy'}
style={{ borderRadius: 1 }} decoding="async"
> />
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" /><path d="m15 5 4 4" /></svg> <PlateSigil />
</a> </div>
<button )}
type="button" </a>
onClick={e => { e.preventDefault(); e.stopPropagation(); handleDelete(post.slug, displayTitle); }}
disabled={isDeleting} {isAdmin && (
title="Remove" <div className="absolute top-3 right-3 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity">
aria-label={`Remove ${displayTitle}`} <a
className="p-1.5 bg-[var(--mantle)] text-[var(--rosewater)] hover:bg-[var(--red)] border border-[var(--surface2)] transition-colors disabled:opacity-50" href={`/admin/editor?edit=${encodeURIComponent(post.slug)}`}
style={{ borderRadius: 1 }} onClick={e => e.stopPropagation()}
> title="Edit"
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h18" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><line x1="10" x2="10" y1="11" y2="17" /><line x1="14" x2="14" y1="11" y2="17" /></svg> aria-label={`Edit ${displayTitle}`}
</button> className="btn btn--ghost btn--icon btn--sm"
>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" /><path d="m15 5 4 4" /></svg>
</a>
<button
type="button"
onClick={e => { e.preventDefault(); e.stopPropagation(); handleDelete(post.slug, displayTitle); }}
disabled={isDeleting}
title="Delete"
aria-label={`Delete ${displayTitle}`}
className="btn btn--danger btn--icon btn--sm"
>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h18" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><line x1="10" x2="10" y1="11" y2="17" /><line x1="14" x2="14" y1="11" y2="17" /></svg>
</button>
</div>
)}
</article>
);
};
if (isBlog) {
return (
<>
<div className="post-list">
{shown.map((post, idx) => renderRow(post, idx))}
</div>
{hasMore && (
<div
ref={sentinelRef}
className="mt-12 md:mt-16 flex items-center justify-center text-[var(--subtext0)] font-display italic text-sm tracking-[0.2em] uppercase"
aria-hidden="true"
>
<span className="opacity-60">{c.loadingMore}</span>
</div>
)}
</>
);
}
return (
<>
<div ref={containerRef} className="just-gallery">
{rows
? rows.map((row, r) => (
<div
className="just-row"
key={r}
style={{ marginBottom: r === rows.length - 1 ? 0 : ROW_GAP }}
>
{row.map(cell => renderCell(cell, cell.post, cell.idx))}
</div> </div>
)} ))
</article> : (
); <div className="just-row just-row--fallback">
})} {shown.map((post, idx) => renderCell(null, post, idx))}
</div> </div>
{hasMore && ( )}
<div
ref={sentinelRef}
className="mt-12 md:mt-16 flex items-center justify-center text-[var(--subtext0)] font-display italic text-sm tracking-[0.2em] uppercase"
aria-hidden="true"
>
<span className="opacity-60">arranging more</span>
</div> </div>
)} {hasMore && (
<div
ref={sentinelRef}
className="mt-12 md:mt-16 flex items-center justify-center text-[var(--subtext0)] font-display italic text-sm tracking-[0.2em] uppercase"
aria-hidden="true"
>
<span className="opacity-60">{c.loadingMore}</span>
</div>
)}
</> </>
); );
} }
+31 -26
View File
@@ -1,5 +1,6 @@
import { useEffect, useMemo, useRef, useState } from 'react'; import { useEffect, useMemo, useRef, useState } from 'react';
import { getPosts } from '../../lib/api'; import { getPosts } from '../../lib/api';
import { type SiteMode, copy } from '../../lib/siteMode';
interface Post { interface Post {
slug: string; slug: string;
@@ -27,7 +28,8 @@ function formatDate(date: string) {
}); });
} }
export default function Search() { export default function Search({ mode = 'atelier' }: { mode?: SiteMode }) {
const c = copy(mode);
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [query, setQuery] = useState(''); const [query, setQuery] = useState('');
const [posts, setPosts] = useState<Post[] | null>(null); const [posts, setPosts] = useState<Post[] | null>(null);
@@ -128,15 +130,11 @@ export default function Search() {
<button <button
type="button" type="button"
onClick={() => setOpen(true)} onClick={() => setOpen(true)}
aria-label={`Search the catalogue (${isMac ? '⌘' : 'Ctrl'}+K)`} aria-label={`${c.searchAria} (${isMac ? '⌘' : 'Ctrl'}+K)`}
title={`Search (${isMac ? '⌘' : 'Ctrl'}+K)`} className="topbar-control tc-collapse-md kbd-tip-host"
className="text-[var(--subtext0)] hover:text-[var(--mauve)] transition-colors flex items-center gap-2 px-2 py-1 hover:bg-[var(--surface0)]/60 font-display italic"
style={{ borderRadius: 1 }}
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24" viewBox="0 0 24 24"
fill="none" fill="none"
stroke="currentColor" stroke="currentColor"
@@ -148,32 +146,34 @@ export default function Search() {
<circle cx="11" cy="11" r="8" /> <circle cx="11" cy="11" r="8" />
<path d="m21 21-4.3-4.3" /> <path d="m21 21-4.3-4.3" />
</svg> </svg>
<kbd className="hidden md:inline-flex items-center gap-1 text-[10px] font-mono text-[var(--subtext0)] px-1.5 py-0.5 border border-[var(--surface2)] bg-[var(--surface0)]/60" style={{ borderRadius: 1 }}> <span className="tc-label">Search</span>
<span>{isMac ? '⌘' : 'Ctrl'}</span><span className="opacity-50">+</span><span>K</span> <span className="kbd-tip" aria-hidden="true">
</kbd> <kbd>{isMac ? '⌘' : 'Ctrl'}</kbd>
<kbd>K</kbd>
</span>
</button> </button>
{open && ( {open && (
<div <div
className="fixed inset-0 z-[200] flex items-start justify-center pt-[10vh] md:pt-[15vh] px-4" className="search-overlay fixed inset-0 z-[200] flex items-start justify-center pt-[10vh] md:pt-[15vh] px-4"
role="dialog" role="dialog"
aria-modal="true" aria-modal="true"
aria-label="Search the catalogue" aria-label={c.searchAria}
onClick={() => setOpen(false)} onClick={() => setOpen(false)}
> >
<div <div
className="absolute inset-0 bg-[var(--crust)]/55 backdrop-blur-md" className="search-backdrop absolute inset-0 bg-[var(--crust)]/55 backdrop-blur-md"
aria-hidden="true" aria-hidden="true"
/> />
<div <div
className="relative w-full max-w-xl bg-[var(--base)] text-[var(--text)] border border-[var(--surface2)] overflow-hidden flex flex-col max-h-[70vh] animate-in fade-in slide-in-from-top-4 duration-200" className="search-panel relative w-full max-w-xl bg-[var(--base)] text-[var(--text)] border border-[var(--surface2)] overflow-hidden flex flex-col max-h-[70vh] animate-in fade-in slide-in-from-top-4 duration-200"
style={{ style={{
borderRadius: 2, borderRadius: 2,
boxShadow: '0 30px 60px -20px rgba(20,16,12,0.55), 0 8px 20px -8px rgba(20,16,12,0.3), inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent)', boxShadow: '0 30px 60px -20px rgba(0,0,0,0.55), 0 8px 20px -8px rgba(0,0,0,0.3), inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent)',
}} }}
onClick={e => e.stopPropagation()} onClick={e => e.stopPropagation()}
> >
<div className="flex items-center gap-3 px-4 py-3 border-b border-[var(--surface2)]/60 bg-[var(--surface0)]/40"> <div className="search-bar flex items-center gap-3 px-4 py-3 border-b border-[var(--surface2)]/60 bg-[var(--surface0)]/40">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="18" width="18"
@@ -196,9 +196,9 @@ export default function Search() {
value={query} value={query}
onChange={e => setQuery(e.target.value)} onChange={e => setQuery(e.target.value)}
onKeyDown={onInputKey} onKeyDown={onInputKey}
placeholder="Search the catalogue…" placeholder={`${c.searchPlaceholder}`}
aria-label="Search query" aria-label="Search query"
className="flex-1 bg-transparent outline-none text-base text-[var(--text)] placeholder:text-[var(--subtext0)] font-display italic" className="search-input flex-1 bg-transparent outline-none text-base text-[var(--text)] placeholder:text-[var(--subtext0)] font-display italic"
/> />
<kbd className="text-[10px] font-mono text-[var(--subtext0)] px-1.5 py-0.5 border border-[var(--surface2)] bg-[var(--surface0)]/60" style={{ borderRadius: 1 }}> <kbd className="text-[10px] font-mono text-[var(--subtext0)] px-1.5 py-0.5 border border-[var(--surface2)] bg-[var(--surface0)]/60" style={{ borderRadius: 1 }}>
Esc Esc
@@ -207,18 +207,18 @@ export default function Search() {
<div className="flex-1 overflow-y-auto"> <div className="flex-1 overflow-y-auto">
{loading && ( {loading && (
<div className="px-4 py-10 text-center font-display italic text-[var(--subtext0)]">Fetching the catalogue</div> <div className="px-4 py-10 text-center font-display italic text-[var(--subtext0)]">{c.searchFetching}</div>
)} )}
{error && ( {error && (
<div className="px-4 py-8 text-center text-sm text-[var(--red)] font-display italic">{error}</div> <div className="px-4 py-8 text-center text-sm text-[var(--red)] font-display italic">{error}</div>
)} )}
{!loading && !error && posts && results.length === 0 && ( {!loading && !error && posts && results.length === 0 && (
<div className="px-4 py-10 text-center font-display italic text-[var(--subtext0)]"> <div className="px-4 py-10 text-center font-display italic text-[var(--subtext0)]">
{query ? 'No works match.' : 'The catalogue is empty.'} {query ? c.searchNoMatch : c.searchEmpty}
</div> </div>
)} )}
{!loading && !error && results.length > 0 && ( {!loading && !error && results.length > 0 && (
<ul ref={listRef} className="py-1"> <ul ref={listRef} className="search-list py-1">
{results.map((p, i) => { {results.map((p, i) => {
const title = p.title || formatSlug(p.slug); const title = p.title || formatSlug(p.slug);
const active = i === activeIdx; const active = i === activeIdx;
@@ -227,15 +227,20 @@ export default function Search() {
key={p.slug} key={p.slug}
onMouseEnter={() => setActiveIdx(i)} onMouseEnter={() => setActiveIdx(i)}
onClick={() => navigate(p.slug)} onClick={() => navigate(p.slug)}
className={`px-4 py-3 cursor-pointer border-l-2 transition-colors ${ className={`search-result px-4 py-3 cursor-pointer border-l-2 transition-colors ${
active active
? 'bg-[var(--surface0)] border-[var(--mauve)]' ? 'search-result--active bg-[var(--surface0)] border-[var(--mauve)]'
: 'border-transparent hover:bg-[var(--surface0)]/60' : 'border-transparent hover:bg-[var(--surface0)]/60'
}`} }`}
> >
<div className="flex items-baseline justify-between gap-3"> <div className="flex items-baseline justify-between gap-3">
<div className={`font-display italic truncate text-lg leading-tight pr-2 ${active ? 'text-[var(--mauve)]' : 'text-[var(--text)]'}`} style={{ paddingInlineEnd: '0.35em' }}> <div className={`font-display italic truncate text-lg leading-tight pr-2 flex items-baseline gap-2 ${active ? 'text-[var(--mauve)]' : 'text-[var(--text)]'}`} style={{ paddingInlineEnd: '0.35em' }}>
{title} <span className="truncate">{title}</span>
{p.draft && (
<span className="chip chip-draft shrink-0 !text-[0.62rem] !py-0">
{c.draftShort}
</span>
)}
</div> </div>
<time className="text-[10px] font-sans uppercase tracking-[0.18em] text-[var(--subtext0)] shrink-0" dateTime={p.date}> <time className="text-[10px] font-sans uppercase tracking-[0.18em] text-[var(--subtext0)] shrink-0" dateTime={p.date}>
{formatDate(p.date)} {formatDate(p.date)}
@@ -251,7 +256,7 @@ export default function Search() {
)} )}
</div> </div>
<div className="flex items-center justify-between px-4 py-2 border-t border-[var(--surface2)]/60 text-[10px] text-[var(--subtext0)] bg-[var(--surface0)]/40 font-display italic"> <div className="search-foot flex items-center justify-between px-4 py-2 border-t border-[var(--surface2)]/60 text-[10px] text-[var(--subtext0)] bg-[var(--surface0)]/40 font-display italic">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<span className="flex items-center gap-1"> <span className="flex items-center gap-1">
<kbd className="font-mono px-1 border border-[var(--surface2)] bg-[var(--surface0)]/60 not-italic" style={{ borderRadius: 1 }}></kbd> <kbd className="font-mono px-1 border border-[var(--surface2)] bg-[var(--surface0)]/60 not-italic" style={{ borderRadius: 1 }}></kbd>
@@ -1,59 +0,0 @@
import { useState, useEffect, useRef } from 'react';
const THEMES = [
{ value: 'salon', label: 'Salon' },
{ value: 'salon-noir', label: 'Salon Noir' },
{ value: 'latte', label: 'Latte' },
{ value: 'mocha', label: 'Mocha' },
];
interface Props {
defaultTheme?: string;
}
export default function ThemeSwitcher({ defaultTheme = 'mocha' }: Props) {
const [theme, setTheme] = useState(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('user-theme') || defaultTheme;
}
return defaultTheme;
});
const [toast, setToast] = useState<string | null>(null);
const isFirst = useRef(true);
useEffect(() => {
const html = document.documentElement;
THEMES.forEach(t => html.classList.remove(t.value));
html.classList.add(theme);
localStorage.setItem('user-theme', theme);
if (isFirst.current) {
isFirst.current = false;
return;
}
const label = THEMES.find(t => t.value === theme)?.label ?? theme;
setToast(`Theme: ${label}`);
const id = setTimeout(() => setToast(null), 1200);
return () => clearTimeout(id);
}, [theme]);
return (
<div className="relative inline-block text-left">
<select
value={theme}
onChange={(e) => setTheme(e.target.value)}
aria-label="Theme"
className="appearance-none bg-[var(--surface0)]/60 text-[var(--text)] border border-[var(--surface2)] px-3 py-1.5 text-xs uppercase tracking-[0.18em] focus:outline-none focus:border-[var(--mauve)] transition-colors cursor-pointer hover:bg-[var(--surface0)] pr-8 font-display italic"
style={{ borderRadius: 1 }}
>
{THEMES.map(t => (
<option key={t.value} value={t.value}>{t.label}</option>
))}
</select>
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-[var(--subtext0)]">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m6 9 6 6 6-6"/></svg>
</div>
{toast && <div className="toast" role="status">{toast}</div>}
</div>
);
}
@@ -1,6 +1,7 @@
import { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { getAssets, uploadAsset, deleteAsset as deleteAssetApi, ApiError } from '../../../lib/api'; import { getAssets, uploadAsset, deleteAsset as deleteAssetApi, ApiError } from '../../../lib/api';
import type { Asset } from '../../../lib/types'; import type { Asset } from '../../../lib/types';
import { confirmDialog } from '../../../lib/confirm';
interface Props { interface Props {
mode?: 'manage' | 'select'; mode?: 'manage' | 'select';
@@ -42,7 +43,12 @@ export default function AssetManager({ mode = 'manage', onSelect }: Props) {
} }
async function handleDelete(name: string) { async function handleDelete(name: string) {
if (!confirm(`Delete "${name}" permanently?`)) return; const ok = await confirmDialog({
title: 'Delete asset?',
message: `${name}” will be permanently deleted. Posts referencing it will break.`,
confirmLabel: 'Delete',
});
if (!ok) return;
try { try {
await deleteAssetApi(name); await deleteAssetApi(name);
showAlert('File deleted.', 'success'); showAlert('File deleted.', 'success');
@@ -55,60 +61,75 @@ export default function AssetManager({ mode = 'manage', onSelect }: Props) {
const isImage = (name: string) => /\.(jpg|jpeg|png|webp|gif|svg)$/i.test(name); const isImage = (name: string) => /\.(jpg|jpeg|png|webp|gif|svg)$/i.test(name);
return ( return (
<div className="space-y-8"> <div className="asset-mgr space-y-8">
{alert && ( {alert && (
<div className={`p-4 rounded-lg mb-6 text-sm ${ <div
alert.type === 'success' ? 'bg-green/20 text-green border border-green/30' : 'bg-red/20 text-red border border-red/30' className={`asset-alert p-4 mb-6 text-sm font-display italic border ${
}`}> alert.type === 'success'
? 'asset-alert--ok bg-[color-mix(in_srgb,var(--green)_18%,transparent)] text-[var(--green)] border-[var(--green)]/40'
: 'asset-alert--err bg-[color-mix(in_srgb,var(--red)_18%,transparent)] text-[var(--red)] border-[var(--red)]/40'
}`}
style={{ borderRadius: 2 }}
>
{alert.msg} {alert.msg}
</div> </div>
)} )}
{/* Upload Zone */} {/* Upload Zone */}
<div <div
className="glass p-6 border-dashed border-2 border-surface1 hover:border-mauve transition-colors group relative cursor-pointer" className="asset-drop glass p-6 border-dashed border-2 border-[var(--surface2)] hover:border-[var(--mauve)] transition-colors group relative cursor-pointer"
onClick={() => fileRef.current?.click()} onClick={() => fileRef.current?.click()}
onDragOver={e => { e.preventDefault(); e.stopPropagation(); }} onDragOver={e => { e.preventDefault(); e.stopPropagation(); }}
onDrop={e => { e.preventDefault(); e.stopPropagation(); if (e.dataTransfer.files.length) handleUpload(e.dataTransfer.files); }} onDrop={e => { e.preventDefault(); e.stopPropagation(); if (e.dataTransfer.files.length) handleUpload(e.dataTransfer.files); }}
> >
<input ref={fileRef} type="file" multiple className="hidden" onChange={e => { if (e.target.files?.length) handleUpload(e.target.files); }} /> <input ref={fileRef} type="file" multiple className="hidden" onChange={e => { if (e.target.files?.length) handleUpload(e.target.files); }} />
<div className="text-center py-4"> <div className="asset-drop-body text-center py-4">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" className="mx-auto mb-4 text-subtext0 group-hover:text-mauve transition-colors"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" className="mx-auto mb-4 text-[var(--subtext0)] group-hover:text-[var(--mauve)] transition-colors"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>
<p className="text-lg font-bold text-lavender">Click or drag to upload assets</p> <p className="asset-drop-title font-display italic text-xl text-[var(--text)] group-hover:text-[var(--mauve)] transition-colors">Click or drag to upload assets</p>
<p className="text-xs text-subtext0 mt-1">Any file type up to 50MB</p> <p className="font-sans text-xs uppercase tracking-[0.2em] text-[var(--subtext0)] mt-2">Any file type · up to 50 MB</p>
</div> </div>
</div> </div>
{/* Grid */} {/* Grid */}
{assets.length === 0 ? ( {assets.length === 0 ? (
<div className="text-center py-20 text-subtext0">No assets uploaded yet.</div> <div className="asset-empty text-center py-20 font-display italic text-[var(--subtext0)]">No assets uploaded yet.</div>
) : ( ) : (
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4"> <div className="asset-grid grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4">
{assets.map(asset => ( {assets.map(asset => (
<div key={asset.name} className="group relative aspect-square bg-crust rounded-xl overflow-hidden border border-white/5 hover:border-mauve/40 transition-colors shadow-lg flex flex-col"> <div
<div className="flex-1 overflow-hidden bg-surface0/20 relative cursor-pointer"> key={asset.name}
className="asset-tile group relative aspect-square overflow-hidden bg-[var(--surface0)] border border-[var(--surface2)]/60 hover:border-[var(--mauve)]/60 transition-colors shadow-md flex flex-col"
style={{ borderRadius: 2 }}
>
<div className="asset-thumb flex-1 overflow-hidden bg-[var(--mantle)] relative cursor-pointer">
{isImage(asset.name) ? ( {isImage(asset.name) ? (
<img src={asset.url} className="w-full h-full object-cover opacity-80 group-hover:opacity-100 transition-opacity" alt={asset.name} /> <img src={asset.url} className="w-full h-full object-cover opacity-90 group-hover:opacity-100 transition-opacity" alt={asset.name} />
) : ( ) : (
<div className="flex flex-col items-center justify-center h-full text-subtext0"> <div className="flex flex-col items-center justify-center h-full text-[var(--subtext0)]">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="mb-2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="mb-2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>
<span className="text-[8px] font-mono px-2 truncate w-full text-center">{asset.name.split('.').pop()?.toUpperCase()}</span> <span className="text-[8px] font-mono px-2 truncate w-full text-center">{asset.name.split('.').pop()?.toUpperCase()}</span>
</div> </div>
)} )}
{/* Hover overlay */} {/* Hover overlay */}
<div className="absolute inset-0 bg-crust/70 backdrop-blur-sm opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-3"> <div className="asset-actions absolute inset-0 bg-[var(--crust)]/75 backdrop-blur-sm opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-3">
{mode === 'select' && onSelect && ( {mode === 'select' && onSelect && (
<button onClick={() => onSelect(asset)} className="bg-mauve hover:bg-pink text-crust px-4 py-2 rounded-lg text-sm font-bold transition-colors shadow-lg inline-flex items-center gap-1.5"> <button
onClick={() => onSelect(asset)}
className="btn btn--primary btn--sm"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
Insert Insert
</button> </button>
)} )}
<button onClick={() => handleDelete(asset.name)} className="bg-red/80 hover:bg-red text-white p-2.5 rounded-lg transition-colors shadow-lg"> <button
onClick={() => handleDelete(asset.name)}
className="btn btn--danger btn--icon btn--sm"
>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>
</button> </button>
</div> </div>
</div> </div>
<div className="p-2 bg-crust text-[10px] truncate border-t border-white/5 text-subtext1">{asset.name}</div> <div className="asset-name p-2 bg-[var(--surface0)] text-[10px] truncate border-t border-[var(--surface2)]/50 text-[var(--subtext1)] font-mono">{asset.name}</div>
</div> </div>
))} ))}
</div> </div>
+177 -273
View File
@@ -1,126 +1,90 @@
import { useState, useEffect, useRef, useCallback } from 'react'; import { lazy, Suspense, useCallback, useEffect, useRef, useState } from 'react';
import { EditorView, keymap, placeholder as cmPlaceholder } from '@codemirror/view'; import { EditorView, keymap, placeholder as cmPlaceholder } from '@codemirror/view';
import { EditorState, Compartment } from '@codemirror/state'; import { EditorState } from '@codemirror/state';
import { markdown, markdownLanguage } from '@codemirror/lang-markdown'; import { markdown, markdownLanguage } from '@codemirror/lang-markdown';
import { languages } from '@codemirror/language-data'; import { languages } from '@codemirror/language-data';
import { defaultKeymap, indentWithTab } from '@codemirror/commands'; import { defaultKeymap, indentWithTab } from '@codemirror/commands';
import { vim } from '@replit/codemirror-vim';
import { search, searchKeymap } from '@codemirror/search'; import { search, searchKeymap } from '@codemirror/search';
import { closeBrackets } from '@codemirror/autocomplete'; import { closeBrackets } from '@codemirror/autocomplete';
import { renderMarkdown } from '../../../lib/markdown';
import { getPost, savePost, deletePost, getAssets, ApiError } from '../../../lib/api';
import type { Asset } from '../../../lib/types'; import type { Asset } from '../../../lib/types';
import AssetManager from './AssetManager'; import { salonTheme, vimCompartment } from './editor/codemirror';
import { useAssetCache } from './editor/useAssetCache';
import { useLivePreview } from './editor/useLivePreview';
import { useImageUpload } from './editor/useImageUpload';
import { useAssetAutocomplete } from './editor/useAssetAutocomplete';
import { usePostMeta } from './editor/usePostMeta';
import { type SiteMode, copy } from '../../../lib/siteMode';
const AssetManager = lazy(() => import('./AssetManager'));
interface Props { interface Props {
editSlug?: string; editSlug?: string;
mode?: SiteMode;
} }
const salonTheme = EditorView.theme({ export default function Editor({ editSlug, mode = 'atelier' }: Props) {
'&': { const c = copy(mode);
backgroundColor: 'var(--base)',
color: 'var(--text)',
border: '1px solid var(--surface2)',
borderRadius: '2px',
fontSize: '14px',
boxShadow: 'inset 0 0 0 1px color-mix(in srgb, var(--surface1) 40%, transparent)',
},
'.cm-content': {
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',
padding: '1rem',
caretColor: 'var(--mauve)',
color: 'var(--text)',
},
'.cm-cursor': { borderLeftColor: 'var(--mauve)', borderLeftWidth: '2px' },
'.cm-selectionBackground': { backgroundColor: 'color-mix(in srgb, var(--mauve) 25%, transparent) !important' },
'&.cm-focused .cm-selectionBackground': { backgroundColor: 'color-mix(in srgb, var(--mauve) 30%, transparent) !important' },
'.cm-activeLine': { backgroundColor: 'color-mix(in srgb, var(--surface0) 55%, transparent)' },
'.cm-gutters': {
backgroundColor: 'var(--surface0)',
color: 'var(--subtext0)',
border: 'none',
borderRight: '1px solid var(--surface2)',
fontFamily: 'var(--font-display)',
fontStyle: 'italic',
},
'.cm-activeLineGutter': { backgroundColor: 'color-mix(in srgb, var(--mauve) 12%, transparent)', color: 'var(--mauve)' },
'.cm-panels': {
backgroundColor: 'var(--surface0)',
color: 'var(--text)',
borderTop: '1px solid var(--surface2)',
},
'.cm-searchMatch': { backgroundColor: 'color-mix(in srgb, var(--yellow) 45%, transparent)' },
'.cm-searchMatch-selected': { backgroundColor: 'color-mix(in srgb, var(--peach) 55%, transparent)' },
'.cm-fat-cursor': {
backgroundColor: 'var(--mauve) !important',
color: 'var(--rosewater) !important',
},
'&:not(.cm-focused) .cm-fat-cursor': {
outline: '1px solid var(--mauve)',
backgroundColor: 'transparent !important',
},
}, { dark: false });
// Compartment for hot-swapping vim mode without recreating the editor
const vimCompartment = new Compartment();
function clientSlugify(s: string): string {
return s
.toLowerCase()
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
}
export default function Editor({ editSlug }: Props) {
const editorRef = useRef<HTMLDivElement>(null); const editorRef = useRef<HTMLDivElement>(null);
const viewRef = useRef<EditorView | null>(null); const viewRef = useRef<EditorView | null>(null);
const previewRef = useRef<HTMLDivElement>(null); const [vimEnabled, setVimEnabled] = useState(false);
const previewTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const updatePreviewRef = useRef<() => void>(() => {});
const today = new Date().toISOString().slice(0, 10);
const [title, setTitle] = useState('');
const [slug, setSlug] = useState(editSlug || '');
const [slugTouched, setSlugTouched] = useState(!!editSlug);
const [date, setDate] = useState(today);
const [summary, setSummary] = useState('');
const [tagsInput, setTagsInput] = useState('');
const [draft, setDraft] = useState(false);
const [originalSlug, setOriginalSlug] = useState(editSlug || '');
const [alert, setAlert] = useState<{ msg: string; type: 'success' | 'error' } | null>(null);
const [showModal, setShowModal] = useState(false); const [showModal, setShowModal] = useState(false);
const [showPreview, setShowPreview] = useState(false);
const [mobileView, setMobileView] = useState<'edit' | 'preview'>('edit');
const [vimEnabled, setVimEnabled] = useState(() =>
typeof window !== 'undefined' && window.innerWidth > 768
);
const [showAutocomplete, setShowAutocomplete] = useState(false);
const [autocompleteAssets, setAutocompleteAssets] = useState<Asset[]>([]);
const [autocompletePos, setAutocompletePos] = useState({ top: 0, left: 0 });
function showAlertMsg(msg: string, type: 'success' | 'error') { const getView = useCallback(() => viewRef.current, []);
setAlert({ msg, type }); const getContent = useCallback(() => viewRef.current?.state.doc.toString() || '', []);
window.scrollTo({ top: 0, behavior: 'smooth' }); const setContent = useCallback((s: string) => {
setTimeout(() => setAlert(null), 5000); const v = viewRef.current;
} if (v) v.dispatch({ changes: { from: 0, to: v.state.doc.length, insert: s } });
}, []);
const updatePreview = useCallback(() => { const assetCache = useAssetCache();
if (!showPreview || !viewRef.current || !previewRef.current) return; const preview = useLivePreview({ getView });
const content = viewRef.current.state.doc.toString(); const upload = useImageUpload({ getView, prependAssets: assetCache.prepend });
previewRef.current.innerHTML = renderMarkdown(content); const autocomplete = useAssetAutocomplete({
}, [showPreview]); getView,
editorRef,
getCachedAssets: assetCache.getCachedAssets,
});
const meta = usePostMeta({ editSlug, getContent, setContent, mode });
useEffect(() => { updatePreviewRef.current = updatePreview; }, [updatePreview]); const {
title, setTitle, slug, setSlug, setSlugTouched, date, setDate,
summary, setSummary, tagsInput, setTagsInput, draft, setDraft,
originalSlug, handleSave, handleDelete,
} = meta;
const { showPreview, setShowPreview, mobileView, setMobileView, previewRef } = preview;
const { isDragging, uploadingCount, setIsDragging, dragDepthRef, uploadFilesAndInsert } = upload;
const {
showAutocomplete, setShowAutocomplete, autocompleteAssets, autocompletePos,
triggerAutocomplete, insertAssetMarkdown,
} = autocomplete;
// Initialize CodeMirror once // Latest handler closures for the (once-created) CodeMirror listeners —
// same stale-closure-avoidance pattern the original component used.
const cmRef = useRef<{
schedulePreview: () => void;
triggerAutocomplete: (v: EditorView) => void;
closeAutocomplete: () => void;
upload: (files: File[], at?: number) => void;
setDragging: (b: boolean) => void;
}>(null!);
useEffect(() => {
cmRef.current = {
schedulePreview: preview.schedulePreview,
triggerAutocomplete,
closeAutocomplete: () => setShowAutocomplete(false),
upload: uploadFilesAndInsert,
setDragging: setIsDragging,
};
});
// Initialize CodeMirror once.
useEffect(() => { useEffect(() => {
if (!editorRef.current || viewRef.current) return; if (!editorRef.current || viewRef.current) return;
const state = EditorState.create({ const state = EditorState.create({
doc: '', doc: '',
extensions: [ extensions: [
vimCompartment.of(window.innerWidth > 768 ? vim() : []), vimCompartment.of([]),
keymap.of([...defaultKeymap, ...searchKeymap, indentWithTab]), keymap.of([...defaultKeymap, ...searchKeymap, indentWithTab]),
search(), search(),
closeBrackets(), closeBrackets(),
@@ -130,18 +94,60 @@ export default function Editor({ editSlug }: Props) {
cmPlaceholder('# A title for the work\n\n![alt text](/uploads/your-image.jpg "optional caption")\n\nNotes, context, materials...'), cmPlaceholder('# A title for the work\n\n![alt text](/uploads/your-image.jpg "optional caption")\n\nNotes, context, materials...'),
EditorView.updateListener.of(update => { EditorView.updateListener.of(update => {
if (!update.docChanged) return; if (!update.docChanged) return;
if (previewTimerRef.current) clearTimeout(previewTimerRef.current); cmRef.current.schedulePreview();
previewTimerRef.current = setTimeout(() => updatePreviewRef.current(), 300);
const pos = update.state.selection.main.head; const pos = update.state.selection.main.head;
const line = update.state.doc.lineAt(pos); const line = update.state.doc.lineAt(pos);
const textBefore = line.text.slice(0, pos - line.from); const textBefore = line.text.slice(0, pos - line.from);
const lastChar = textBefore.slice(-1); const lastChar = textBefore.slice(-1);
if (lastChar === '/' || lastChar === '!') { if (lastChar === '/' || lastChar === '!') {
triggerAutocomplete(update.view); cmRef.current.triggerAutocomplete(update.view);
} else if (lastChar === ' ' || textBefore.length === 0) { } else if (lastChar === ' ' || textBefore.length === 0) {
setShowAutocomplete(false); cmRef.current.closeAutocomplete();
} }
}), }),
EditorView.domEventHandlers({
dragenter(event) {
if (!event.dataTransfer?.types.includes('Files')) return false;
dragDepthRef.current += 1;
cmRef.current.setDragging(true);
return false;
},
dragover(event) {
if (!event.dataTransfer?.types.includes('Files')) return false;
event.preventDefault();
return true;
},
dragleave() {
dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
if (dragDepthRef.current === 0) cmRef.current.setDragging(false);
return false;
},
drop(event, view) {
const files = event.dataTransfer?.files;
if (!files || files.length === 0) return false;
event.preventDefault();
dragDepthRef.current = 0;
cmRef.current.setDragging(false);
const pos = view.posAtCoords({ x: event.clientX, y: event.clientY }) ?? view.state.selection.main.head;
cmRef.current.upload(Array.from(files), pos);
return true;
},
paste(event, view) {
const items = event.clipboardData?.items;
if (!items) return false;
const imageFiles: File[] = [];
for (const item of Array.from(items)) {
if (item.kind === 'file' && item.type.startsWith('image/')) {
const f = item.getAsFile();
if (f) imageFiles.push(f);
}
}
if (imageFiles.length === 0) return false;
event.preventDefault();
cmRef.current.upload(imageFiles, view.state.selection.main.head);
return true;
},
}),
], ],
}); });
@@ -149,160 +155,44 @@ export default function Editor({ editSlug }: Props) {
viewRef.current = view; viewRef.current = view;
return () => { view.destroy(); viewRef.current = null; }; return () => { view.destroy(); viewRef.current = null; };
}, []); }, [dragDepthRef]);
// Hot-swap vim mode via compartment reconfiguration // Hot-swap vim mode via compartment reconfiguration; lazy-load vim module.
useEffect(() => { useEffect(() => {
if (!viewRef.current) return; if (!viewRef.current) return;
viewRef.current.dispatch({ if (!vimEnabled) {
effects: vimCompartment.reconfigure(vimEnabled ? vim() : []), viewRef.current.dispatch({ effects: vimCompartment.reconfigure([]) });
}); return;
}, [vimEnabled]);
// Load existing post for editing
useEffect(() => {
if (!editSlug) return;
getPost(editSlug).then(post => {
if (post.title) setTitle(post.title);
if (post.summary) setSummary(post.summary);
if (post.date) setDate(post.date);
if (post.tags?.length) setTagsInput(post.tags.join(', '));
setDraft(!!post.draft);
if (post.content && viewRef.current) {
viewRef.current.dispatch({
changes: { from: 0, to: viewRef.current.state.doc.length, insert: post.content },
});
}
}).catch(() => showAlertMsg('Failed to load post.', 'error'));
}, [editSlug]);
// Auto-derive slug from title until user edits the slug field
useEffect(() => {
if (slugTouched) return;
setSlug(clientSlugify(title));
}, [title, slugTouched]);
useEffect(() => {
if (showPreview) updatePreview();
}, [showPreview, updatePreview]);
async function triggerAutocomplete(view: EditorView) {
try {
const assets = await getAssets();
setAutocompleteAssets(assets.slice(0, 8));
const pos = view.state.selection.main.head;
const coords = view.coordsAtPos(pos);
if (coords) {
const editorRect = editorRef.current?.getBoundingClientRect();
if (editorRect) {
setAutocompletePos({
top: coords.bottom - editorRect.top + 4,
left: coords.left - editorRect.left,
});
}
}
setShowAutocomplete(true);
} catch { /* ignore */ }
}
function insertAssetMarkdown(asset: Asset) {
const view = viewRef.current;
if (!view) return;
const isImage = /\.(jpg|jpeg|png|webp|gif|svg)$/i.test(asset.name);
const md = isImage ? `![${asset.name}](${asset.url})` : `[${asset.name}](${asset.url})`;
const pos = view.state.selection.main.head;
const line = view.state.doc.lineAt(pos);
const textBefore = line.text.slice(0, pos - line.from);
const triggerIdx = Math.max(textBefore.lastIndexOf('/'), textBefore.lastIndexOf('!'));
if (triggerIdx !== -1) {
const from = line.from + triggerIdx;
view.dispatch({ changes: { from, to: pos, insert: md } });
} else {
view.dispatch({ changes: { from: pos, insert: md } });
} }
view.focus(); let cancelled = false;
setShowAutocomplete(false); import('@replit/codemirror-vim').then(({ vim }) => {
} if (cancelled || !viewRef.current) return;
viewRef.current.dispatch({ effects: vimCompartment.reconfigure(vim()) });
});
return () => { cancelled = true; };
}, [vimEnabled]);
function handleAssetSelect(asset: Asset) { function handleAssetSelect(asset: Asset) {
insertAssetMarkdown(asset); insertAssetMarkdown(asset);
setShowModal(false); setShowModal(false);
} }
async function handleSave() { function closeAssetModal() {
const content = viewRef.current?.state.doc.toString() || ''; assetCache.invalidate();
if (!title.trim() || !slug || !content) { setShowModal(false);
showAlertMsg('Title, slug, and body are required.', 'error');
return;
}
if (!/!\[[^\]]*\]\([^)]+\)/.test(content)) {
showAlertMsg('A gallery work must include at least one image — insert via the Assets panel or type "!".', 'error');
return;
}
const tags = tagsInput
.split(',')
.map(t => t.trim())
.filter(Boolean);
try {
const saved = await savePost({
slug,
old_slug: originalSlug || null,
title: title.trim(),
date,
summary: summary || null,
tags,
draft,
content,
});
showAlertMsg('Post saved!', 'success');
if (saved?.slug && saved.slug !== slug) {
setSlug(saved.slug);
setSlugTouched(true);
}
setOriginalSlug(saved?.slug ?? slug);
} catch (e) {
showAlertMsg(e instanceof ApiError ? `Error: ${e.message}` : 'Failed to connect to server.', 'error');
}
} }
async function handleDelete() {
const target = originalSlug || slug;
if (!confirm(`Remove work "${target}" from the catalogue permanently?`)) return;
try {
await deletePost(target);
window.location.href = '/admin';
} catch {
showAlertMsg('Error deleting post.', 'error');
}
}
useEffect(() => {
if (!showAutocomplete) return;
const handler = () => setShowAutocomplete(false);
window.addEventListener('click', handler);
return () => window.removeEventListener('click', handler);
}, [showAutocomplete]);
return ( return (
<> <>
{alert && (
<div className={`p-4 rounded-lg mb-6 text-sm font-semibold text-center backdrop-blur-sm shadow-lg ${
alert.type === 'success' ? 'bg-green/15 border border-green/30' : 'bg-red/15 border border-red/30'
}`} style={{ color: 'var(--text)' }}>
{alert.msg}
</div>
)}
{/* Actions bar */} {/* Actions bar */}
<div className="flex flex-wrap gap-4 mb-6"> <div className="flex flex-wrap gap-4 mb-6">
{originalSlug && ( {originalSlug && (
<button onClick={handleDelete} className="btn-ghost py-3 px-6 text-[var(--red)] border-[var(--red)]/40 hover:bg-[var(--red)]/10 hover:border-[var(--red)] hover:text-[var(--red)]"> <button onClick={handleDelete} className="btn btn--danger">
Remove Remove
</button> </button>
)} )}
<button onClick={handleSave} className="btn-stamp py-3 px-8 whitespace-nowrap"> <button onClick={handleSave} className="btn btn--primary">
Save work Save work
</button> </button>
{originalSlug && ( {originalSlug && (
@@ -310,7 +200,7 @@ export default function Editor({ editSlug }: Props) {
href={`/posts/${encodeURIComponent(originalSlug)}`} href={`/posts/${encodeURIComponent(originalSlug)}`}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
className="btn-ghost py-3 px-6 inline-flex items-center justify-center gap-2 whitespace-nowrap" className="btn btn--ghost"
> >
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
View work View work
@@ -328,7 +218,7 @@ export default function Editor({ editSlug }: Props) {
value={title} value={title}
onChange={e => setTitle(e.target.value)} onChange={e => setTitle(e.target.value)}
required required
placeholder="Untitled (charcoal on paper)" placeholder={c.editorTitlePh}
className="field-input" className="field-input"
/> />
</div> </div>
@@ -346,14 +236,14 @@ export default function Editor({ editSlug }: Props) {
{/* Slug */} {/* Slug */}
<div> <div>
<label className="field-label"> <label className="field-label">
Slug <span className="normal-case tracking-normal text-[var(--overlay0)] italic font-display"> auto-derived from title</span> Slug <span className="slug-hint normal-case tracking-normal text-[var(--overlay0)] italic font-display"> auto-derived from title</span>
</label> </label>
<input <input
type="text" type="text"
value={slug} value={slug}
onChange={e => { setSlug(e.target.value); setSlugTouched(true); }} onChange={e => { setSlug(e.target.value); setSlugTouched(true); }}
required required
placeholder="untitled-charcoal-on-paper" placeholder={c.editorSlugPh}
className="field-input font-mono" className="field-input font-mono"
/> />
</div> </div>
@@ -366,7 +256,7 @@ export default function Editor({ editSlug }: Props) {
type="text" type="text"
value={tagsInput} value={tagsInput}
onChange={e => setTagsInput(e.target.value)} onChange={e => setTagsInput(e.target.value)}
placeholder="oil, paper, 2026, study" placeholder={c.editorTagsPh}
className="field-input" className="field-input"
/> />
</div> </div>
@@ -377,18 +267,18 @@ export default function Editor({ editSlug }: Props) {
onChange={e => setDraft(e.target.checked)} onChange={e => setDraft(e.target.checked)}
className="accent-[var(--peach)]" className="accent-[var(--peach)]"
/> />
<span className="text-sm font-display italic text-[var(--subtext1)]">Sketch (draft)</span> <span className="text-sm font-display italic text-[var(--subtext1)]">{c.editorDraftLabel}</span>
</label> </label>
</div> </div>
{/* Summary */} {/* Summary */}
<div> <div>
<label className="field-label">Caption (optional)</label> <label className="field-label">{c.editorSummaryLabel}</label>
<textarea <textarea
value={summary} value={summary}
onChange={e => setSummary(e.target.value)} onChange={e => setSummary(e.target.value)}
rows={2} rows={2}
placeholder="A short caption for the catalogue index..." placeholder={c.editorSummaryPh}
className="field-input resize-none" className="field-input resize-none"
/> />
</div> </div>
@@ -396,39 +286,35 @@ export default function Editor({ editSlug }: Props) {
{/* Editor Toolbar */} {/* Editor Toolbar */}
<div className="flex flex-col md:flex-row justify-between items-start md:items-end gap-2"> <div className="flex flex-col md:flex-row justify-between items-start md:items-end gap-2">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<label className="block text-sm font-medium text-subtext1 italic">Type '/' or '!' to insert an image · at least one image is required</label> <label className="block text-sm font-display italic text-[var(--subtext1)]">
Drag, paste, or click <span className="text-[var(--mauve)]">Add image</span> to insert. At least one image is required.
</label>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex flex-wrap items-center gap-2 w-full md:w-auto">
<button <button
type="button" type="button"
onClick={() => setVimEnabled(v => !v)} onClick={() => setVimEnabled(v => !v)}
className={`text-xs px-3 py-1.5 rounded border transition-colors font-mono ${ className={`btn btn--ghost btn--sm vim-toggle${vimEnabled ? ' is-active' : ''}`}
vimEnabled aria-pressed={vimEnabled}
? 'bg-mauve/20 text-mauve border-mauve/30' title={vimEnabled ? 'Vim mode ON — click to disable' : 'Vim mode OFF — click to enable'}
: 'bg-surface0 text-subtext0 border-surface1 hover:text-text'
}`}
title={vimEnabled ? 'Vim mode ON' : 'Vim mode OFF'}
> >
{vimEnabled ? 'VIM' : 'vim'} {vimEnabled ? 'Vim on' : 'Vim off'}
</button> </button>
<button <button
type="button" type="button"
onClick={() => setShowPreview(p => !p)} onClick={() => setShowPreview(p => !p)}
className={`text-xs px-3 py-1.5 rounded border transition-colors ${ className={`btn btn--ghost btn--sm flex-1 md:flex-none${showPreview ? ' is-active' : ''}`}
showPreview
? 'bg-blue/20 text-blue border-blue/30'
: 'bg-surface0 text-subtext0 border-surface1 hover:text-text'
}`}
> >
{showPreview ? 'Hide Preview' : 'Show Preview'} {showPreview ? 'Hide Preview' : 'Show Preview'}
</button> </button>
<button <button
type="button" type="button"
onClick={() => setShowModal(true)} onClick={() => setShowModal(true)}
className="text-sm bg-surface0 hover:bg-surface1 text-lavender px-4 py-1.5 rounded border border-surface1 transition-colors inline-flex items-center gap-2" className="btn btn--primary btn--sm flex-1 md:flex-none"
title="Insert an image — also: drag an image into the editor, or paste from clipboard"
> >
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>
Assets Add image
</button> </button>
</div> </div>
</div> </div>
@@ -441,11 +327,7 @@ export default function Editor({ editSlug }: Props) {
role="tab" role="tab"
aria-selected={mobileView === 'edit'} aria-selected={mobileView === 'edit'}
onClick={() => setMobileView('edit')} onClick={() => setMobileView('edit')}
className={`flex-1 text-xs px-3 py-2 rounded border transition-colors ${ className={`btn btn--ghost btn--sm flex-1${mobileView === 'edit' ? ' is-active' : ''}`}
mobileView === 'edit'
? 'bg-blue/20 text-blue border-blue/30'
: 'bg-surface0 text-subtext0 border-surface1 hover:text-text'
}`}
> >
Edit Edit
</button> </button>
@@ -454,11 +336,7 @@ export default function Editor({ editSlug }: Props) {
role="tab" role="tab"
aria-selected={mobileView === 'preview'} aria-selected={mobileView === 'preview'}
onClick={() => setMobileView('preview')} onClick={() => setMobileView('preview')}
className={`flex-1 text-xs px-3 py-2 rounded border transition-colors ${ className={`btn btn--ghost btn--sm flex-1${mobileView === 'preview' ? ' is-active' : ''}`}
mobileView === 'preview'
? 'bg-blue/20 text-blue border-blue/30'
: 'bg-surface0 text-subtext0 border-surface1 hover:text-text'
}`}
> >
Preview Preview
</button> </button>
@@ -474,6 +352,30 @@ export default function Editor({ editSlug }: Props) {
> >
<div ref={editorRef} className="min-h-[500px] md:flex-1 md:min-h-0" /> <div ref={editorRef} className="min-h-[500px] md:flex-1 md:min-h-0" />
{/* Drop overlay */}
{isDragging && (
<div
className="absolute inset-0 z-40 flex items-center justify-center pointer-events-none border-2 border-dashed border-[var(--mauve)] bg-[var(--mauve)]/10 backdrop-blur-[1px]"
style={{ borderRadius: 2 }}
>
<div className="text-center">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" className="mx-auto mb-3 text-[var(--mauve)]"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>
<p className="font-display italic text-xl text-[var(--text)]">Drop image to insert</p>
</div>
</div>
)}
{/* Uploading indicator */}
{uploadingCount > 0 && (
<div
className="absolute top-3 right-3 z-30 px-3 py-1.5 bg-[var(--surface0)] border border-[var(--mauve)]/40 text-xs font-display italic text-[var(--text)] flex items-center gap-2 shadow-lg"
style={{ borderRadius: 2 }}
>
<span className="w-2 h-2 rounded-full bg-[var(--mauve)] animate-pulse" />
Uploading {uploadingCount} image{uploadingCount === 1 ? '' : 's'}
</div>
)}
{/* Autocomplete dropdown */} {/* Autocomplete dropdown */}
{showAutocomplete && autocompleteAssets.length > 0 && ( {showAutocomplete && autocompleteAssets.length > 0 && (
<div <div
@@ -530,15 +432,17 @@ export default function Editor({ editSlug }: Props) {
<div className="glass w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden bg-[var(--base)]"> <div className="glass w-full max-w-5xl max-h-[90vh] flex flex-col overflow-hidden bg-[var(--base)]">
<header className="p-4 md:p-6 border-b border-[var(--surface2)]/60 flex justify-between items-center bg-[var(--surface0)]/50"> <header className="p-4 md:p-6 border-b border-[var(--surface2)]/60 flex justify-between items-center bg-[var(--surface0)]/50">
<div> <div>
<h2 className="font-display italic text-2xl md:text-3xl text-[var(--text)] leading-tight">Asset library</h2> <h2 className="font-display italic text-2xl md:text-3xl text-[var(--text)] leading-tight">Add image</h2>
<p className="text-xs text-[var(--subtext0)] font-display italic mt-1">Click an asset to drop it into the work.</p> <p className="text-xs text-[var(--subtext0)] font-display italic mt-1">Click an image to insert it. Drag new files in to upload.</p>
</div> </div>
<button onClick={() => setShowModal(false)} className="p-2 text-[var(--subtext0)] hover:text-[var(--red)] transition-colors"> <button onClick={closeAssetModal} className="btn btn--ghost btn--icon btn--sm">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
</button> </button>
</header> </header>
<div className="p-4 md:p-6 overflow-y-auto flex-1 bg-[var(--base)]/50"> <div className="p-4 md:p-6 overflow-y-auto flex-1 bg-[var(--base)]/50">
<AssetManager mode="select" onSelect={handleAssetSelect} /> <Suspense fallback={<div className="text-center py-12 font-display italic text-[var(--subtext0)]">Loading assets</div>}>
<AssetManager mode="select" onSelect={handleAssetSelect} />
</Suspense>
</div> </div>
</div> </div>
</div> </div>
@@ -0,0 +1,154 @@
import { useEffect, useState } from 'react';
import { listMessages, deleteMessage, ApiError } from '../../../lib/api';
import type { Message } from '../../../lib/types';
import { confirmDialog, notify } from '../../../lib/confirm';
export default function Inbox() {
const [messages, setMessages] = useState<Message[] | null>(null);
const [error, setError] = useState('');
const [expandedId, setExpandedId] = useState<string | null>(null);
useEffect(() => {
load();
}, []);
async function load() {
try {
const data = await listMessages();
setMessages(data);
setError('');
} catch (e) {
setError(e instanceof ApiError ? e.message : 'Failed to load messages.');
setMessages([]);
}
}
async function remove(id: string) {
const ok = await confirmDialog({
title: 'Delete this message?',
message: 'This cannot be undone.',
confirmLabel: 'Delete',
});
if (!ok) return;
try {
await deleteMessage(id);
setMessages(prev => (prev ?? []).filter(m => m.id !== id));
} catch (e) {
notify(e instanceof ApiError ? e.message : 'Failed to delete.');
}
}
function formatDate(ms: number): string {
const d = new Date(ms);
return d.toLocaleString(undefined, {
year: 'numeric', month: 'short', day: 'numeric',
hour: '2-digit', minute: '2-digit',
});
}
if (messages === null) {
return <p className="font-display italic text-[var(--subtext0)]">Loading</p>;
}
if (error) {
return (
<div
className="p-4 text-sm font-display italic text-center border bg-[var(--red)]/15 text-[var(--red)] border-[var(--red)]/30"
style={{ borderRadius: 1 }}
>
{error}
</div>
);
}
if (messages.length === 0) {
return (
<div className="glass p-12 md:p-16 text-center">
<div className="font-display italic text-[var(--subtext0)] text-xs tracking-[0.3em] uppercase mb-3">Inbox empty</div>
<p className="font-display italic text-[var(--text)] text-2xl">No messages yet.</p>
<p className="font-sans text-sm text-[var(--subtext1)] mt-3">When visitors send a note from the contact page, it'll appear here.</p>
</div>
);
}
return (
<ul className="space-y-3">
{messages.map(m => {
const isOpen = expandedId === m.id;
return (
<li
key={m.id}
className="border border-[var(--surface2)]/60"
style={{ borderRadius: 1 }}
>
<div
role="button"
tabIndex={0}
onClick={() => setExpandedId(isOpen ? null : m.id)}
onKeyDown={e => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
setExpandedId(isOpen ? null : m.id);
}
}}
className="w-full flex flex-col md:flex-row md:items-baseline md:justify-between gap-2 md:gap-4 px-5 py-4 text-left hover:bg-[var(--surface0)]/40 transition-colors cursor-pointer"
aria-expanded={isOpen}
>
<div className="flex-1 min-w-0">
<div className="font-display italic text-base md:text-lg text-[var(--text)] truncate">
{m.subject || m.name || '(no subject)'}
</div>
<div className="font-display italic text-xs text-[var(--subtext0)] tracking-wider mt-1 truncate">
{m.name ? `${m.name} · ` : ''}
{m.email ? (
<a
href={`mailto:${m.email}${m.subject ? `?subject=${encodeURIComponent('Re: ' + m.subject)}` : ''}`}
onClick={e => e.stopPropagation()}
className="underline decoration-[var(--surface2)] underline-offset-2 hover:text-[var(--mauve)] hover:decoration-[var(--mauve)] transition-colors"
>
{m.email}
</a>
) : (
'no email'
)}
</div>
</div>
<div className="font-display italic text-xs text-[var(--subtext0)] tracking-wider shrink-0">
{formatDate(m.received_at)}
</div>
</div>
{isOpen && (
<div className="px-5 pb-5 pt-2 border-t border-[var(--surface2)]/40 space-y-4">
<pre className="font-sans whitespace-pre-wrap text-[var(--text)] text-sm leading-relaxed">
{m.body}
</pre>
<div className="flex flex-wrap items-center gap-2 pt-2">
{m.email && (
<a
href={`mailto:${m.email}${m.subject ? `?subject=${encodeURIComponent('Re: ' + m.subject)}` : ''}`}
className="btn btn--ghost btn--sm"
>
Reply
</a>
)}
<button
type="button"
onClick={() => remove(m.id)}
className="btn btn--danger btn--sm"
>
Delete
</button>
{m.ip_hash && (
<span className="font-mono text-[10px] text-[var(--overlay0)] ml-auto" title="Hashed sender bucket">
sender: {m.ip_hash.slice(0, 8)}
</span>
)}
</div>
</div>
)}
</li>
);
})}
</ul>
);
}
+22 -8
View File
@@ -1,14 +1,16 @@
import { useState } from 'react'; import { useState } from 'react';
import { login, ApiError } from '../../../lib/api'; import { login, ApiError } from '../../../lib/api';
import { useAuth } from '../../../stores/auth'; import { useAuth } from '../../../stores/auth';
import { type SiteMode, copy } from '../../../lib/siteMode';
export default function Login() { export default function Login({ mode = 'atelier' }: { mode?: SiteMode }) {
const c = copy(mode);
const [value, setValue] = useState(''); const [value, setValue] = useState('');
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
const setLoggedIn = useAuth(s => s.setLoggedIn); const setLoggedIn = useAuth(s => s.setLoggedIn);
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) { async function handleSubmit(e: React.SyntheticEvent<HTMLFormElement>) {
e.preventDefault(); e.preventDefault();
const token = value.trim(); const token = value.trim();
if (!token) return; if (!token) return;
@@ -29,10 +31,10 @@ export default function Login() {
} }
return ( return (
<div className="max-w-md mx-auto mt-16"> <div className="max-w-md mx-auto mt-10 md:mt-20 px-1">
<div className="glass p-10"> <div className="glass p-7 sm:p-10">
<div className="font-display italic text-[var(--subtext0)] text-xs tracking-[0.3em] uppercase mb-3 text-center"> <div className="font-display italic text-[var(--subtext0)] text-xs tracking-[0.3em] uppercase mb-3 text-center">
Curator's entrance Artist's entrance
</div> </div>
<h1 className="font-display italic text-3xl md:text-4xl font-semibold text-[var(--text)] mb-2 text-center leading-tight"> <h1 className="font-display italic text-3xl md:text-4xl font-semibold text-[var(--text)] mb-2 text-center leading-tight">
Sign in Sign in
@@ -43,7 +45,7 @@ export default function Login() {
<p className="text-[var(--subtext1)] mb-8 text-center font-display italic"> <p className="text-[var(--subtext1)] mb-8 text-center font-display italic">
Present your token to enter the back room. Present your token to enter the back room.
</p> </p>
<form onSubmit={handleSubmit} className="space-y-6"> <form onSubmit={handleSubmit} className="space-y-6" noValidate>
<div> <div>
<label htmlFor="token" className="field-label">Admin token</label> <label htmlFor="token" className="field-label">Admin token</label>
<input <input
@@ -53,24 +55,36 @@ export default function Login() {
value={value} value={value}
onChange={e => setValue(e.target.value)} onChange={e => setValue(e.target.value)}
autoComplete="current-password" autoComplete="current-password"
aria-invalid={error ? true : undefined}
aria-describedby={error ? 'login-error' : undefined}
className="field-input font-mono tracking-widest" className="field-input font-mono tracking-widest"
placeholder="••••••••••••" placeholder="••••••••••••"
/> />
</div> </div>
{error && ( {error && (
<p className="text-sm text-[var(--red)] bg-[var(--red)]/10 border border-[var(--red)]/30 px-3 py-2 font-display italic"> <p
id="login-error"
role="alert"
className="text-sm text-[var(--red)] bg-[var(--red)]/10 border border-[var(--red)]/30 px-3 py-2 font-display italic"
>
{error} {error}
</p> </p>
)} )}
<button <button
type="submit" type="submit"
disabled={busy} disabled={busy}
className="btn-stamp w-full justify-center disabled:opacity-60 disabled:cursor-not-allowed" className="btn btn--primary btn--block btn--lg"
> >
{busy ? 'Unlocking' : 'Enter'} {busy ? 'Unlocking' : 'Enter'}
</button> </button>
</form> </form>
</div> </div>
<div className="text-center mt-6">
<a href="/" className="back-link">
<span className="bl-arrow" aria-hidden="true"></span>
{c.adminBack}
</a>
</div>
</div> </div>
); );
} }
+134 -24
View File
@@ -1,11 +1,19 @@
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { getConfig, updateConfig, ApiError } from '../../../lib/api'; import { getConfig, updateConfig, ApiError } from '../../../lib/api';
import type { SiteConfig } from '../../../lib/types'; import { notify } from '../../../lib/confirm';
import type { SiteConfig, ContactLink } from '../../../lib/types';
const CONTACT_KINDS: { value: string; label: string; placeholder: string }[] = [
{ value: 'email', label: 'Email', placeholder: 'you@example.com' },
{ value: 'mastodon', label: 'Mastodon', placeholder: 'https://mastodon.social/@you' },
{ value: 'bluesky', label: 'Bluesky', placeholder: 'https://bsky.app/profile/you.bsky.social' },
{ value: 'github', label: 'GitHub', placeholder: 'https://github.com/you' },
{ value: 'instagram', label: 'Instagram', placeholder: 'https://instagram.com/you' },
{ value: 'url', label: 'Other link', placeholder: 'https://…' },
];
export default function Settings() { export default function Settings() {
const [config, setConfig] = useState<Partial<SiteConfig>>({}); const [config, setConfig] = useState<Partial<SiteConfig>>({});
const [alert, setAlert] = useState<{ msg: string; type: 'success' | 'error' } | null>(null);
useEffect(() => { useEffect(() => {
getConfig() getConfig()
.then(setConfig) .then(setConfig)
@@ -13,15 +21,34 @@ export default function Settings() {
}, []); }, []);
function showAlert(msg: string, type: 'success' | 'error') { function showAlert(msg: string, type: 'success' | 'error') {
setAlert({ msg, type }); notify(msg, type);
setTimeout(() => setAlert(null), 5000);
} }
function update(key: keyof SiteConfig, value: string) { function update<K extends keyof SiteConfig>(key: K, value: SiteConfig[K]) {
setConfig(prev => ({ ...prev, [key]: value })); setConfig(prev => ({ ...prev, [key]: value }));
} }
async function handleSubmit(e: React.FormEvent) { const contactLinks: ContactLink[] = config.contact_links ?? [];
function updateContactLink(index: number, patch: Partial<ContactLink>) {
const next = contactLinks.map((row, i) => (i === index ? { ...row, ...patch } : row));
update('contact_links', next);
}
function addContactLink() {
update('contact_links', [...contactLinks, { kind: 'email', label: 'Email', value: '' }]);
}
function removeContactLink(index: number) {
update('contact_links', contactLinks.filter((_, i) => i !== index));
}
function moveContactLink(index: number, dir: -1 | 1) {
const target = index + dir;
if (target < 0 || target >= contactLinks.length) return;
const next = [...contactLinks];
[next[index], next[target]] = [next[target], next[index]];
update('contact_links', next);
}
async function handleSubmit(e: React.SyntheticEvent) {
e.preventDefault(); e.preventDefault();
try { try {
await updateConfig(config); await updateConfig(config);
@@ -33,19 +60,6 @@ export default function Settings() {
return ( return (
<form onSubmit={handleSubmit} className="space-y-10"> <form onSubmit={handleSubmit} className="space-y-10">
{alert && (
<div
className={`p-4 text-sm font-display italic text-center border ${
alert.type === 'success'
? 'bg-[var(--green)]/15 text-[var(--green)] border-[var(--green)]/30'
: 'bg-[var(--red)]/15 text-[var(--red)] border-[var(--red)]/30'
}`}
style={{ borderRadius: 1 }}
>
{alert.msg}
</div>
)}
<section className="space-y-6"> <section className="space-y-6">
<h2 className="font-display italic text-2xl text-[var(--text)] border-l-2 border-[var(--mauve)] pl-4">Identity</h2> <h2 className="font-display italic text-2xl text-[var(--text)] border-l-2 border-[var(--mauve)] pl-4">Identity</h2>
<div className="grid md:grid-cols-2 gap-6"> <div className="grid md:grid-cols-2 gap-6">
@@ -68,10 +82,11 @@ export default function Settings() {
> >
<option value="salon">Salon (parchment, default)</option> <option value="salon">Salon (parchment, default)</option>
<option value="salon-noir">Salon Noir (black gallery wall)</option> <option value="salon-noir">Salon Noir (black gallery wall)</option>
<option value="latte">Latte (light)</option> <option value="gothic">Gothic (cathedral nightfall)</option>
<option value="mocha">Mocha (dark)</option> <option value="breakcore">Breakcore (Y2K rot + neon glitch)</option>
<option value="cybersigil">Cybersigil (dark frostbite + glitch)</option>
</select> </select>
<p className="text-[10px] font-display italic text-[var(--subtext0)] mt-2 tracking-wider">Salon and Salon Noir are tuned for the gallery aesthetic.</p> <p className="text-[10px] font-display italic text-[var(--subtext0)] mt-2 tracking-wider">Salon trio tuned for the gallery aesthetic. Breakcore swaps that for early-2000s web rot hot magenta on CRT violet, acid green, scanline noise. Cybersigil is the moody cut near-black ground, ice-cyan barbed sigil linework, bruised-magenta on contact, lingering chromatic glitch.</p>
</div> </div>
<div> <div>
<label className="field-label">Custom CSS</label> <label className="field-label">Custom CSS</label>
@@ -86,12 +101,107 @@ export default function Settings() {
</div> </div>
</section> </section>
<section className="space-y-6">
<h2 className="font-display italic text-2xl text-[var(--text)] border-l-2 border-[var(--peach)] pl-4">Contact</h2>
<div>
<label className="field-label">Intro text (shown above links)</label>
<textarea
value={config.contact_intro || ''}
onChange={e => update('contact_intro', e.target.value)}
rows={3}
className="field-input"
placeholder="A short note for visitors who want to reach out."
/>
</div>
<div className="space-y-4">
<label className="field-label">Contact links</label>
{contactLinks.length === 0 && (
<p className="text-[11px] font-display italic text-[var(--subtext0)] tracking-wider">
No links yet. Add one below to populate the contact page.
</p>
)}
{contactLinks.map((row, i) => (
<div
key={i}
className="grid md:grid-cols-[160px_1fr_1fr_auto] gap-3 items-end p-3 border border-[var(--surface2)]/60"
style={{ borderRadius: 1 }}
>
<div>
<label className="field-label">Kind</label>
<select
value={row.kind}
onChange={e => updateContactLink(i, { kind: e.target.value })}
className="field-input font-display italic"
>
{CONTACT_KINDS.map(k => (
<option key={k.value} value={k.value}>{k.label}</option>
))}
</select>
</div>
<div>
<label className="field-label">Label</label>
<input
type="text"
value={row.label}
onChange={e => updateContactLink(i, { label: e.target.value })}
className="field-input"
placeholder="Displayed name"
/>
</div>
<div>
<label className="field-label">{row.kind === 'email' ? 'Address' : 'URL'}</label>
<input
type="text"
value={row.value}
onChange={e => updateContactLink(i, { value: e.target.value })}
className="field-input"
placeholder={CONTACT_KINDS.find(k => k.value === row.kind)?.placeholder ?? ''}
/>
</div>
<div className="flex gap-1 items-center pb-1">
<button
type="button"
onClick={() => moveContactLink(i, -1)}
disabled={i === 0}
className="chip disabled:opacity-30"
aria-label="Move up"
title="Move up"
></button>
<button
type="button"
onClick={() => moveContactLink(i, 1)}
disabled={i === contactLinks.length - 1}
className="chip disabled:opacity-30"
aria-label="Move down"
title="Move down"
></button>
<button
type="button"
onClick={() => removeContactLink(i)}
className="chip text-[var(--red)]"
aria-label="Remove link"
title="Remove"
></button>
</div>
</div>
))}
<button
type="button"
onClick={addContactLink}
className="btn btn--ghost btn--sm"
>
+ Add contact link
</button>
</div>
</section>
<section className="space-y-6"> <section className="space-y-6">
<h2 className="font-display italic text-2xl text-[var(--text)] border-l-2 border-[var(--teal)] pl-4">Footer</h2> <h2 className="font-display italic text-2xl text-[var(--text)] border-l-2 border-[var(--teal)] pl-4">Footer</h2>
<Field label="Footer text" value={config.footer || ''} onChange={v => update('footer', v)} /> <Field label="Footer text" value={config.footer || ''} onChange={v => update('footer', v)} />
</section> </section>
<button type="submit" className="btn-stamp"> <button type="submit" className="btn btn--primary">
Save site settings Save site settings
</button> </button>
</form> </form>
@@ -0,0 +1,72 @@
import { EditorView } from '@codemirror/view';
import { Compartment } from '@codemirror/state';
// Salon-themed CodeMirror look. Static — defined once at module load.
export const salonTheme = EditorView.theme(
{
'&': {
backgroundColor: 'var(--base)',
color: 'var(--text)',
border: '1px solid var(--surface2)',
borderRadius: '2px',
fontSize: '14px',
boxShadow: 'inset 0 0 0 1px color-mix(in srgb, var(--surface1) 40%, transparent)',
},
'.cm-content': {
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',
padding: '1rem',
caretColor: 'var(--mauve)',
color: 'var(--text)',
},
'.cm-cursor': { borderLeftColor: 'var(--mauve)', borderLeftWidth: '2px' },
'.cm-selectionBackground': {
backgroundColor: 'color-mix(in srgb, var(--mauve) 25%, transparent) !important',
},
'&.cm-focused .cm-selectionBackground': {
backgroundColor: 'color-mix(in srgb, var(--mauve) 30%, transparent) !important',
},
'.cm-activeLine': { backgroundColor: 'color-mix(in srgb, var(--surface0) 55%, transparent)' },
'.cm-gutters': {
backgroundColor: 'var(--surface0)',
color: 'var(--subtext0)',
border: 'none',
borderRight: '1px solid var(--surface2)',
fontFamily: 'var(--font-display)',
fontStyle: 'italic',
},
'.cm-activeLineGutter': {
backgroundColor: 'color-mix(in srgb, var(--mauve) 12%, transparent)',
color: 'var(--mauve)',
},
'.cm-panels': {
backgroundColor: 'var(--surface0)',
color: 'var(--text)',
borderTop: '1px solid var(--surface2)',
},
'.cm-searchMatch': { backgroundColor: 'color-mix(in srgb, var(--yellow) 45%, transparent)' },
'.cm-searchMatch-selected': {
backgroundColor: 'color-mix(in srgb, var(--peach) 55%, transparent)',
},
'.cm-fat-cursor': {
backgroundColor: 'var(--mauve) !important',
color: 'var(--rosewater) !important',
},
'&:not(.cm-focused) .cm-fat-cursor': {
outline: '1px solid var(--mauve)',
backgroundColor: 'transparent !important',
},
},
{ dark: false },
);
// Compartment for hot-swapping vim mode without recreating the editor.
export const vimCompartment = new Compartment();
export function clientSlugify(s: string): string {
return s
.toLowerCase()
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
}
@@ -0,0 +1,74 @@
import { type RefObject, useEffect, useState } from 'react';
import type { EditorView } from '@codemirror/view';
import type { Asset } from '../../../../lib/types';
interface Opts {
getView: () => EditorView | null;
editorRef: RefObject<HTMLDivElement | null>;
getCachedAssets: () => Promise<Asset[]>;
}
/** Inline `/` or `!` asset autocomplete dropdown. */
export function useAssetAutocomplete({ getView, editorRef, getCachedAssets }: Opts) {
const [showAutocomplete, setShowAutocomplete] = useState(false);
const [autocompleteAssets, setAutocompleteAssets] = useState<Asset[]>([]);
const [autocompletePos, setAutocompletePos] = useState({ top: 0, left: 0 });
async function triggerAutocomplete(view: EditorView) {
try {
const assets = await getCachedAssets();
setAutocompleteAssets(assets.slice(0, 8));
const pos = view.state.selection.main.head;
const coords = view.coordsAtPos(pos);
if (coords) {
const editorRect = editorRef.current?.getBoundingClientRect();
if (editorRect) {
setAutocompletePos({
top: coords.bottom - editorRect.top + 4,
left: coords.left - editorRect.left,
});
}
}
setShowAutocomplete(true);
} catch {
/* ignore */
}
}
function insertAssetMarkdown(asset: Asset) {
const view = getView();
if (!view) return;
const isImage = /\.(jpg|jpeg|png|webp|gif|svg)$/i.test(asset.name);
const md = isImage ? `![${asset.name}](${asset.url})` : `[${asset.name}](${asset.url})`;
const pos = view.state.selection.main.head;
const line = view.state.doc.lineAt(pos);
const textBefore = line.text.slice(0, pos - line.from);
const triggerIdx = Math.max(textBefore.lastIndexOf('/'), textBefore.lastIndexOf('!'));
if (triggerIdx !== -1) {
const from = line.from + triggerIdx;
view.dispatch({ changes: { from, to: pos, insert: md } });
} else {
view.dispatch({ changes: { from: pos, insert: md } });
}
view.focus();
setShowAutocomplete(false);
}
useEffect(() => {
if (!showAutocomplete) return;
const handler = () => setShowAutocomplete(false);
window.addEventListener('click', handler);
return () => window.removeEventListener('click', handler);
}, [showAutocomplete]);
return {
showAutocomplete,
setShowAutocomplete,
autocompleteAssets,
autocompletePos,
triggerAutocomplete,
insertAssetMarkdown,
};
}
@@ -0,0 +1,28 @@
import { useRef } from 'react';
import { getAssets } from '../../../../lib/api';
import type { Asset } from '../../../../lib/types';
/** Shared, lazily-populated asset list (used by autocomplete + upload). */
export function useAssetCache() {
const cacheRef = useRef<Asset[] | null>(null);
async function getCachedAssets(): Promise<Asset[]> {
if (cacheRef.current) return cacheRef.current;
const assets = await getAssets();
cacheRef.current = assets;
return assets;
}
// Mirrors the original behaviour: prepend only if the cache is already
// warm; if it's cold, leave it null so the next read refetches.
function prepend(newAssets: Asset[]) {
if (newAssets.length === 0) return;
cacheRef.current = cacheRef.current ? [...newAssets, ...cacheRef.current] : null;
}
function invalidate() {
cacheRef.current = null;
}
return { getCachedAssets, prepend, invalidate };
}
@@ -0,0 +1,67 @@
import { useRef, useState } from 'react';
import type { EditorView } from '@codemirror/view';
import { ApiError, uploadAsset } from '../../../../lib/api';
import { notify } from '../../../../lib/confirm';
import type { Asset } from '../../../../lib/types';
interface Opts {
getView: () => EditorView | null;
prependAssets: (assets: Asset[]) => void;
}
/** Drag/paste/click image upload + insertion, with progress + drag state. */
export function useImageUpload({ getView, prependAssets }: Opts) {
const [uploadingCount, setUploadingCount] = useState(0);
const [isDragging, setIsDragging] = useState(false);
const dragDepthRef = useRef(0);
async function uploadFilesAndInsert(files: File[], insertAt?: number) {
const view = getView();
if (!view || files.length === 0) return;
const images = files.filter(f => f.type.startsWith('image/'));
if (images.length === 0) {
notify('Only image files can be dropped here.', 'error');
return;
}
setUploadingCount(c => c + images.length);
// Fire all uploads in parallel; the browser caps per-origin concurrency.
// Insert results in submission order so the markdown reflects user intent.
const uploads = images.map(file =>
uploadAsset(file).then(
asset => ({ ok: true as const, asset }),
err => ({ ok: false as const, err }),
),
);
let pos = typeof insertAt === 'number' ? insertAt : view.state.selection.main.head;
const newAssets: Asset[] = [];
for (const promise of uploads) {
const result = await promise;
setUploadingCount(c => Math.max(0, c - 1));
if (result.ok) {
const { asset } = result;
newAssets.push(asset);
const md = `![${asset.name}](${asset.url})`;
const line = view.state.doc.lineAt(pos);
const atLineEnd = pos === line.to;
const insertText = atLineEnd ? `\n\n${md}\n` : `${md}\n\n`;
view.dispatch({ changes: { from: pos, insert: insertText } });
pos += insertText.length;
} else {
const e = result.err;
notify(
e instanceof ApiError ? `Upload failed: ${e.message}` : 'Upload failed.',
'error',
);
}
}
if (newAssets.length > 0) {
prependAssets(newAssets);
}
view.focus();
}
return { uploadingCount, isDragging, setIsDragging, dragDepthRef, uploadFilesAndInsert };
}
@@ -0,0 +1,51 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import type { EditorView } from '@codemirror/view';
interface Opts {
getView: () => EditorView | null;
}
/** Live markdown preview pane: visibility, mobile tab, debounced render. */
export function useLivePreview({ getView }: Opts) {
const [showPreview, setShowPreview] = useState(false);
const [mobileView, setMobileView] = useState<'edit' | 'preview'>('edit');
const previewRef = useRef<HTMLDivElement>(null);
const renderMarkdownRef = useRef<((src: string) => string) | null>(null);
const previewTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const updatePreviewRef = useRef<() => void>(() => {});
const updatePreview = useCallback(async () => {
const view = getView();
if (!showPreview || !view || !previewRef.current) return;
if (!renderMarkdownRef.current) {
const mod = await import('../../../../lib/markdown');
renderMarkdownRef.current = mod.renderMarkdown;
}
const content = view.state.doc.toString();
previewRef.current.innerHTML = renderMarkdownRef.current(content);
}, [showPreview, getView]);
useEffect(() => {
updatePreviewRef.current = updatePreview;
}, [updatePreview]);
useEffect(() => {
if (showPreview) updatePreview();
}, [showPreview, updatePreview]);
// Debounced refresh — called from the CodeMirror update listener.
const schedulePreview = useCallback(() => {
if (previewTimerRef.current) clearTimeout(previewTimerRef.current);
previewTimerRef.current = setTimeout(() => updatePreviewRef.current(), 300);
}, []);
return {
showPreview,
setShowPreview,
mobileView,
setMobileView,
previewRef,
updatePreview,
schedulePreview,
};
}
@@ -0,0 +1,124 @@
import { useEffect, useState } from 'react';
import { ApiError, deletePost, getPost, savePost } from '../../../../lib/api';
import { confirmDialog, notify } from '../../../../lib/confirm';
import { type SiteMode, copy } from '../../../../lib/siteMode';
import { clientSlugify } from './codemirror';
interface Opts {
editSlug?: string;
getContent: () => string;
setContent: (s: string) => void;
mode?: SiteMode;
}
/** Post metadata form + slug derivation + load/save/delete. */
export function usePostMeta({ editSlug, getContent, setContent, mode = 'atelier' }: Opts) {
const c = copy(mode);
const today = new Date().toISOString().slice(0, 10);
const [title, setTitle] = useState('');
const [slug, setSlug] = useState(editSlug || '');
const [slugTouched, setSlugTouched] = useState(!!editSlug);
const [date, setDate] = useState(today);
const [summary, setSummary] = useState('');
const [tagsInput, setTagsInput] = useState('');
const [draft, setDraft] = useState(false);
const [originalSlug, setOriginalSlug] = useState(editSlug || '');
// Load existing post for editing.
useEffect(() => {
if (!editSlug) return;
getPost(editSlug)
.then(post => {
if (post.title) setTitle(post.title);
if (post.summary) setSummary(post.summary);
if (post.date) setDate(post.date);
if (post.tags?.length) setTagsInput(post.tags.join(', '));
setDraft(!!post.draft);
if (post.content) setContent(post.content);
})
.catch(() => notify('Failed to load post.', 'error'));
}, [editSlug, setContent]);
// Auto-derive slug from title until the user edits the slug field.
useEffect(() => {
if (slugTouched) return;
setSlug(clientSlugify(title));
}, [title, slugTouched]);
async function handleSave() {
const content = getContent();
if (!title.trim() || !slug || !content) {
notify('Title, slug, and body are required.', 'error');
return;
}
if (!/!\[[^\]]*\]\([^)]+\)/.test(content)) {
notify(
'Add at least one image before saving — drag, paste, or use the Add image button.',
'error',
);
return;
}
const tags = tagsInput
.split(',')
.map(t => t.trim())
.filter(Boolean);
try {
const saved = await savePost({
slug,
old_slug: originalSlug || null,
title: title.trim(),
date,
summary: summary || null,
tags,
draft,
content,
});
notify('Post saved!', 'success');
if (saved?.slug && saved.slug !== slug) {
setSlug(saved.slug);
setSlugTouched(true);
}
setOriginalSlug(saved?.slug ?? slug);
} catch (e) {
notify(
e instanceof ApiError ? `Error: ${e.message}` : 'Failed to connect to server.',
'error',
);
}
}
async function handleDelete() {
const target = originalSlug || slug;
const ok = await confirmDialog({
title: c.deletePostTitle,
message: c.deletePostMsg(target),
confirmLabel: c.deleteListConfirm,
});
if (!ok) return;
try {
await deletePost(target);
window.location.href = '/admin';
} catch {
notify('Error deleting post.', 'error');
}
}
return {
title,
setTitle,
slug,
setSlug,
setSlugTouched,
date,
setDate,
summary,
setSummary,
tagsInput,
setTagsInput,
draft,
setDraft,
originalSlug,
handleSave,
handleDelete,
};
}
-32
View File
@@ -1,32 +0,0 @@
export function showAlert(msg: string, type: 'success' | 'error', elementId: string = 'alert') {
const alertEl = document.getElementById(elementId);
if (alertEl) {
alertEl.textContent = msg;
// Define colors based on type using theme variables
const colorVar = type === 'success' ? 'var(--green)' : 'var(--red)';
// Apply inline styles for guaranteed high contrast and glassy look
alertEl.style.display = 'block';
alertEl.style.backgroundColor = `color-mix(in srgb, ${colorVar} 15%, transparent)`;
alertEl.style.color = 'var(--text)';
alertEl.style.border = `1px solid color-mix(in srgb, ${colorVar} 40%, transparent)`;
alertEl.style.padding = '1rem';
alertEl.style.borderRadius = '0.75rem';
alertEl.style.marginBottom = '1.5rem';
alertEl.style.fontSize = '0.875rem';
alertEl.style.fontWeight = '600';
alertEl.style.backdropFilter = 'blur(12px)';
alertEl.style.textAlign = 'center';
alertEl.style.boxShadow = '0 4px 15px -5px rgba(0,0,0,0.3)';
alertEl.classList.remove('hidden');
window.scrollTo({ top: 0, behavior: 'smooth' });
setTimeout(() => {
alertEl.classList.add('hidden');
alertEl.style.display = 'none';
}, 5000);
}
}
+6 -4
View File
@@ -1,5 +1,6 @@
--- ---
import Layout from './Layout.astro'; import Layout from './Layout.astro';
import { getSiteMode, copy } from '../lib/siteMode';
interface Props { interface Props {
title: string; title: string;
@@ -7,6 +8,7 @@ interface Props {
} }
const { title, wide = false } = Astro.props; const { title, wide = false } = Astro.props;
const c = copy(getSiteMode());
if (Astro.cookies.get('admin_session')?.value !== '1') { if (Astro.cookies.get('admin_session')?.value !== '1') {
return Astro.redirect('/admin/login'); return Astro.redirect('/admin/login');
@@ -17,11 +19,11 @@ if (Astro.cookies.get('admin_session')?.value !== '1') {
<div class="space-y-10 md:space-y-14"> <div class="space-y-10 md:space-y-14">
<header class="flex flex-col md:flex-row md:items-end justify-between gap-6 pb-6 border-b border-[var(--surface2)]/60"> <header class="flex flex-col md:flex-row md:items-end justify-between gap-6 pb-6 border-b border-[var(--surface2)]/60">
<div class="flex-1 min-w-0"> <div class="flex-1 min-w-0">
<a href="/" class="inline-flex items-center gap-1.5 text-xs font-display italic text-[var(--subtext0)] hover:text-[var(--mauve)] transition-colors mb-3 group"> <a href="/" class="back-link mb-3">
<span class="transition-transform group-hover:-translate-x-0.5">←</span> <span class="bl-arrow" aria-hidden="true">←</span>
Back to the catalogue {c.adminBack}
</a> </a>
<div class="font-display italic text-[var(--mauve)] text-xs tracking-[0.3em] uppercase mb-2">Curator's desk</div> <div class="font-display italic text-[var(--mauve)] text-xs tracking-[0.3em] uppercase mb-2">{c.adminEyebrow}</div>
<h1 class="font-display italic font-semibold text-[var(--text)] text-4xl md:text-5xl tracking-tight leading-[1.05]"> <h1 class="font-display italic font-semibold text-[var(--text)] text-4xl md:text-5xl tracking-tight leading-[1.05]">
{title} {title}
</h1> </h1>
+95 -55
View File
@@ -1,15 +1,16 @@
--- ---
import '../styles/global.css'; import '../styles/global.css';
import 'katex/dist/katex.min.css';
import 'highlight.js/styles/atom-one-dark.css';
import '@fontsource-variable/fraunces'; import '@fontsource-variable/fraunces';
import '@fontsource-variable/eb-garamond'; import '@fontsource-variable/eb-garamond';
import '@fontsource/caveat';
import '@fontsource-variable/jetbrains-mono'; import '@fontsource-variable/jetbrains-mono';
import ThemeSwitcher from '../components/react/ThemeSwitcher'; import '@fontsource/vt323';
import '@fontsource/space-mono';
import '@fontsource/space-mono/700.css';
import CyberFx from '../components/CyberFx.astro';
import Search from '../components/react/Search'; import Search from '../components/react/Search';
import LogoutButton from '../components/react/LogoutButton'; import LogoutButton from '../components/react/LogoutButton';
import EditableText from '../components/react/EditableText'; import EditableText from '../components/react/EditableText';
import { getSiteMode, copy } from '../lib/siteMode';
interface Props { interface Props {
title: string; title: string;
@@ -17,20 +18,35 @@ interface Props {
description?: string; description?: string;
image?: string; image?: string;
type?: 'website' | 'article'; type?: 'website' | 'article';
/** Strips the top-bar controls and footer nav — used by the login page
* so the sign-in screen is a focused, chrome-free stage. */
minimal?: boolean;
} }
const { title, wide = false, description, image, type = 'website' } = Astro.props; const { title, wide = false, description, image, type = 'website', minimal = false } = Astro.props;
const siteMode = getSiteMode();
const c = copy(siteMode);
const API_URL = process.env.PUBLIC_API_URL || 'http://backend:3000'; const API_URL = process.env.PUBLIC_API_URL || 'http://backend:3000';
const isAdmin = Astro.cookies.get('admin_session')?.value === '1'; const isAdmin = Astro.cookies.get('admin_session')?.value === '1';
let siteConfig = { let siteConfig: {
title: string;
subtitle: string;
footer: string;
favicon: string;
theme: string;
custom_css: string;
contact_links?: { kind: string; label: string; value: string }[];
} = {
title: "Ela's Atelier", title: "Ela's Atelier",
subtitle: "Works on paper, canvas, and elsewhere", subtitle: "Works on paper, canvas, and elsewhere",
footer: "Hand-arranged with care", footer: "Hand-arranged with care",
favicon: "/favicon.svg", favicon: "/favicon.svg",
theme: "salon", theme: "salon",
custom_css: "" custom_css: "",
contact_links: []
}; };
try { try {
@@ -44,13 +60,14 @@ try {
const fullTitle = `${title} · ${siteConfig.title}`; const fullTitle = `${title} · ${siteConfig.title}`;
const year = new Date().getFullYear(); const year = new Date().getFullYear();
const hasContact = (siteConfig.contact_links?.length ?? 0) > 0;
--- ---
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" class={`mode-${siteMode}`}>
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href={siteConfig.favicon} /> <link rel="icon" href={siteConfig.favicon} />
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<title>{fullTitle}</title> <title>{fullTitle}</title>
@@ -67,9 +84,19 @@ const year = new Date().getFullYear();
{image && <meta name="twitter:image" content={image} />} {image && <meta name="twitter:image" content={image} />}
<link rel="alternate" type="application/rss+xml" title={siteConfig.title} href="/feed.xml" /> <link rel="alternate" type="application/rss+xml" title={siteConfig.title} href="/feed.xml" />
{siteConfig.custom_css && <style set:html={siteConfig.custom_css} />} {siteConfig.custom_css && <style set:html={siteConfig.custom_css} />}
<script is:inline define:vars={{ defaultTheme: siteConfig.theme }}> <script is:inline define:vars={{ siteTheme: siteConfig.theme }}>
const savedTheme = localStorage.getItem('user-theme') || defaultTheme || 'salon'; // Theme is owner-controlled (site config). Drop any legacy
document.documentElement.classList.add(savedTheme); // per-visitor override so everyone sees the configured theme.
try { localStorage.removeItem('user-theme'); } catch (e) {}
document.documentElement.classList.add(siteTheme || 'salon');
</script>
<script is:inline>
// When a page is restored from the back/forward cache (e.g. after
// saving in the editor and hitting Back), the SSR'd post grid is
// stale. Force a fresh fetch so newly edited tags / titles show up.
window.addEventListener('pageshow', function (e) {
if (e.persisted) window.location.reload();
});
</script> </script>
<slot name="head" /> <slot name="head" />
</head> </head>
@@ -77,11 +104,11 @@ const year = new Date().getFullYear();
<div class="salon-atmosphere" aria-hidden="true"></div> <div class="salon-atmosphere" aria-hidden="true"></div>
<header class="border-b border-[var(--surface2)]/60"> <header class="border-b border-[var(--surface2)]/60">
<div class="max-w-6xl mx-auto px-6 md:px-10 py-5 md:py-7 flex flex-col md:flex-row md:items-end gap-4 md:gap-6"> <div class={`max-w-6xl mx-auto px-6 md:px-10 py-5 md:py-7 flex flex-col gap-4 md:flex-row md:items-end md:gap-6 ${minimal ? 'justify-center text-center' : 'md:justify-between'}`}>
<a href="/" class="nameplate group" aria-label="Home"> <a href="/" class="nameplate group" aria-label="Home">
{isAdmin ? ( {isAdmin ? (
<EditableText <EditableText
client:load client:visible
initial={siteConfig.title} initial={siteConfig.title}
fieldKey="title" fieldKey="title"
isAdmin isAdmin
@@ -93,7 +120,7 @@ const year = new Date().getFullYear();
)} )}
{isAdmin ? ( {isAdmin ? (
<EditableText <EditableText
client:load client:visible
initial={siteConfig.subtitle} initial={siteConfig.subtitle}
fieldKey="subtitle" fieldKey="subtitle"
isAdmin isAdmin
@@ -105,27 +132,28 @@ const year = new Date().getFullYear();
)} )}
</a> </a>
<div class="flex-1 hidden md:flex items-end justify-center pb-1"> {!minimal && (
<span class="font-display italic text-[var(--subtext0)] text-sm tracking-wider">— exhibition est. {year} —</span> <nav class="topbar-cluster w-full md:w-auto" aria-label="Site controls">
</div> {hasContact && (
<a href="/contact" class="topbar-control">Contact</a>
<div class="flex flex-wrap items-center gap-3 justify-start md:justify-end"> )}
<Search client:load /> <Search client:idle mode={siteMode} />
{isAdmin && ( <span class="topbar-divider" aria-hidden="true"></span>
<div class="flex items-center gap-1 pl-3 ml-1 border-l border-[var(--surface2)]/60"> {isAdmin ? (
<LogoutButton client:idle />
) : (
<a <a
href="/admin" href="/admin/login"
class="chip chip-accent uppercase" class="topbar-control tc-collapse-sm"
title="Signed in as curator" aria-label="Admin login"
title="Admin login"
> >
<span class="w-1.5 h-1.5 rounded-full bg-[var(--rosewater)] animate-pulse"></span> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z"/><circle cx="16.5" cy="7.5" r=".5" fill="currentColor"/></svg>
Curator <span class="tc-label">Admin</span>
</a> </a>
<LogoutButton client:load /> )}
</div> </nav>
)} )}
<ThemeSwitcher client:only="react" defaultTheme={siteConfig.theme} />
</div>
</div> </div>
</header> </header>
@@ -133,30 +161,42 @@ const year = new Date().getFullYear();
<slot /> <slot />
</main> </main>
<footer class="max-w-6xl mx-auto px-6 md:px-10 py-12 md:py-16 text-center border-t border-[var(--surface2)]/40 mt-12"> <footer class={`max-w-6xl mx-auto px-6 md:px-10 text-center border-t border-[var(--surface2)]/40 ${minimal ? 'py-8 mt-8' : 'py-12 md:py-16 mt-12'}`}>
<div class="section-rule mb-6"> {!minimal && (
<span class="ornament">✦</span> <>
<span class="font-display italic text-[var(--subtext0)] text-sm">end of catalogue</span> <div class="section-rule mb-6">
<span class="ornament">✦</span> <span class="ornament">✦</span>
</div> <span class="font-display italic text-[var(--subtext0)] text-sm">{c.footerEnd}</span>
<p class="font-display italic text-base text-[var(--subtext1)] mb-2"> <span class="ornament">✦</span>
{isAdmin ? ( </div>
<EditableText <p class="font-display italic text-base text-[var(--subtext1)] mb-2">
client:load {isAdmin ? (
initial={siteConfig.footer} <EditableText
fieldKey="footer" client:visible
isAdmin initial={siteConfig.footer}
ariaLabel="footer text" fieldKey="footer"
className="inline" isAdmin
/> ariaLabel="footer text"
) : siteConfig.footer} className="inline"
</p> />
<div class="text-xs text-[var(--subtext0)] tracking-[0.2em] uppercase mb-3"> ) : siteConfig.footer}
<a href="/feed.xml" class="hover:text-[var(--mauve)] transition-colors">RSS Feed</a> </p>
</div> <div class="text-xs text-[var(--subtext0)] tracking-[0.2em] uppercase mb-3 flex items-center justify-center gap-3 flex-wrap">
<div class="text-[var(--overlay0)] text-xs italic"> <a href="/feed.xml" class="hover:text-[var(--mauve)] transition-colors">RSS Feed</a>
{hasContact && (
<>
<span class="text-[var(--overlay0)]" aria-hidden="true">·</span>
<a href="/contact" class="hover:text-[var(--mauve)] transition-colors">Contact</a>
</>
)}
</div>
</>
)}
<div class="site-copyright text-[var(--overlay0)] text-xs italic">
&copy; {year} · {siteConfig.title} &copy; {year} · {siteConfig.title}
</div> </div>
</footer> </footer>
<CyberFx />
</body> </body>
</html> </html>
+8 -1
View File
@@ -1,4 +1,4 @@
import type { Post, SiteConfig, Asset } from './types'; import type { Post, SiteConfig, Asset, ContactSubmission, Message } from './types';
async function apiFetch<T>(path: string, options: RequestInit = {}): Promise<T> { async function apiFetch<T>(path: string, options: RequestInit = {}): Promise<T> {
const headers: Record<string, string> = { const headers: Record<string, string> = {
@@ -67,3 +67,10 @@ export const uploadAsset = (file: File) => {
}; };
export const deleteAsset = (name: string) => export const deleteAsset = (name: string) =>
apiFetch<void>(`/uploads/${encodeURIComponent(name)}`, { method: 'DELETE' }); apiFetch<void>(`/uploads/${encodeURIComponent(name)}`, { method: 'DELETE' });
// Contact
export const submitContact = (data: ContactSubmission) =>
apiFetch<{ ok: boolean }>('/contact', { method: 'POST', body: JSON.stringify(data) });
export const listMessages = () => apiFetch<Message[]>('/messages');
export const deleteMessage = (id: string) =>
apiFetch<{ ok: boolean }>(`/messages/${encodeURIComponent(id)}`, { method: 'DELETE' });
+138
View File
@@ -0,0 +1,138 @@
/*
* Imperative confirm() / notify() that replace native window.confirm /
* window.alert. The site hydrates many independent React islands that share
* no React root, so this is a vanilla DOM singleton: any island (or inline
* script) can `await confirmDialog(...)`. Styling is class-driven, so it
* inherits every theme — including the breakcore neon/hazard layer — for free.
*/
export interface ConfirmOptions {
title: string;
message?: string;
confirmLabel?: string;
cancelLabel?: string;
/** Visual weight of the confirm button. Defaults to 'danger'. */
tone?: 'danger' | 'primary';
}
let activeCleanup: (() => void) | null = null;
export function confirmDialog(opts: ConfirmOptions): Promise<boolean> {
// Collapse any in-flight dialog (treat as cancel) before opening a new one.
activeCleanup?.();
return new Promise<boolean>(resolve => {
const {
title,
message,
confirmLabel = 'Confirm',
cancelLabel = 'Cancel',
tone = 'danger',
} = opts;
const lastFocused = document.activeElement as HTMLElement | null;
const prevOverflow = document.body.style.overflow;
document.body.style.overflow = 'hidden';
const overlay = document.createElement('div');
overlay.className = 'cdialog-overlay';
overlay.setAttribute('role', 'alertdialog');
overlay.setAttribute('aria-modal', 'true');
const backdrop = document.createElement('div');
backdrop.className = 'cdialog-backdrop';
backdrop.setAttribute('aria-hidden', 'true');
const panel = document.createElement('div');
panel.className = 'glass cdialog-panel';
const titleId = `cdlg-t-${Math.random().toString(36).slice(2)}`;
const h = document.createElement('h2');
h.className = 'cdialog-title';
h.id = titleId;
h.textContent = title;
overlay.setAttribute('aria-labelledby', titleId);
panel.appendChild(h);
if (message) {
const p = document.createElement('p');
p.className = 'cdialog-msg';
p.textContent = message;
panel.appendChild(p);
}
const actions = document.createElement('div');
actions.className = 'cdialog-actions';
const cancelBtn = document.createElement('button');
cancelBtn.type = 'button';
cancelBtn.className = 'btn btn--ghost';
cancelBtn.textContent = cancelLabel;
const confirmBtn = document.createElement('button');
confirmBtn.type = 'button';
confirmBtn.className = `btn ${tone === 'primary' ? 'btn--primary' : 'btn--danger'}`;
confirmBtn.textContent = confirmLabel;
actions.append(cancelBtn, confirmBtn);
panel.appendChild(actions);
overlay.append(backdrop, panel);
document.body.appendChild(overlay);
let settled = false;
function close(result: boolean) {
if (settled) return;
settled = true;
activeCleanup = null;
document.removeEventListener('keydown', onKey, true);
document.body.style.overflow = prevOverflow;
overlay.remove();
lastFocused?.focus?.();
resolve(result);
}
function onKey(e: KeyboardEvent) {
if (e.key === 'Escape') {
e.preventDefault();
close(false);
} else if (e.key === 'Tab') {
// Two-stop focus trap.
e.preventDefault();
const next = document.activeElement === confirmBtn ? cancelBtn : confirmBtn;
next.focus();
} else if (e.key === 'Enter' && document.activeElement === confirmBtn) {
e.preventDefault();
close(true);
}
}
backdrop.addEventListener('click', () => close(false));
cancelBtn.addEventListener('click', () => close(false));
confirmBtn.addEventListener('click', () => close(true));
document.addEventListener('keydown', onKey, true);
activeCleanup = () => close(false);
// Destructive default: focus Cancel so an accidental Enter is safe.
(tone === 'primary' ? confirmBtn : cancelBtn).focus();
});
}
/** Transient hovering toast at the top of the viewport. Replaces
* window.alert and the old inline save banners. */
export function notify(message: string, tone: 'error' | 'success' = 'error') {
document.querySelector('.toast[data-notify]')?.remove();
const el = document.createElement('div');
el.className = `toast toast--${tone}`;
el.dataset.notify = '';
el.setAttribute('role', tone === 'error' ? 'alert' : 'status');
el.textContent = message;
const dismiss = () => {
if (el.classList.contains('toast--out')) return;
el.classList.add('toast--out');
window.setTimeout(() => el.remove(), 220);
};
el.addEventListener('click', dismiss);
document.body.appendChild(el);
window.setTimeout(dismiss, 4500);
}
+72
View File
@@ -0,0 +1,72 @@
import { describe, expect, it } from 'vitest';
import { buildCybersigil, GLYPHS } from './cybersigil';
/** Deterministic LCG so a given seed reproduces a given sigil. */
function seeded(seed: number): () => number {
let s = seed >>> 0;
return () => {
s = (s * 1664525 + 1013904223) >>> 0;
return s / 4294967296;
};
}
describe('buildCybersigil', () => {
it('is deterministic for a fixed RNG', () => {
const a = buildCybersigil({ rng: seeded(42) });
const b = buildCybersigil({ rng: seeded(42) });
expect(a).toBe(b);
});
it('varies with the seed', () => {
expect(buildCybersigil({ rng: seeded(1) })).not.toBe(buildCybersigil({ rng: seeded(2) }));
});
it('emits a single well-formed root svg', () => {
const svg = buildCybersigil({ rng: seeded(7) });
expect(svg.startsWith('<svg')).toBe(true);
expect(svg.endsWith('</svg>')).toBe(true);
expect(svg.match(/<svg/g)).toHaveLength(1);
// no formatting holes leaked into the path data
expect(svg).not.toMatch(/NaN|undefined|Infinity/);
});
it('is vertically mirrored (two halves, one flipped about x=0)', () => {
const svg = buildCybersigil({ rng: seeded(7) });
expect(svg.match(/class="cs-sig-half"/g)).toHaveLength(2);
expect(svg).toContain('transform="scale(-1 1)"');
});
it('every stroke is pathLength-normalised for the carve animation', () => {
const svg = buildCybersigil({ rng: seeded(99) });
const paths = svg.match(/<path\b[^>]*>/g) ?? [];
expect(paths.length).toBeGreaterThan(0);
for (const p of paths) expect(p).toContain('pathLength="1"');
});
it('exposes a numeric, positive viewBox', () => {
const svg = buildCybersigil({ rng: seeded(7) });
const vb = svg.match(/viewBox="([^"]+)"/)?.[1] ?? '';
const nums = vb.split(/\s+/).map(Number);
expect(nums).toHaveLength(4);
expect(nums.every(Number.isFinite)).toBe(true);
expect(nums[2]).toBeGreaterThan(0); // width
expect(nums[3]).toBeGreaterThan(0); // height
});
it('honours the count option and stays bounded', () => {
const sparse = buildCybersigil({ count: 1, rng: seeded(5) });
const dense = buildCybersigil({ count: 9, rng: seeded(5) });
const n = (s: string) => (s.match(/<path/g) ?? []).length;
expect(n(dense)).toBeGreaterThan(n(sparse));
expect(n(dense)).toBeLessThanOrEqual(260); // MAX_PATHS(110) mirrored + ornaments
});
it('ships a non-empty glyph library with valid path data', () => {
expect(GLYPHS.length).toBeGreaterThan(0);
for (const g of GLYPHS) {
expect(g.w).toBeGreaterThan(0);
expect(g.h).toBeGreaterThan(0);
expect(g.d).toMatch(/^M/);
}
});
});
+235
View File
@@ -0,0 +1,235 @@
/*
* cybersigil — chaotic neo-tribal sigil generator.
*
* Cybersigilism's signature is dense, fractal, barbed linework with hard
* vertical symmetry. We grow it procedurally: a wavering central spine spawns
* recursive curved limbs, each scattering barbs and thin filament shadows and
* occasionally terminating in a small hand-drawn motif. The whole right-leaning
* tangle is mirrored about x=0 (scale(-1 1)); a spine that wobbles in +x while
* its mirror wobbles in x weaves the two halves into one symmetric growth.
*
* Strokes carry pathLength="1" so the CSS draw-on ("carve") animation needs no
* JS length measurement; an inline `--i` staggers the carve into waves.
* Output is decorative and self-generated (no user input) — safe to inject via
* innerHTML. Inert under non-cybersigil themes (all styling `.cybersigil`-scoped).
*/
export interface Glyph {
w: number;
h: number;
/** path data, local coords, anchored near origin */
d: string;
}
// Small hand-drawn motifs used as limb-tip flourishes — the deliberate,
// "carved on purpose" punctuation amid the procedural chaos.
export const GLYPHS: readonly Glyph[] = [
{ w: 18, h: 22, d: 'M0 0 Q16 5 14 14 Q12 21 0 22 M4 7 L10 3' },
{ w: 16, h: 16, d: 'M0 8 Q14 0 15 8 Q14 16 0 8 M8 2 L8 14' },
{ w: 14, h: 24, d: 'M0 0 L0 24 M0 6 L12 2 M0 14 L13 10 M0 21 L9 19' },
{ w: 20, h: 18, d: 'M0 9 Q10 -2 19 4 M19 4 L15 0 M19 4 L20 9 M0 9 L4 16' },
{ w: 15, h: 20, d: 'M0 0 Q14 6 13 13 Q12 19 0 19 M7 8 Q11 11 11 16' },
] as const;
export interface SigilOptions {
/** rough number of primary branch nodes; default random 610 */
count?: number;
/** injectable RNG (0..1); default Math.random */
rng?: () => number;
}
const H = 200; // internal canvas height (viewBox scales it to fit)
const PAD = 14;
const MAX_PATHS = 110; // safety ceiling; real density is bounded by the params
type Pt = [number, number];
export function buildCybersigil(opts: SigilOptions = {}): string {
const rng = opts.rng ?? Math.random;
const rnd = (a: number, b: number) => a + rng() * (b - a);
const pick = <T>(a: readonly T[]): T => a[Math.floor(rng() * a.length)];
const n = (v: number) => {
const r = Math.round(v * 10) / 10;
return Object.is(r, -0) ? '0' : String(r);
};
const parts: string[] = [];
let strokeCount = 0;
let maxX = 24;
const track = (x: number) => {
const ax = Math.abs(x);
if (ax > maxX) maxX = ax;
};
const emit = (d: string, cls: string) => {
if (strokeCount >= MAX_PATHS) return;
parts.push(
`<path class="${cls}" d="${d}" pathLength="1" style="--i:${strokeCount % 16}"/>`,
);
strokeCount++;
};
// Catmull-Rom → cubic Bézier through an ordered point list (organic sweep).
const spline = (pts: Pt[]): string => {
if (pts.length < 2) return '';
let d = `M${n(pts[0][0])} ${n(pts[0][1])}`;
for (let i = 0; i < pts.length - 1; i++) {
const p0 = pts[i - 1] ?? pts[i];
const p1 = pts[i];
const p2 = pts[i + 1];
const p3 = pts[i + 2] ?? p2;
const c1: Pt = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];
const c2: Pt = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];
d += `C${n(c1[0])} ${n(c1[1])} ${n(c2[0])} ${n(c2[1])} ${n(p2[0])} ${n(p2[1])}`;
track(c1[0]);
track(c2[0]);
track(p2[0]);
}
return d;
};
// A short spike, optionally kinked into a fang.
const barb = (base: Pt, ang: number, len: number) => {
const tip: Pt = [base[0] + Math.cos(ang) * len, base[1] + Math.sin(ang) * len];
if (tip[0] < -3) tip[0] = -3;
track(base[0]);
track(tip[0]);
if (rng() < 0.45) {
const mid: Pt = [
(base[0] + tip[0]) / 2 + Math.cos(ang + Math.PI / 2) * len * 0.3,
(base[1] + tip[1]) / 2 + Math.sin(ang + Math.PI / 2) * len * 0.3,
];
emit(
`M${n(base[0])} ${n(base[1])}Q${n(mid[0])} ${n(mid[1])} ${n(tip[0])} ${n(tip[1])}`,
'cs-sig-barb',
);
} else {
emit(`M${n(base[0])} ${n(base[1])}L${n(tip[0])} ${n(tip[1])}`, 'cs-sig-barb');
}
};
const ornament = (at: Pt, ang: number) => {
const g = pick(GLYPHS);
const s = rnd(0.45, 0.85);
const deg = (ang * 180) / Math.PI + rnd(-25, 25);
track(at[0] + g.w * s);
parts.push(
`<g transform="translate(${n(at[0])} ${n(at[1])}) rotate(${n(deg)}) scale(${n(s)})">` +
`<path class="cs-sig-orn" d="${g.d}" pathLength="1" style="--i:${strokeCount % 16}"/></g>`,
);
strokeCount++;
};
// Recursive limb: a curved sweep out from (ox,oy) along `ang`, hooking back,
// scattering barbs, shedding a filament shadow, branching, sometimes tipped
// with a motif.
const limb = (ox: number, oy: number, ang: number, scale: number, depth: number) => {
if (strokeCount >= MAX_PATHS) return;
const L = scale * rnd(34, 64);
const dx = Math.cos(ang) * L;
const dy = Math.sin(ang) * L;
const peak: Pt = [ox + dx, oy + dy];
const mid: Pt = [
ox + dx * 0.45 + Math.cos(ang + Math.PI / 2) * rnd(-10, 14),
oy + dy * 0.45 + Math.sin(ang + Math.PI / 2) * rnd(-10, 14),
];
// hook back toward the spine
const hook: Pt = [
peak[0] - Math.cos(ang) * L * rnd(0.3, 0.55),
peak[1] + Math.sin(ang + 0.7) * L * rnd(0.25, 0.5),
];
const tail: Pt = [Math.max(-2, hook[0] - L * rnd(0.2, 0.4)), hook[1] + rnd(-6, 10)];
const pts: Pt[] = [[ox, oy], mid, peak, hook, tail];
emit(spline(pts), 'cs-sig-main');
// terminal spike off the outermost point
barb(peak, ang + rnd(-0.5, 0.5), scale * rnd(8, 18));
// filament shadow trailing the main sweep
if (rng() < 0.4) {
const off = rnd(2, 6);
emit(
spline(
pts.map(
([x, y]) =>
[x + Math.cos(ang + Math.PI / 2) * off, y + Math.sin(ang + Math.PI / 2) * off] as Pt,
),
),
'cs-sig-fil',
);
}
// barb scatter along the chord
const nb = 1 + Math.floor(rng() * 2);
for (let k = 0; k < nb; k++) {
const t = (k + 1) / (nb + 1);
const seg = t < 0.5 ? [pts[0], pts[2], t * 2] : [pts[2], pts[4], (t - 0.5) * 2];
const a = seg[0] as Pt;
const b = seg[1] as Pt;
const tt = seg[2] as number;
const base: Pt = [a[0] + (b[0] - a[0]) * tt, a[1] + (b[1] - a[1]) * tt];
const side = k % 2 ? 1 : -1;
barb(base, ang + side * rnd(0.6, 1.3), scale * rnd(6, 16));
}
// recurse — one child curls off the mid/peak region
if (depth > 0 && rng() < 0.55) {
const from = rng() < 0.5 ? mid : peak;
limb(
from[0],
from[1],
ang + (rng() < 0.5 ? 1 : -1) * rnd(0.5, 1.2),
scale * rnd(0.42, 0.6),
depth - 1,
);
}
// motif flourish at a terminal tip
if (depth === 0 && rng() < 0.3) ornament(peak, ang);
};
// ── Wavering spine: a curve from top to bottom, gently bowing in +x.
const spineNodes = 5 + Math.floor(rng() * 3);
const spinePts: Pt[] = [];
for (let i = 0; i <= spineNodes; i++) {
const y = (H * i) / spineNodes;
const x = i === 0 || i === spineNodes ? 0 : rnd(0, 11);
spinePts.push([x, y]);
}
emit(spline(spinePts), 'cs-sig-main');
// ── Branch nodes ride the spine and throw limbs outward. Nodes are
// inset from the very ends and spread the full height so growth flows
// down the whole trunk rather than clumping at the top.
const nodes = opts.count ?? 7 + Math.floor(rng() * 3); // 79
for (let i = 0; i < nodes; i++) {
const t = 0.08 + (0.86 * (i + rnd(-0.25, 0.25))) / (nodes - 1);
const tc = Math.max(0.05, Math.min(0.95, t));
const si = Math.min(spinePts.length - 2, Math.floor(tc * (spinePts.length - 1)));
const sf = tc * (spinePts.length - 1) - si;
const a = spinePts[si];
const b = spinePts[si + 1];
const node: Pt = [a[0] + (b[0] - a[0]) * sf, a[1] + (b[1] - a[1]) * sf];
// later nodes lean downward so the lower trunk fills out
const bias = -0.25 + tc * 0.7;
const limbs = 1 + Math.floor(rng() * 2);
for (let l = 0; l < limbs; l++) {
const ang = bias + rnd(-0.55, 0.55);
limb(node[0], node[1], ang, rnd(0.65, 1.05), 1);
}
// the odd bare barb straight off the spine keeps the trunk prickly
if (rng() < 0.55) barb(node, bias + rnd(-0.3, 0.3), rnd(7, 14));
}
const half = parts.join('');
const minX = -(maxX + PAD);
const vbW = 2 * (maxX + PAD);
return (
`<svg class="cs-sigil" viewBox="${n(minX)} ${-PAD} ${n(vbW)} ${H + 2 * PAD}" ` +
`preserveAspectRatio="xMidYMid meet" aria-hidden="true" focusable="false" ` +
`xmlns="http://www.w3.org/2000/svg">` +
`<g class="cs-sig-half">${half}</g>` +
`<g class="cs-sig-half" transform="scale(-1 1)">${half}</g>` +
`</svg>`
);
}
+91 -3
View File
@@ -2,9 +2,38 @@ import { Marked } from 'marked';
import markedKatex from 'marked-katex-extension'; import markedKatex from 'marked-katex-extension';
import { markedHighlight } from 'marked-highlight'; import { markedHighlight } from 'marked-highlight';
import { gfmHeadingId } from 'marked-gfm-heading-id'; import { gfmHeadingId } from 'marked-gfm-heading-id';
import hljs from 'highlight.js'; import hljs from 'highlight.js/lib/core';
import bash from 'highlight.js/lib/languages/bash';
import css from 'highlight.js/lib/languages/css';
import diff from 'highlight.js/lib/languages/diff';
import go from 'highlight.js/lib/languages/go';
import javascript from 'highlight.js/lib/languages/javascript';
import json from 'highlight.js/lib/languages/json';
import markdown from 'highlight.js/lib/languages/markdown';
import python from 'highlight.js/lib/languages/python';
import rust from 'highlight.js/lib/languages/rust';
import shell from 'highlight.js/lib/languages/shell';
import sql from 'highlight.js/lib/languages/sql';
import typescript from 'highlight.js/lib/languages/typescript';
import xml from 'highlight.js/lib/languages/xml';
import yaml from 'highlight.js/lib/languages/yaml';
import DOMPurify from 'isomorphic-dompurify'; import DOMPurify from 'isomorphic-dompurify';
hljs.registerLanguage('bash', bash);
hljs.registerLanguage('css', css);
hljs.registerLanguage('diff', diff);
hljs.registerLanguage('go', go);
hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('json', json);
hljs.registerLanguage('markdown', markdown);
hljs.registerLanguage('python', python);
hljs.registerLanguage('rust', rust);
hljs.registerLanguage('shell', shell);
hljs.registerLanguage('sql', sql);
hljs.registerLanguage('typescript', typescript);
hljs.registerLanguage('xml', xml);
hljs.registerLanguage('yaml', yaml);
function escapeHtml(s: string): string { function escapeHtml(s: string): string {
return s return s
.replace(/&/g, '&amp;') .replace(/&/g, '&amp;')
@@ -50,8 +79,67 @@ const KATEX_TAGS = [
'mpadded', 'menclose', 'mpadded', 'menclose',
]; ];
export function renderMarkdown(src: string): string { export interface ImageDim { w: number; h: number }
const html = renderer.parse(src, { async: false }) as string; export type ImageDims = Record<string, ImageDim>;
function injectDimensions(html: string, dims?: ImageDims): string {
if (!dims) return html;
return html.replace(/<img\s+src="([^"]+)"([^>]*?)\s*\/?>/g, (match, src, rest) => {
const d = dims[src];
if (!d) return match;
if (/\swidth\s*=/.test(rest) || /\sheight\s*=/.test(rest)) return match;
return `<img src="${src}" width="${d.w}" height="${d.h}"${rest} />`;
});
}
// Marked emits `<p><figure>…</figure></p>` because the image renderer returns
// a block element from an inline slot. Strip the `<p>` wrapper when the
// paragraph contains nothing but figures (and whitespace / <br>), so the
// figure-grouping step below can see contiguous runs.
function unwrapFiguresFromParagraphs(html: string): string {
return html.replace(/<p>([\s\S]*?)<\/p>/g, (match, inner: string) => {
const stripped = inner.replace(/<br\s*\/?>/g, '').trim();
if (!stripped) return match;
if (/^(?:\s*<figure>[\s\S]*?<\/figure>\s*)+$/.test(stripped)) {
return stripped;
}
return match;
});
}
// Wrap runs of 2+ consecutive <figure> elements in a `.figure-row` flex
// container. Each figure gets `flex: <aspect-ratio>` so widths divide the
// row proportionally and the final heights match.
function groupFigures(html: string): string {
return html.replace(
/(?:<figure>[\s\S]*?<\/figure>\s*){2,}/g,
(run) => {
const figures = run.match(/<figure>[\s\S]*?<\/figure>/g) ?? [];
const items = figures.map((fig) => {
const m = fig.match(/<img[^>]*\swidth="(\d+)"[^>]*\sheight="(\d+)"/);
const ratio = m ? Number(m[1]) / Number(m[2]) : 1;
const safe = Number.isFinite(ratio) && ratio > 0 ? ratio : 1;
const r = safe.toFixed(3);
// flex-basis tracks target row height (var --row-h) × aspect ratio,
// so the browser fits as many figures per row as it can while keeping
// each at roughly the target height; the rest wrap. max-width caps
// any leftover row so a lone last image doesn't balloon.
const style = [
`flex:${r} ${r} calc(${r} * var(--row-h, 16rem))`,
`max-width:calc(${r} * var(--row-max, 30rem))`,
].join(';');
return fig.replace('<figure>', `<figure style="${style}">`);
});
return `<div class="figure-row">${items.join('')}</div>`;
},
);
}
export function renderMarkdown(src: string, dims?: ImageDims): string {
let html = renderer.parse(src, { async: false }) as string;
html = injectDimensions(html, dims);
html = unwrapFiguresFromParagraphs(html);
html = groupFigures(html);
return DOMPurify.sanitize(html, { return DOMPurify.sanitize(html, {
ADD_TAGS: [...KATEX_TAGS, 'figure', 'figcaption'], ADD_TAGS: [...KATEX_TAGS, 'figure', 'figcaption'],
ADD_ATTR: ['aria-hidden', 'style', 'id', 'class', 'encoding', 'mathvariant', 'displaystyle', 'scriptlevel', 'loading'], ADD_ATTR: ['aria-hidden', 'style', 'id', 'class', 'encoding', 'mathvariant', 'displaystyle', 'scriptlevel', 'loading'],
+99
View File
@@ -0,0 +1,99 @@
// Site presentation mode. The atelier skin (fonts, cybersigil/breakcore
// themes, paper grain, CyberFx) is identical in both modes — only the *focus*
// flips: `atelier` puts images first (justified gallery plates, "plates"
// count), `blog` puts writing first (stacked rows, excerpts, reading time).
//
// Resolved server-side from the SITE_MODE env var. React islands cannot read
// process.env in the browser, so pages pass the resolved mode down as a prop;
// islands then look up COPY by mode.
export type SiteMode = 'blog' | 'atelier';
/** Server-side only. Defaults to atelier for any unset/unknown value. */
export function getSiteMode(): SiteMode {
const v = typeof process !== 'undefined' ? process.env.SITE_MODE : undefined;
return v === 'blog' ? 'blog' : 'atelier';
}
/**
* Mode-keyed user-facing strings. Atelier keeps the gallery voice; blog
* neutralises it. Anything not voice-flavoured (e.g. "Search", "Cancel")
* stays out of here so there's no needless duplication.
*/
export const COPY = {
atelier: {
indexTitle: 'Catalogue',
backHome: 'Back to catalogue',
adminBack: 'Back to the catalogue',
adminEyebrow: "Artist's desk",
footerEnd: 'end of catalogue',
loadingMore: 'arranging more…',
draftShort: 'Sketch',
draftLong: 'Sketch · unpublished',
searchPlaceholder: 'Search the catalogue…',
searchAria: 'Search the catalogue',
searchFetching: 'Fetching the catalogue…',
searchEmpty: 'The catalogue is empty.',
searchNoMatch: 'No works match.',
deleteListTitle: 'Take this off the wall?',
deleteListMsg: (t: string) =>
`${t}” will be removed from the catalogue. This cannot be undone.`,
deleteListConfirm: 'Remove',
deleteListCancel: 'Keep',
deletePostTitle: 'Delete this work?',
deletePostMsg: (t: string) => `${t}” will be permanently removed. This cannot be undone.`,
postNotFound: 'Work not found in the catalogue',
returnHome: 'Return to the catalogue',
notFoundTitle: 'Not in the catalogue',
notFoundDesc: "The work you're looking for is not on view.",
notFoundRule: 'Pardon — the gallery has misplaced this work',
notFoundHead: 'This piece is not on view.',
notFoundBody:
'The room you reached for has either been re-hung, withdrawn,|or never made it to the wall in the first place.',
editorTitlePh: 'Untitled (charcoal on paper)',
editorSlugPh: 'untitled-charcoal-on-paper',
editorDraftLabel: 'Sketch (draft)',
editorSummaryPh: 'A short caption for the catalogue index...',
editorSummaryLabel: 'Caption (optional)',
editorTagsPh: 'oil, paper, 2026, study',
},
blog: {
indexTitle: 'Posts',
backHome: 'Back to posts',
adminBack: 'Back to posts',
adminEyebrow: 'Dashboard',
footerEnd: 'end of posts',
loadingMore: 'loading more…',
draftShort: 'Draft',
draftLong: 'Draft · unpublished',
searchPlaceholder: 'Search posts…',
searchAria: 'Search posts',
searchFetching: 'Loading posts…',
searchEmpty: 'No posts yet.',
searchNoMatch: 'No posts match.',
deleteListTitle: 'Delete this post?',
deleteListMsg: (t: string) => `${t}” will be permanently deleted. This cannot be undone.`,
deleteListConfirm: 'Delete',
deleteListCancel: 'Cancel',
deletePostTitle: 'Delete this post?',
deletePostMsg: (t: string) => `${t}” will be permanently deleted. This cannot be undone.`,
postNotFound: 'Post not found',
returnHome: 'Return to posts',
notFoundTitle: 'Post not found',
notFoundDesc: "The post you're looking for doesn't exist.",
notFoundRule: 'This page could not be found',
notFoundHead: 'Nothing here.',
notFoundBody:
'The post you reached for has either moved, been unpublished,|or never existed in the first place.',
editorTitlePh: 'Post title',
editorSlugPh: 'post-slug',
editorDraftLabel: 'Draft',
editorSummaryPh: 'A short summary for the index...',
editorSummaryLabel: 'Summary (optional)',
editorTagsPh: 'essay, notes, 2026',
},
} as const satisfies Record<SiteMode, Record<string, unknown>>;
export function copy(mode: SiteMode) {
return COPY[mode];
}
+29
View File
@@ -10,6 +10,14 @@ export interface Post {
reading_time: number; reading_time: number;
} }
export type ContactKind = 'email' | 'mastodon' | 'github' | 'bluesky' | 'instagram' | 'url';
export interface ContactLink {
kind: ContactKind | string;
label: string;
value: string;
}
export interface SiteConfig { export interface SiteConfig {
title: string; title: string;
subtitle: string; subtitle: string;
@@ -19,9 +27,30 @@ export interface SiteConfig {
favicon: string; favicon: string;
theme: string; theme: string;
custom_css: string; custom_css: string;
contact_intro: string;
contact_links: ContactLink[];
} }
export interface Asset { export interface Asset {
name: string; name: string;
url: string; url: string;
} }
export interface ContactSubmission {
name?: string;
email?: string;
subject?: string;
message: string;
website?: string;
started_at: number;
}
export interface Message {
id: string;
name?: string;
email?: string;
subject?: string;
body: string;
received_at: number;
ip_hash?: string;
}
+10 -6
View File
@@ -1,24 +1,28 @@
--- ---
import Layout from '../layouts/Layout.astro'; import Layout from '../layouts/Layout.astro';
import { getSiteMode, copy } from '../lib/siteMode';
const c = copy(getSiteMode());
const [bodyA, bodyB] = c.notFoundBody.split('|');
--- ---
<Layout title="Not in the catalogue" description="The work you're looking for is not on view."> <Layout title={c.notFoundTitle} description={c.notFoundDesc}>
<div class="max-w-2xl mx-auto py-16 md:py-24 text-center"> <div class="max-w-2xl mx-auto py-16 md:py-24 text-center">
<div class="numeral text-[var(--mauve)] text-[8rem] md:text-[12rem] leading-none mb-4"> <div class="numeral text-[var(--mauve)] text-[8rem] md:text-[12rem] leading-none mb-4">
CDIV CDIV
</div> </div>
<div class="section-rule max-w-sm mx-auto mb-8"> <div class="section-rule max-w-sm mx-auto mb-8">
<span class="ornament">✦</span> <span class="ornament">✦</span>
<span>Pardon — the gallery has misplaced this work</span> <span>{c.notFoundRule}</span>
<span class="ornament">✦</span> <span class="ornament">✦</span>
</div> </div>
<h1 class="font-display italic text-3xl md:text-5xl text-[var(--text)] mb-6 leading-tight"> <h1 class="font-display italic text-3xl md:text-5xl text-[var(--text)] mb-6 leading-tight">
This piece is not on view. {c.notFoundHead}
</h1> </h1>
<p class="text-[var(--subtext1)] font-sans text-lg mb-10 leading-relaxed"> <p class="text-[var(--subtext1)] font-sans text-lg mb-10 leading-relaxed">
The room you reached for has either been re-hung, withdrawn,<br class="hidden md:block" /> {bodyA}<br class="hidden md:block" />
or never made it to the wall in the first place. {bodyB}
</p> </p>
<a href="/" class="btn-stamp">↶ Return to the catalogue</a> <a href="/" class="btn btn--primary">↶ {c.returnHome}</a>
</div> </div>
</Layout> </Layout>
+4 -1
View File
@@ -1,11 +1,14 @@
--- ---
import 'katex/dist/katex.min.css';
import AdminLayout from '../../layouts/AdminLayout.astro'; import AdminLayout from '../../layouts/AdminLayout.astro';
import Editor from '../../components/react/admin/Editor'; import Editor from '../../components/react/admin/Editor';
import { getSiteMode } from '../../lib/siteMode';
const editSlug = Astro.url.searchParams.get('edit') || undefined; const editSlug = Astro.url.searchParams.get('edit') || undefined;
const siteMode = getSiteMode();
--- ---
<AdminLayout title="Write Post" wide> <AdminLayout title="Write Post" wide>
<p slot="header-subtitle" class="mt-2 text-sm md:text-base" style="color: var(--text) !important;">Create/Edit post.</p> <p slot="header-subtitle" class="mt-2 text-sm md:text-base" style="color: var(--text) !important;">Create/Edit post.</p>
<Editor client:only="react" editSlug={editSlug} /> <Editor client:only="react" editSlug={editSlug} mode={siteMode} />
</AdminLayout> </AdminLayout>
+5 -2
View File
@@ -1,8 +1,11 @@
--- ---
import Layout from '../../layouts/Layout.astro'; import Layout from '../../layouts/Layout.astro';
import Login from '../../components/react/admin/Login'; import Login from '../../components/react/admin/Login';
import { getSiteMode } from '../../lib/siteMode';
const siteMode = getSiteMode();
--- ---
<Layout title="Admin Login"> <Layout title="Admin Login" description="Sign in to the back room." minimal>
<Login client:only="react" /> <Login client:only="react" mode={siteMode} />
</Layout> </Layout>
+9
View File
@@ -0,0 +1,9 @@
---
import AdminLayout from '../../layouts/AdminLayout.astro';
import Inbox from '../../components/react/admin/Inbox';
---
<AdminLayout title="Messages">
<p slot="header-subtitle" class="mt-2 text-sm md:text-base" style="color: var(--text) !important;">Notes sent from the public contact page.</p>
<Inbox client:only="react" />
</AdminLayout>
+18 -10
View File
@@ -2,6 +2,13 @@ import type { APIRoute } from 'astro';
const FORBIDDEN_HEADERS = new Set([ const FORBIDDEN_HEADERS = new Set([
'host', 'connection', 'content-length', 'transfer-encoding', 'origin', 'referer', 'host', 'connection', 'content-length', 'transfer-encoding', 'origin', 'referer',
'accept-encoding',
]);
// Node fetch auto-decompresses the response body, so any encoding/length
// headers from the upstream no longer match what we forward to the browser.
const FORBIDDEN_RESPONSE_HEADERS = new Set([
'content-encoding', 'content-length', 'transfer-encoding',
]); ]);
export const ALL: APIRoute = async ({ request, params }) => { export const ALL: APIRoute = async ({ request, params }) => {
@@ -29,25 +36,26 @@ export const ALL: APIRoute = async ({ request, params }) => {
headers, headers,
}; };
if (request.method !== 'GET' && request.method !== 'HEAD') { if (request.method !== 'GET' && request.method !== 'HEAD' && request.body) {
const reqClone = request.clone(); fetchOptions.body = request.body;
if (request.method !== 'DELETE' || reqClone.body) { // @ts-expect-error — required by Node fetch when body is a stream
fetchOptions.body = reqClone.body; fetchOptions.duplex = 'half';
// @ts-ignore — required by Node fetch when body is a stream
fetchOptions.duplex = 'half';
}
} }
const response = await fetch(url.toString(), fetchOptions); const response = await fetch(url.toString(), fetchOptions);
const responseHeaders = new Headers(); const responseHeaders = new Headers();
response.headers.forEach((value, key) => { response.headers.forEach((value, key) => {
const k = key.toLowerCase();
// Set-Cookie can repeat and must NOT be merged. Handle it separately below. // Set-Cookie can repeat and must NOT be merged. Handle it separately below.
if (key.toLowerCase() === 'set-cookie') return; if (k === 'set-cookie') return;
if (FORBIDDEN_RESPONSE_HEADERS.has(k)) return;
responseHeaders.set(key, value); responseHeaders.set(key, value);
}); });
// @ts-ignore — getSetCookie is on Node fetch's Headers // getSetCookie is present on Node/undici Headers; type it locally so we
const setCookies: string[] = response.headers.getSetCookie?.() ?? []; // neither depend on a specific @types/node nor need a ts-suppression.
const h = response.headers as Headers & { getSetCookie?: () => string[] };
const setCookies: string[] = h.getSetCookie?.() ?? [];
for (const c of setCookies) { for (const c of setCookies) {
responseHeaders.append('set-cookie', c); responseHeaders.append('set-cookie', c);
} }
+153
View File
@@ -0,0 +1,153 @@
---
import Layout from '../layouts/Layout.astro';
import ContactForm from '../components/react/ContactForm';
interface ContactLink {
kind: string;
label: string;
value: string;
}
interface SiteConfig {
contact_intro?: string;
contact_links?: ContactLink[];
}
const API_URL = process.env.PUBLIC_API_URL || 'http://localhost:3000';
let siteConfig: SiteConfig = {};
let error = '';
try {
const res = await fetch(`${API_URL}/api/config`);
if (res.ok) {
siteConfig = await res.json();
} else {
error = 'Failed to load contact details.';
}
} catch (e) {
error = `Could not connect to backend: ${e instanceof Error ? e.message : String(e)}`;
console.error(error);
}
const links: ContactLink[] = siteConfig.contact_links ?? [];
const intro = siteConfig.contact_intro ?? '';
const KIND_LABEL: Record<string, string> = {
email: 'Email',
mastodon: 'Mastodon',
bluesky: 'Bluesky',
github: 'GitHub',
instagram: 'Instagram',
url: 'Link',
};
function b64(s: string): string {
return Buffer.from(s, 'utf-8').toString('base64');
}
function obfuscateEmail(addr: string): { user: string; host: string; display: string; u64: string; h64: string } | null {
const at = addr.indexOf('@');
if (at === -1) return null;
const user = addr.slice(0, at);
const host = addr.slice(at + 1);
const display = `${user} [at] ${host.replace(/\./g, ' [dot] ')}`;
return { user, host, display, u64: b64(user), h64: b64(host) };
}
---
<Layout title="Contact" description="Get in touch.">
<section class="max-w-2xl mx-auto">
<div class="mb-10 md:mb-14">
<div class="font-display italic text-[var(--subtext0)] text-xs tracking-[0.3em] uppercase mb-4">Correspondence</div>
<h1 class="font-display italic font-semibold text-[var(--text)] text-5xl md:text-6xl leading-[1.08] tracking-tight mb-6">
Get in touch
</h1>
{intro && (
<p class="font-sans text-lg text-[var(--subtext1)] leading-relaxed whitespace-pre-line">
{intro}
</p>
)}
</div>
{error && (
<div class="glass p-6 text-center mb-8 border-[var(--red)]/40">
<p class="font-display italic text-[var(--red)]">{error}</p>
</div>
)}
{links.length > 0 && (
<ul class="space-y-3 mb-12">
{links.map((link) => {
const isEmail = link.kind === 'email';
const obf = isEmail ? obfuscateEmail(link.value.trim()) : null;
return (
<li>
<a
href={obf ? '#' : link.value}
{...(!isEmail ? { target: '_blank', rel: 'noopener noreferrer me' } : {})}
{...(obf ? { 'data-mail': '', 'data-mail-u': obf.u64, 'data-mail-h': obf.h64 } : {})}
class="group grid md:grid-cols-[1fr_minmax(0,auto)] gap-2 md:gap-6 px-5 md:px-6 py-4 md:items-baseline border border-[var(--surface2)]/60 hover:border-[var(--mauve)]/60 transition-colors"
style="border-radius: 1px"
>
<div class="min-w-0">
<div class="font-display italic text-[11px] uppercase tracking-[0.18em] text-[var(--subtext0)] mb-1 pr-1">
{KIND_LABEL[link.kind] ?? link.kind}
</div>
<div class="font-display italic text-xl md:text-2xl text-[var(--text)] group-hover:text-[var(--mauve)] transition-colors break-words">
{link.label}
</div>
</div>
<div
class="font-mono text-xs text-[var(--subtext0)] md:text-right break-words min-w-0"
title={obf ? obf.display : link.value}
data-mail-text={obf ? '' : undefined}
>
{obf ? obf.display : link.value}
</div>
</a>
</li>
);
})}
</ul>
)}
<div class="mt-8">
<h2 class="font-display italic text-2xl md:text-3xl text-[var(--text)] border-l-2 border-[var(--mauve)] pl-4 mb-6">
Or send a note directly
</h2>
<ContactForm client:idle />
</div>
<div class="section-rule mt-16">
<span class="ornament">✦</span>
</div>
</section>
</Layout>
<script>
function hydrateMail() {
document.querySelectorAll<HTMLAnchorElement>('a[data-mail]').forEach((a) => {
const u = a.dataset.mailU;
const h = a.dataset.mailH;
if (!u || !h) return;
try {
const user = atob(u);
const host = atob(h);
const addr = `${user}@${host}`;
a.href = `mailto:${addr}`;
a.querySelectorAll<HTMLElement>('[data-mail-text]').forEach((el) => {
el.textContent = addr;
el.setAttribute('title', addr);
});
} catch {
// leave obfuscated form
}
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', hydrateMail);
} else {
hydrateMail();
}
</script>
+33 -29
View File
@@ -3,12 +3,18 @@ import Layout from '../layouts/Layout.astro';
import PostList from '../components/react/PostList'; import PostList from '../components/react/PostList';
import EditableText from '../components/react/EditableText'; import EditableText from '../components/react/EditableText';
import AssetsButton from '../components/react/AssetsButton'; import AssetsButton from '../components/react/AssetsButton';
import { getSiteMode, copy } from '../lib/siteMode';
const siteMode = getSiteMode();
const c = copy(siteMode);
const API_URL = process.env.PUBLIC_API_URL || 'http://localhost:3000'; const API_URL = process.env.PUBLIC_API_URL || 'http://localhost:3000';
interface CoverImage { interface CoverImage {
url: string; url: string;
alt: string; alt: string;
w?: number;
h?: number;
} }
interface Post { interface Post {
@@ -31,9 +37,12 @@ let siteConfig = {
welcome_subtitle: "An ongoing arrangement of pieces, sketches, and stray observations." welcome_subtitle: "An ongoing arrangement of pieces, sketches, and stray observations."
}; };
const cookieHeader = Astro.request.headers.get('cookie') ?? '';
const fetchHeaders: HeadersInit = cookieHeader ? { cookie: cookieHeader } : {};
try { try {
const [postsRes, configRes] = await Promise.all([ const [postsRes, configRes] = await Promise.all([
fetch(`${API_URL}/api/posts`), fetch(`${API_URL}/api/posts`, { headers: fetchHeaders }),
fetch(`${API_URL}/api/config`) fetch(`${API_URL}/api/config`)
]); ]);
@@ -53,17 +62,20 @@ try {
} }
const isAdmin = Astro.cookies.get('admin_session')?.value === '1'; const isAdmin = Astro.cookies.get('admin_session')?.value === '1';
const total = posts.length;
--- ---
<Layout title="Catalogue" description={siteConfig.welcome_subtitle}> <Layout title={c.indexTitle} description={siteConfig.welcome_subtitle}>
{posts[0]?.cover_image?.url && (
<Fragment slot="head">
<link rel="preload" as="image" href={posts[0].cover_image.url} fetchpriority="high" />
</Fragment>
)}
<section class="relative mb-16 md:mb-24"> <section class="relative mb-16 md:mb-24">
<div class="flex flex-col md:flex-row md:items-end gap-8 md:gap-12"> <div class="max-w-2xl">
<div class="flex-1 max-w-2xl"> <h1 class="font-display italic font-semibold text-[var(--text)] text-5xl md:text-7xl lg:text-8xl leading-[1.08] tracking-tight mb-6">
<h1 class="font-display italic font-semibold text-[var(--text)] text-5xl md:text-7xl lg:text-8xl leading-[0.95] tracking-tight mb-6">
{isAdmin ? ( {isAdmin ? (
<EditableText <EditableText
client:load client:visible
initial={siteConfig.welcome_title} initial={siteConfig.welcome_title}
fieldKey="welcome_title" fieldKey="welcome_title"
isAdmin isAdmin
@@ -75,7 +87,7 @@ const total = posts.length;
<p class="font-sans text-lg md:text-xl text-[var(--subtext1)] leading-relaxed max-w-xl"> <p class="font-sans text-lg md:text-xl text-[var(--subtext1)] leading-relaxed max-w-xl">
{isAdmin ? ( {isAdmin ? (
<EditableText <EditableText
client:load client:visible
initial={siteConfig.welcome_subtitle} initial={siteConfig.welcome_subtitle}
fieldKey="welcome_subtitle" fieldKey="welcome_subtitle"
isAdmin isAdmin
@@ -88,29 +100,21 @@ const total = posts.length;
{isAdmin && ( {isAdmin && (
<div class="mt-8 flex flex-wrap items-center gap-3"> <div class="mt-8 flex flex-wrap items-center gap-3">
<a href="/admin/editor" class="btn-stamp"> <a href="/admin/editor" class="btn btn--primary">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M12 5v14"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M12 5v14"/></svg>
Hang new work New work
</a> </a>
<AssetsButton client:load /> <AssetsButton client:idle className="btn btn--ghost" iconSize={14} />
<a href="/admin/settings" class="btn-ghost"> <a href="/admin/messages" class="btn btn--ghost">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg>
Messages
</a>
<a href="/admin/settings" class="btn btn--ghost">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/></svg>
Settings Settings
</a> </a>
</div> </div>
)} )}
</div>
<aside class="md:w-64 lg:w-80 shrink-0 md:pb-2">
<div class="font-display italic text-[var(--subtext0)] text-xs tracking-[0.3em] uppercase mb-2">Index</div>
<div class="numeral text-5xl md:text-6xl text-[var(--mauve)] leading-none mb-3">
{String(total).padStart(2, '0')}
</div>
<div class="font-display italic text-[var(--subtext1)] text-base leading-snug">
{total === 1 ? 'work hanging' : 'works hanging'},
<span class="font-hand text-[var(--mauve)] text-xl ml-1">arranged below</span>
</div>
</aside>
</div> </div>
</section> </section>
@@ -122,16 +126,16 @@ const total = posts.length;
{posts.length === 0 && !error && ( {posts.length === 0 && !error && (
<div class="glass p-12 md:p-20 text-center max-w-2xl mx-auto"> <div class="glass p-12 md:p-20 text-center max-w-2xl mx-auto">
<div class="font-display italic text-[var(--subtext0)] text-sm tracking-[0.3em] uppercase mb-4">Notice</div> <div class="font-display italic text-[var(--subtext0)] text-sm tracking-[0.3em] uppercase mb-4">Nothing here yet</div>
<p class="font-display italic text-[var(--text)] text-2xl md:text-3xl leading-snug mb-2"> <p class="font-display italic text-[var(--text)] text-2xl md:text-3xl leading-snug mb-2">
The exhibition is currently being arranged. No posts to show.
</p> </p>
<p class="font-sans text-[var(--subtext1)] mt-4">Please return shortly.</p> <p class="font-sans text-[var(--subtext1)] mt-4">Check back soon.</p>
{isAdmin && ( {isAdmin && (
<a href="/admin/editor" class="btn-stamp mt-8">Hang the first work</a> <a href="/admin/editor" class="btn btn--primary mt-8">Create the first post</a>
)} )}
</div> </div>
)} )}
{posts.length > 0 && <PostList posts={posts} isAdmin={isAdmin} client:load />} {posts.length > 0 && <PostList posts={posts} isAdmin={isAdmin} mode={siteMode} client:idle />}
</Layout> </Layout>
+66 -79
View File
@@ -1,12 +1,22 @@
--- ---
import 'katex/dist/katex.min.css';
import Layout from '../../layouts/Layout.astro'; import Layout from '../../layouts/Layout.astro';
import DeletePostButton from '../../components/react/DeletePostButton'; import DeletePostButton from '../../components/react/DeletePostButton';
import { renderMarkdown } from '../../lib/markdown'; import { renderMarkdown } from '../../lib/markdown';
import { getSiteMode, copy } from '../../lib/siteMode';
const siteMode = getSiteMode();
const isBlog = siteMode === 'blog';
const c = copy(siteMode);
const { slug } = Astro.params; const { slug } = Astro.params;
const API_URL = (typeof process !== 'undefined' ? process.env.PUBLIC_API_URL : import.meta.env.PUBLIC_API_URL) || 'http://localhost:3000'; const API_URL = (typeof process !== 'undefined' ? process.env.PUBLIC_API_URL : import.meta.env.PUBLIC_API_URL) || 'http://localhost:3000';
interface CoverImage { url: string; alt: string } interface CoverImage { url: string; alt: string; w?: number; h?: number }
interface PostNeighbor {
slug: string;
title?: string;
}
interface PostDetail { interface PostDetail {
slug: string; slug: string;
date: string; date: string;
@@ -18,29 +28,15 @@ interface PostDetail {
reading_time: number; reading_time: number;
cover_image?: CoverImage; cover_image?: CoverImage;
image_count: number; image_count: number;
} prev?: PostNeighbor;
interface PostInfo { next?: PostNeighbor;
slug: string; dimensions?: Record<string, { w: number; h: number }>;
title?: string;
} }
function formatDate(d: string) { function formatDate(d: string) {
return new Date(d).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); return new Date(d).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
} }
function toRoman(n: number): string {
const map: [number, string][] = [
[1000, 'M'], [900, 'CM'], [500, 'D'], [400, 'CD'],
[100, 'C'], [90, 'XC'], [50, 'L'], [40, 'XL'],
[10, 'X'], [9, 'IX'], [5, 'V'], [4, 'IV'], [1, 'I'],
];
let out = '';
for (const [val, sym] of map) {
while (n >= val) { out += sym; n -= val; }
}
return out;
}
function formatSlug(s: string) { function formatSlug(s: string) {
if (!s) return ''; if (!s) return '';
return s.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); return s.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
@@ -49,30 +45,17 @@ function formatSlug(s: string) {
let post: PostDetail | null = null; let post: PostDetail | null = null;
let html = ''; let html = '';
let error = ''; let error = '';
let neighbors: { prev?: PostInfo; next?: PostInfo; index: number; total: number } = { index: -1, total: 0 };
const cookieHeader = Astro.request.headers.get('cookie') ?? '';
const fetchHeaders: HeadersInit = cookieHeader ? { cookie: cookieHeader } : {};
try { try {
const [postRes, listRes] = await Promise.all([ const postRes = await fetch(`${API_URL}/api/posts/${encodeURIComponent(slug ?? '')}`, { headers: fetchHeaders });
fetch(`${API_URL}/api/posts/${encodeURIComponent(slug ?? '')}`),
fetch(`${API_URL}/api/posts`),
]);
if (postRes.ok) { if (postRes.ok) {
post = await postRes.json(); post = await postRes.json();
html = renderMarkdown(post!.content); html = renderMarkdown(post!.content, post!.dimensions);
} else { } else {
error = 'Work not found in the catalogue'; error = c.postNotFound;
}
if (listRes.ok) {
const list: PostInfo[] = await listRes.json();
const i = list.findIndex(p => p.slug === slug);
if (i >= 0) {
neighbors = {
index: i,
total: list.length,
prev: i > 0 ? list[i - 1] : undefined,
next: i < list.length - 1 ? list[i + 1] : undefined,
};
}
} }
} catch (e) { } catch (e) {
const cause = (e as any)?.cause; const cause = (e as any)?.cause;
@@ -80,9 +63,13 @@ try {
console.error(error); console.error(error);
} }
const neighbors = {
prev: post?.prev,
next: post?.next,
};
const isAdmin = Astro.cookies.get('admin_session')?.value === '1'; const isAdmin = Astro.cookies.get('admin_session')?.value === '1';
const displayTitle = post ? (post.title || formatSlug(post.slug)) : 'Work'; const displayTitle = post ? (post.title || formatSlug(post.slug)) : 'Work';
const exhibitNumber = neighbors.index >= 0 ? toRoman(neighbors.index + 1) : '';
--- ---
<Layout <Layout
@@ -91,54 +78,56 @@ const exhibitNumber = neighbors.index >= 0 ? toRoman(neighbors.index + 1) : '';
image={post?.cover_image?.url} image={post?.cover_image?.url}
type="article" type="article"
> >
{!isBlog && post?.cover_image?.url && (
<Fragment slot="head">
<link rel="preload" as="image" href={post.cover_image.url} fetchpriority="high" />
</Fragment>
)}
<div id="reading-progress" class="reading-progress" aria-hidden="true"></div> <div id="reading-progress" class="reading-progress" aria-hidden="true"></div>
{error && ( {error && (
<div class="max-w-2xl mx-auto py-20 md:py-32 text-center"> <div class="max-w-2xl mx-auto py-20 md:py-32 text-center">
<div class="font-display italic text-[var(--subtext0)] text-sm tracking-[0.3em] uppercase mb-4">Pardon —</div> <div class="font-display italic text-[var(--subtext0)] text-sm tracking-[0.3em] uppercase mb-4">Pardon —</div>
<h2 class="font-display italic text-3xl md:text-5xl text-[var(--mauve)] mb-6 leading-tight">{error}</h2> <h2 class="font-display italic text-3xl md:text-5xl text-[var(--mauve)] mb-6 leading-tight">{error}</h2>
<a href="/" class="btn-ghost">← Return to the catalogue</a> <a href="/" class="btn btn--ghost">← {c.returnHome}</a>
</div> </div>
)} )}
{post && ( {post && (
<article class="plate-enter"> <article class="plate-enter">
{/* Toolbar — exhibit nav */} {/* Toolbar — exhibit nav */}
<div class="flex items-center justify-between gap-3 mb-10 md:mb-14 font-display italic text-sm text-[var(--subtext0)]"> <div class="flex flex-wrap items-center justify-between gap-3 mb-10 md:mb-14 font-display italic text-sm text-[var(--subtext0)]">
<a href="/" class="inline-flex items-center gap-2 hover:text-[var(--mauve)] transition-colors group"> <a href="/" class="back-link">
<span class="transition-transform group-hover:-translate-x-1">←</span> <span class="bl-arrow" aria-hidden="true">←</span>
Back to catalogue {c.backHome}
</a> </a>
{isAdmin && ( {isAdmin && (
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<a href={`/admin/editor?edit=${encodeURIComponent(post.slug)}`} class="btn-ghost"> <a href={`/admin/editor?edit=${encodeURIComponent(post.slug)}`} class="btn btn--ghost">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
Edit Edit
</a> </a>
<DeletePostButton slug={post.slug} title={displayTitle} client:load /> <DeletePostButton slug={post.slug} title={displayTitle} mode={siteMode} client:idle />
</div> </div>
)} )}
</div> </div>
{/* Plaque header */} {/* Plaque header */}
<header class="max-w-3xl mx-auto text-center mb-12 md:mb-16"> <header class="max-w-3xl mx-auto text-center mb-12 md:mb-16">
{exhibitNumber && ( <h1 class="font-display italic font-semibold text-[var(--text)] text-4xl md:text-6xl lg:text-7xl leading-[1.08] tracking-tight mb-6">
<div class="font-display italic text-[var(--mauve)] tracking-[0.3em] text-sm mb-5">
№ {exhibitNumber} <span class="text-[var(--subtext0)] not-italic">/ {neighbors.total}</span>
</div>
)}
<h1 class="font-display italic font-semibold text-[var(--text)] text-4xl md:text-6xl lg:text-7xl leading-[0.95] tracking-tight mb-6">
{displayTitle} {displayTitle}
</h1> </h1>
<div class="section-rule max-w-md mx-auto mb-6"> <div class="section-rule max-w-md mx-auto mb-6">
<span class="ornament">✦</span> <span class="ornament">✦</span>
<span>{formatDate(post.date)}</span> <span>{formatDate(post.date)}</span>
<span class="ornament">·</span> {isBlog ? (
<span>{post.reading_time} min</span> <>
{post.image_count > 0 && ( <span class="ornament">·</span>
<span>{post.reading_time} min read</span>
</>
) : post.image_count > 0 && (
<> <>
<span class="ornament">·</span> <span class="ornament">·</span>
<span>{post.image_count} {post.image_count === 1 ? 'plate' : 'plates'}</span> <span>{post.image_count} {post.image_count === 1 ? 'plate' : 'plates'}</span>
@@ -155,8 +144,8 @@ const exhibitNumber = neighbors.index >= 0 ? toRoman(neighbors.index + 1) : '';
{post.draft && ( {post.draft && (
<div class="mt-6 inline-block"> <div class="mt-6 inline-block">
<span class="chip" style="background: var(--peach); color: var(--crust); border-color: var(--peach);"> <span class="chip chip-draft">
Sketch · unpublished {c.draftLong}
</span> </span>
</div> </div>
)} )}
@@ -171,17 +160,15 @@ const exhibitNumber = neighbors.index >= 0 ? toRoman(neighbors.index + 1) : '';
{/* Body — works on paper */} {/* Body — works on paper */}
<div id="post-content" class="prose" set:html={html} /> <div id="post-content" class="prose" set:html={html} />
{/* Closing — continue the room */} {isBlog ? (
<div class="max-w-3xl mx-auto mt-20 md:mt-28"> <div class="max-w-3xl mx-auto mt-20 md:mt-28 text-center">
<div class="section-rule mb-10"> <a href="/" class="btn btn--ghost">← {c.backHome}</a>
<span class="ornament">✦</span>
<span>continue the gallery</span>
<span class="ornament">✦</span>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> ) : (neighbors.prev || neighbors.next) && (
<nav class="post-nav max-w-3xl mx-auto mt-20 md:mt-28 grid grid-cols-1 md:grid-cols-2 gap-6" aria-label="Post navigation">
{neighbors.prev && ( {neighbors.prev && (
<a href={`/posts/${encodeURIComponent(neighbors.prev.slug)}`} class="group glass p-6 hover:border-[var(--mauve)] transition-colors text-left"> <a href={`/posts/${encodeURIComponent(neighbors.prev.slug)}`} class="group glass p-6 hover:border-[var(--mauve)] transition-colors text-left">
<div class="font-sans text-xs tracking-[0.22em] uppercase text-[var(--subtext0)] mb-2">← Previously hung</div> <div class="pn-eyebrow font-sans text-xs tracking-[0.22em] uppercase text-[var(--subtext0)] mb-2">← Previous</div>
<div class="font-display italic text-xl text-[var(--text)] group-hover:text-[var(--mauve)] transition-colors leading-snug"> <div class="font-display italic text-xl text-[var(--text)] group-hover:text-[var(--mauve)] transition-colors leading-snug">
{neighbors.prev.title || formatSlug(neighbors.prev.slug)} {neighbors.prev.title || formatSlug(neighbors.prev.slug)}
</div> </div>
@@ -189,23 +176,14 @@ const exhibitNumber = neighbors.index >= 0 ? toRoman(neighbors.index + 1) : '';
)} )}
{neighbors.next && ( {neighbors.next && (
<a href={`/posts/${encodeURIComponent(neighbors.next.slug)}`} class="group glass p-6 hover:border-[var(--mauve)] transition-colors text-right md:col-start-2"> <a href={`/posts/${encodeURIComponent(neighbors.next.slug)}`} class="group glass p-6 hover:border-[var(--mauve)] transition-colors text-right md:col-start-2">
<div class="font-sans text-xs tracking-[0.22em] uppercase text-[var(--subtext0)] mb-2">Next on the wall →</div> <div class="pn-eyebrow font-sans text-xs tracking-[0.22em] uppercase text-[var(--subtext0)] mb-2">Next →</div>
<div class="font-display italic text-xl text-[var(--text)] group-hover:text-[var(--mauve)] transition-colors leading-snug"> <div class="font-display italic text-xl text-[var(--text)] group-hover:text-[var(--mauve)] transition-colors leading-snug">
{neighbors.next.title || formatSlug(neighbors.next.slug)} {neighbors.next.title || formatSlug(neighbors.next.slug)}
</div> </div>
</a> </a>
)} )}
{!neighbors.prev && !neighbors.next && ( </nav>
<div class="md:col-span-2 text-center font-display italic text-[var(--subtext0)]"> )}
This is the sole work currently on view.
</div>
)}
</div>
<div class="mt-12 text-center">
<a href="/" class="btn-ghost">↶ Return to catalogue</a>
</div>
</div>
</article> </article>
)} )}
@@ -220,9 +198,18 @@ const exhibitNumber = neighbors.index >= 0 ? toRoman(neighbors.index + 1) : '';
const pct = Math.max(0, Math.min(1, (window.scrollY - startY) / distance)); const pct = Math.max(0, Math.min(1, (window.scrollY - startY) / distance));
bar.style.transform = 'scaleX(' + pct + ')'; bar.style.transform = 'scaleX(' + pct + ')';
} }
let pending = false;
function schedule() {
if (pending) return;
pending = true;
requestAnimationFrame(function () {
pending = false;
update();
});
}
update(); update();
window.addEventListener('scroll', update, { passive: true }); window.addEventListener('scroll', schedule, { passive: true });
window.addEventListener('resize', update); window.addEventListener('resize', schedule);
})(); })();
</script> </script>
</Layout> </Layout>
+10 -7
View File
@@ -8,13 +8,16 @@ if (!response.ok) {
return new Response(null, { status: 404 }); return new Response(null, { status: 404 });
} }
const blob = await response.blob(); const headers = new Headers();
const contentType = response.headers.get('content-type'); const contentType = response.headers.get('content-type');
if (contentType) headers.set('content-type', contentType);
// Skip content-length / content-encoding: Node fetch auto-decompresses the
// upstream response, so any length/encoding from the backend is stale.
const etag = response.headers.get('etag');
if (etag) headers.set('etag', etag);
const lastModified = response.headers.get('last-modified');
if (lastModified) headers.set('last-modified', lastModified);
headers.set('cache-control', 'public, max-age=3600');
return new Response(blob, { return new Response(response.body, { headers });
headers: {
'content-type': contentType || 'application/octet-stream',
'cache-control': 'public, max-age=3600'
}
});
--- ---
+16 -859
View File
@@ -1,864 +1,21 @@
@import "tailwindcss"; @import "tailwindcss";
/* /*
* SALON HANG — gallery theme. * Entry stylesheet. The cascade is order-sensitive (custom CSS is unlayered so
* Aged parchment ground, oxblood ink, ochre+cobalt+vermillion accents. * it beats Tailwind utilities; per-theme overrides and the reduced-motion
* Romantic gravity (Friedrich, Dix, Goya) + raw scrawl (Basquiat) + bold cutout (Matisse, Kahlo). * kill-switch rely on source order). These @imports are inlined by Tailwind v4
* at build IN ORDER — keep them in this exact sequence; do not reorder.
* See partials/ for the split-out sections.
*/ */
@theme { @import "./partials/00-theme.css";
--color-crust: var(--crust); @import "./partials/10-tokens.css";
--color-mantle: var(--mantle); @import "./partials/20-atmosphere.css";
--color-bg: var(--base); @import "./partials/30-prose.css";
--color-surface0: var(--surface0); @import "./partials/40-components.css";
--color-surface1: var(--surface1); @import "./partials/45-blog.css";
--color-surface2: var(--surface2); @import "./partials/50-controls.css";
--color-overlay0: var(--overlay0); @import "./partials/60-breakcore.css";
--color-overlay1: var(--overlay1); @import "./partials/70-cybersigil.css";
--color-overlay2: var(--overlay2); @import "./partials/90-keyframes.css";
--color-text: var(--text); @import "./partials/99-reduced-motion.css";
--color-subtext0: var(--subtext0);
--color-subtext1: var(--subtext1);
--color-blue: var(--blue);
--color-lavender: var(--lavender);
--color-sapphire: var(--sapphire);
--color-sky: var(--sky);
--color-teal: var(--teal);
--color-green: var(--green);
--color-yellow: var(--yellow);
--color-peach: var(--peach);
--color-maroon: var(--maroon);
--color-red: var(--red);
--color-mauve: var(--mauve);
--color-pink: var(--pink);
--color-flamingo: var(--flamingo);
--color-rosewater: var(--rosewater);
--font-sans: 'EB Garamond Variable', 'EB Garamond', Georgia, 'Times New Roman', serif;
--font-display: 'Fraunces Variable', 'Fraunces', Georgia, 'Times New Roman', serif;
--font-hand: 'Caveat', 'Bradley Hand', cursive;
--font-mono: 'JetBrains Mono Variable', ui-monospace, 'SF Mono', Menlo, monospace;
}
/* SALON — default. Aged parchment with romantic weight. */
:root, .salon {
--crust: #14100C;
--mantle: #2A1F18;
--base: #ECE0C6;
--surface0: #DDCEB0;
--surface1: #B69C70;
--surface2: #826846;
--overlay0: #5C463A;
--overlay1: #463226;
--overlay2: #2E1F17;
--text: #1A120C;
--subtext0: #5C463A;
--subtext1: #3D2B1E;
/* accents — mapped to the original token names so existing UI flows pick them up */
--blue: #1F3A78; /* Kahlo cobalt */
--lavender: #5C4D7A; /* faded violet */
--sapphire: #2B3E5C; /* deep ink-blue */
--sky: #4A6FA0; /* muted azure */
--teal: #4C7264; /* verdigris */
--green: #6A7341; /* olive */
--yellow: #C9882B; /* Friedrich ochre */
--peach: #C26847; /* terracotta */
--maroon: #6B2B2A; /* wine */
--red: #B83A2B; /* Matisse/Goya vermillion */
--mauve: #6B1F1A; /* oxblood — primary accent */
--pink: #B85A6C; /* rosehip */
--flamingo: #C77A6C; /* faded coral */
--rosewater: #E8D9BD; /* bone */
}
/* Salon Noir — black gallery wall variant (Goya black paintings, Abramović stark). */
.salon-noir {
--crust: #050402;
--mantle: #0E0A06;
--base: #16110B;
--surface0: #221A12;
--surface1: #3A2B1E;
--surface2: #5C4530;
--overlay0: #7A5D43;
--overlay1: #93755A;
--overlay2: #B69779;
--text: #ECE0C6;
--subtext0: #B69C70;
--subtext1: #D6C49E;
--blue: #5A7DC4;
--lavender: #9A8DBE;
--sapphire: #87A9D8;
--sky: #B0C4E0;
--teal: #84A89A;
--green: #B9C076;
--yellow: #E9B854;
--peach: #E89570;
--maroon: #A04A47;
--red: #E25940;
--mauve: #C24336; /* lifted oxblood for dark bg contrast */
--pink: #E090A0;
--flamingo: #EBA797;
--rosewater: #F4E5C9;
}
/* Legacy Catppuccin themes — kept for users that already opted in. */
.mocha {
--crust: #11111b; --mantle: #181825; --base: #1e1e2e;
--surface0: #313244; --surface1: #45475a; --surface2: #585b70;
--overlay0: #6c7086; --overlay1: #7f849c; --overlay2: #9399b2;
--text: #cdd6f4; --subtext0: #a6adc8; --subtext1: #bac2de;
--blue: #89b4fa; --lavender: #b4befe; --sapphire: #74c7ec;
--sky: #89dceb; --teal: #94e2d5; --green: #a6e3a1;
--yellow: #f9e2af; --peach: #fab387; --maroon: #eba0ac;
--red: #f38ba8; --mauve: #cba6f7; --pink: #f5c2e7;
--flamingo: #f2cdcd; --rosewater: #f5e0dc;
}
.latte {
--crust: #dce0e8; --mantle: #e6e9ef; --base: #eff1f5;
--surface0: #ccd0da; --surface1: #bcc0cc; --surface2: #acb0be;
--overlay0: #7c7f93; --overlay1: #6c6f85; --overlay2: #5c5f77;
--text: #1e1e2e; --subtext0: #3c3f59; --subtext1: #4c4f69;
--blue: #1e66f5; --lavender: #7287fd; --sapphire: #209fb5;
--sky: #04a5e5; --teal: #179299; --green: #40a02b;
--yellow: #df8e1d; --peach: #fe640b; --maroon: #e64553;
--red: #d20f39; --mauve: #8839ef; --pink: #ea76cb;
--flamingo: #dd7878; --rosewater: #dc8a78;
}
html {
font-family: var(--font-sans);
font-feature-settings: "kern", "liga", "calt", "onum";
}
body {
background-color: var(--base);
color: var(--text);
min-height: 100vh;
transition: background-color 0.3s ease, color 0.3s ease;
-webkit-font-smoothing: antialiased;
font-size: 1.0625rem;
line-height: 1.65;
position: relative;
}
/* Paper grain — applied as a fixed overlay so every page gets the texture.
* All three layers sit behind content (negative z-index) so fixed-positioned
* modals (e.g. the search palette) can escape ancestor stacking traps. */
body::before {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
z-index: -3;
background-color: var(--base);
}
body::after {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
z-index: -1;
opacity: 0.32;
mix-blend-mode: multiply;
background-image:
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10 0 0 0 0 0.07 0 0 0 0 0.04 0 0 0 0.22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.salon-noir body::after,
html.salon-noir body::after {
opacity: 0.5;
}
/* Floating motes of pigment — far background, very subtle. */
.salon-atmosphere {
position: fixed;
inset: 0;
z-index: -2;
pointer-events: none;
overflow: hidden;
}
.salon-atmosphere::before,
.salon-atmosphere::after {
content: "";
position: absolute;
border-radius: 50%;
filter: blur(120px);
opacity: 0.18;
}
.salon-atmosphere::before {
width: 55vw; height: 55vw;
top: -15vw; left: -10vw;
background: var(--mauve);
}
.salon-atmosphere::after {
width: 45vw; height: 45vw;
bottom: -10vw; right: -10vw;
background: var(--blue);
opacity: 0.12;
}
code, pre, kbd, samp {
font-family: var(--font-mono);
}
/* Selection */
::selection {
background: var(--mauve);
color: var(--rosewater);
}
/* ───── Display utilities ───── */
.font-display {
font-family: var(--font-display);
font-feature-settings: "kern", "liga", "calt", "lnum", "ss01";
letter-spacing: -0.01em;
}
.font-hand {
font-family: var(--font-hand);
font-weight: 400;
}
.font-display-italic {
font-family: var(--font-display);
font-style: italic;
font-feature-settings: "kern", "liga", "calt", "ss01";
}
/* Roman numerals get small-caps treatment */
.numeral {
font-family: var(--font-display);
font-variant-numeric: lining-nums;
letter-spacing: 0.08em;
font-weight: 500;
}
/* ───── Salon prose — exhibit plaque body ───── */
.prose {
color: var(--text);
max-width: 62ch;
margin-left: auto;
margin-right: auto;
line-height: 1.75;
font-size: 1.125rem;
font-family: var(--font-sans);
}
@media (min-width: 768px) {
.prose { font-size: 1.1875rem; }
}
.prose > *:first-child { margin-top: 0; }
.prose p:first-of-type::first-letter {
font-family: var(--font-display);
font-weight: 600;
font-size: 3.6em;
line-height: 0.85;
float: left;
margin: 0.08em 0.12em 0 -0.04em;
color: var(--mauve);
}
.prose h1 {
font-family: var(--font-display);
font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
font-weight: 600;
font-style: italic;
color: var(--text);
margin: 0 0 1.25rem;
line-height: 1.05;
letter-spacing: -0.02em;
}
.prose h2 {
font-family: var(--font-display);
font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
font-weight: 500;
color: var(--text);
margin: 3rem 0 1rem;
line-height: 1.2;
letter-spacing: -0.01em;
}
.prose h2::before {
content: "§ ";
color: var(--mauve);
font-style: italic;
opacity: 0.7;
}
.prose h3 {
font-family: var(--font-display);
font-size: 1.4rem;
font-weight: 500;
font-style: italic;
color: var(--text);
margin: 2.25rem 0 0.75rem;
}
.prose h4 {
font-family: var(--font-display);
font-size: 1.2rem;
font-weight: 500;
color: var(--subtext1);
margin: 1.75rem 0 0.5rem;
}
.prose h5 {
font-size: 0.85rem;
font-weight: 600;
color: var(--subtext0);
text-transform: uppercase;
letter-spacing: 0.18em;
margin: 1.5rem 0 0.5rem;
}
.prose h6 {
font-size: 0.85rem;
font-weight: 500;
color: var(--overlay0);
font-style: italic;
margin: 1rem 0 0.5rem;
}
.prose p { margin: 0 0 1.15rem; }
.prose blockquote {
border-left: 3px double var(--mauve);
padding: 0.5rem 0 0.5rem 1.4rem;
margin: 1.75rem 0;
color: var(--subtext1);
font-family: var(--font-display);
font-style: italic;
font-size: 1.15em;
line-height: 1.55;
}
.prose blockquote::before {
content: "“";
font-family: var(--font-display);
color: var(--mauve);
font-size: 2.5em;
line-height: 0;
vertical-align: -0.35em;
margin-right: 0.1em;
opacity: 0.55;
}
.prose pre {
padding: 1rem 1.1rem;
border-radius: 0;
border: 1px solid var(--surface2);
border-left-width: 3px;
border-left-color: var(--mauve);
margin: 1.75rem 0;
background-color: color-mix(in srgb, var(--surface0) 70%, transparent);
font-size: 0.875rem;
line-height: 1.55;
overflow-x: auto;
}
.prose code {
background-color: color-mix(in srgb, var(--surface0) 90%, transparent);
padding: 0.1rem 0.4rem;
border-radius: 0;
border-bottom: 1px solid var(--surface1);
font-size: 0.9em;
color: var(--mauve);
}
.prose pre code {
background: transparent;
padding: 0;
border: 0;
color: inherit;
font-size: inherit;
}
.prose a {
color: var(--mauve);
text-decoration: underline;
text-decoration-color: var(--surface1);
text-decoration-thickness: 1px;
text-underline-offset: 3px;
transition: color 0.15s, text-decoration-color 0.15s;
}
.prose a:hover {
color: var(--red);
text-decoration-color: var(--red);
}
.prose ul, .prose ol {
margin: 0 0 1.15rem;
padding-left: 1.6rem;
}
.prose ul { list-style: none; }
.prose ul > li { position: relative; padding-left: 0.2rem; }
.prose ul > li::before {
content: "❦";
position: absolute;
left: -1.2rem;
color: var(--mauve);
font-size: 0.85em;
top: 0.05em;
}
.prose ol { list-style: decimal-leading-zero; }
.prose ol > li::marker { color: var(--mauve); font-family: var(--font-display); font-style: italic; }
.prose li { margin: 0.3rem 0; }
.prose hr {
margin: 3rem auto;
border: 0;
text-align: center;
height: 1em;
}
.prose hr::before {
content: "✦ ✦ ✦";
color: var(--surface2);
letter-spacing: 0.8em;
font-size: 0.85em;
}
.prose strong { color: var(--mauve); font-weight: 700; }
.prose em { color: inherit; font-style: italic; font-family: var(--font-display); }
.prose del { color: var(--overlay0); text-decoration: line-through; }
/* ───── Figure / image plate — the heart of the gallery body ───── */
.prose figure,
.prose p > img:only-child {
margin: 2.5rem 0;
}
.prose figure {
display: block;
text-align: center;
}
.prose figure img,
.prose img {
display: block;
max-width: 100%;
height: auto;
margin: 0 auto;
border: 1px solid var(--surface2);
padding: 6px;
background:
linear-gradient(var(--rosewater), var(--rosewater)) padding-box,
linear-gradient(135deg, var(--surface2), var(--surface1)) border-box;
box-shadow:
0 1px 0 var(--surface0),
0 18px 38px -22px rgba(20, 16, 12, 0.45),
0 2px 6px -2px rgba(20, 16, 12, 0.2);
border-radius: 2px;
}
.salon-noir .prose figure img,
.salon-noir .prose img {
background:
linear-gradient(var(--surface0), var(--surface0)) padding-box,
linear-gradient(135deg, var(--surface2), var(--surface1)) border-box;
box-shadow:
0 18px 38px -22px rgba(0, 0, 0, 0.7),
0 2px 6px -2px rgba(0, 0, 0, 0.5);
}
.prose figure figcaption {
font-family: var(--font-display);
font-style: italic;
font-size: 0.9rem;
color: var(--subtext0);
margin-top: 0.85rem;
letter-spacing: 0.02em;
line-height: 1.4;
}
.prose figure figcaption::before {
content: "— ";
color: var(--mauve);
}
/* GFM tables — keep, slightly more editorial */
.prose table {
width: 100%;
margin: 1.75rem 0;
border-collapse: collapse;
border: 1px solid var(--surface2);
font-size: 0.95rem;
font-family: var(--font-sans);
}
.prose thead { background-color: color-mix(in srgb, var(--surface0) 80%, transparent); }
.prose th {
padding: 0.55rem 0.9rem;
text-align: left;
font-weight: 600;
color: var(--text);
border-bottom: 1px solid var(--surface2);
text-transform: uppercase;
letter-spacing: 0.08em;
font-size: 0.75rem;
}
.prose td {
padding: 0.5rem 0.9rem;
border-bottom: 1px solid color-mix(in srgb, var(--surface1) 60%, transparent);
}
.prose tr:last-child td { border-bottom: 0; }
/* ───── Salon plate — a single framed image card used on the gallery index ───── */
.plate {
position: relative;
background: var(--rosewater);
padding: 14px 14px 0 14px;
border: 1px solid var(--surface2);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 1px 0 var(--surface0),
0 22px 42px -28px rgba(20, 16, 12, 0.5),
0 4px 12px -6px rgba(20, 16, 12, 0.25);
border-radius: 2px;
transition: transform 0.4s cubic-bezier(0.2, 0.6, 0.2, 1),
box-shadow 0.4s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.salon-noir .plate {
background: var(--surface0);
}
.plate:hover {
transform: translateY(-4px) rotate(-0.25deg);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 60%, transparent),
0 1px 0 var(--surface0),
0 32px 60px -28px rgba(20, 16, 12, 0.55),
0 8px 20px -8px rgba(20, 16, 12, 0.3);
}
.plate .plate-image {
position: relative;
overflow: hidden;
background: var(--mantle);
}
.plate .plate-image img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
filter: saturate(0.94) contrast(1.02);
transition: transform 0.8s cubic-bezier(0.2, 0.6, 0.2, 1), filter 0.4s ease;
}
.plate:hover .plate-image img {
transform: scale(1.03);
filter: saturate(1.05) contrast(1.04);
}
.plate .plate-caption {
padding: 12px 4px 14px 4px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
}
.plate .plate-caption-title {
font-family: var(--font-display);
font-style: italic;
font-weight: 500;
font-size: 1.05rem;
line-height: 1.2;
color: var(--text);
letter-spacing: -0.005em;
}
.plate .plate-caption-meta {
font-family: var(--font-sans);
font-size: 0.72rem;
text-transform: uppercase;
letter-spacing: 0.18em;
color: var(--subtext0);
white-space: nowrap;
align-self: flex-start;
padding-top: 0.35rem;
}
/* The little exhibit number stuck to the corner of a plate */
.plate-tag {
position: absolute;
top: -10px;
left: 14px;
background: var(--mauve);
color: var(--rosewater);
font-family: var(--font-display);
font-size: 0.7rem;
font-weight: 600;
letter-spacing: 0.18em;
padding: 4px 8px;
text-transform: uppercase;
box-shadow: 0 2px 6px -2px rgba(20, 16, 12, 0.45);
}
.plate-tag-mini {
position: absolute;
bottom: 18px;
right: 18px;
background: rgba(20, 16, 12, 0.78);
color: var(--rosewater);
font-family: var(--font-display);
font-size: 0.7rem;
letter-spacing: 0.16em;
padding: 3px 8px;
text-transform: uppercase;
backdrop-filter: blur(2px);
}
/* Nameplate — the museum-style header used in the site chrome */
.nameplate {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
gap: 2px;
position: relative;
}
.nameplate::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: -6px;
height: 2px;
background: linear-gradient(to right,
var(--mauve) 0%,
var(--mauve) 35%,
var(--surface2) 35%,
var(--surface2) 100%);
}
.nameplate-title {
font-family: var(--font-display);
font-weight: 600;
font-style: italic;
font-size: 1.6rem;
letter-spacing: -0.01em;
color: var(--text);
line-height: 1;
}
.nameplate-subtitle {
font-family: var(--font-sans);
font-size: 0.65rem;
letter-spacing: 0.32em;
text-transform: uppercase;
color: var(--subtext0);
}
/* Section ornaments */
.section-rule {
display: flex;
align-items: center;
gap: 1rem;
color: var(--subtext0);
font-family: var(--font-display);
font-style: italic;
font-size: 0.95rem;
letter-spacing: 0.04em;
}
.section-rule::before,
.section-rule::after {
content: "";
flex: 1;
height: 1px;
background: var(--surface2);
}
.section-rule .ornament {
color: var(--mauve);
}
/* Scrawled handwritten margin notes */
.scrawl {
font-family: var(--font-hand);
color: var(--mauve);
font-size: 1.4rem;
line-height: 1;
transform: rotate(-6deg);
display: inline-block;
}
.scrawl-mark::before {
content: "✕";
font-family: var(--font-hand);
color: var(--red);
margin-right: 0.35em;
}
/* Stripe (Matisse cutout) chip used for tags */
.chip {
display: inline-flex;
align-items: center;
gap: 0.3rem;
font-family: var(--font-display);
font-style: italic;
font-size: 0.78rem;
padding: 0.15rem 0.6rem;
background: color-mix(in srgb, var(--surface0) 80%, transparent);
border: 1px solid var(--surface2);
color: var(--subtext1);
border-radius: 1px;
letter-spacing: 0.02em;
}
.chip-accent {
background: var(--mauve);
color: var(--rosewater);
border-color: var(--mauve);
}
/* Card / glass — keep the name but reinterpret as a paper card */
.glass {
background-color: color-mix(in srgb, var(--surface0) 80%, transparent);
border: 1px solid var(--surface2);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 10px 30px -20px rgba(20, 16, 12, 0.45);
border-radius: 2px;
}
.salon-noir .glass {
background-color: color-mix(in srgb, var(--surface0) 70%, transparent);
}
/* ───── Buttons ───── */
.btn-stamp {
display: inline-flex;
align-items: center;
gap: 0.5rem;
font-family: var(--font-display);
font-style: italic;
font-weight: 500;
font-size: 0.95rem;
padding: 0.55rem 1.2rem;
background: var(--mauve);
color: var(--rosewater);
border: 1px solid var(--mauve);
border-radius: 1px;
letter-spacing: 0.02em;
text-decoration: none;
cursor: pointer;
transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
box-shadow: 0 4px 0 -2px color-mix(in srgb, var(--mauve) 60%, black);
}
.btn-stamp:hover {
transform: translateY(-1px);
background: var(--red);
border-color: var(--red);
box-shadow: 0 6px 0 -2px color-mix(in srgb, var(--red) 60%, black);
}
.btn-stamp:active {
transform: translateY(1px);
box-shadow: 0 1px 0 -1px color-mix(in srgb, var(--mauve) 60%, black);
}
.btn-ghost {
display: inline-flex;
align-items: center;
gap: 0.5rem;
font-family: var(--font-sans);
font-size: 0.82rem;
padding: 0.4rem 0.85rem;
background: transparent;
color: var(--subtext1);
border: 1px solid var(--surface2);
border-radius: 1px;
letter-spacing: 0.06em;
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-ghost:hover {
color: var(--mauve);
border-color: var(--mauve);
background: color-mix(in srgb, var(--mauve) 8%, transparent);
}
/* Form input look */
.field-input {
width: 100%;
background: color-mix(in srgb, var(--surface0) 60%, transparent);
border: 1px solid var(--surface2);
border-radius: 1px;
padding: 0.65rem 0.9rem;
color: var(--text);
font-family: var(--font-sans);
font-size: 1rem;
transition: border-color 0.15s, background 0.15s;
}
.field-input:focus {
outline: none;
border-color: var(--mauve);
background: color-mix(in srgb, var(--rosewater) 70%, transparent);
}
.field-label {
display: block;
font-family: var(--font-sans);
font-size: 0.72rem;
letter-spacing: 0.22em;
text-transform: uppercase;
color: var(--subtext0);
margin-bottom: 0.4rem;
}
/* hljs token colors — driven by theme tokens, slightly muted for parchment bg */
.hljs { color: var(--text); background: transparent; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: var(--mauve); font-weight: 600; }
.hljs-string, .hljs-attr { color: var(--green); }
.hljs-number, .hljs-literal { color: var(--peach); }
.hljs-comment, .hljs-quote { color: var(--overlay0); font-style: italic; }
.hljs-title, .hljs-section, .hljs-name { color: var(--blue); }
.hljs-type, .hljs-class .hljs-title { color: var(--yellow); }
.hljs-variable, .hljs-template-variable { color: var(--red); }
/* KaTeX */
.katex { color: var(--text); }
/* Skeleton loader */
.skeleton {
background: linear-gradient(
90deg,
color-mix(in srgb, var(--surface0) 50%, transparent) 0%,
color-mix(in srgb, var(--surface1) 50%, transparent) 50%,
color-mix(in srgb, var(--surface0) 50%, transparent) 100%
);
background-size: 200% 100%;
animation: skeleton-shimmer 1.5s ease-in-out infinite;
border-radius: 1px;
}
@keyframes skeleton-shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
/* Toast */
.toast {
position: fixed;
bottom: 1.5rem;
left: 50%;
transform: translateX(-50%);
background: var(--mantle);
border: 1px solid var(--surface2);
color: var(--rosewater);
padding: 0.65rem 1.1rem;
border-radius: 1px;
box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.45);
font-family: var(--font-display);
font-style: italic;
font-size: 0.9rem;
z-index: 200;
animation: toast-in 0.2s ease;
}
@keyframes toast-in {
from { opacity: 0; transform: translate(-50%, 8px); }
to { opacity: 1; transform: translate(-50%, 0); }
}
/* Salon grid spans driven by --col-span custom prop (avoids Tailwind dynamic class issue). */
@media (min-width: 768px) {
.md-col-span {
grid-column: span var(--col-span, 6) / span var(--col-span, 6);
}
}
/* Subtle page enter animation for gallery / plaque */
@keyframes plate-fade-up {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0); }
}
.plate-enter {
opacity: 0;
animation: plate-fade-up 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
/* Custom checkbox accent for form bits inside the salon */
input[type="checkbox"] { accent-color: var(--mauve); }
input[type="date"] { color-scheme: light; }
.salon-noir input[type="date"] { color-scheme: dark; }
/* Reading progress bar - thin terracotta line */
.reading-progress {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 2px;
background: var(--mauve);
z-index: 150;
transform-origin: left;
transform: scaleX(0);
transition: transform 80ms linear;
}
+41
View File
@@ -0,0 +1,41 @@
/*
* SALON HANG — gallery theme.
* Aged parchment ground, oxblood ink, ochre+cobalt+vermillion accents.
* Romantic gravity (Friedrich, Dix, Goya) + raw scrawl (Basquiat) + bold cutout (Matisse, Kahlo).
*/
@theme {
--color-crust: var(--crust);
--color-mantle: var(--mantle);
--color-bg: var(--base);
--color-surface0: var(--surface0);
--color-surface1: var(--surface1);
--color-surface2: var(--surface2);
--color-overlay0: var(--overlay0);
--color-overlay1: var(--overlay1);
--color-overlay2: var(--overlay2);
--color-text: var(--text);
--color-subtext0: var(--subtext0);
--color-subtext1: var(--subtext1);
--color-blue: var(--blue);
--color-lavender: var(--lavender);
--color-sapphire: var(--sapphire);
--color-sky: var(--sky);
--color-teal: var(--teal);
--color-green: var(--green);
--color-yellow: var(--yellow);
--color-peach: var(--peach);
--color-maroon: var(--maroon);
--color-red: var(--red);
--color-mauve: var(--mauve);
--color-pink: var(--pink);
--color-flamingo: var(--flamingo);
--color-rosewater: var(--rosewater);
--font-sans: 'EB Garamond Variable', 'EB Garamond', Georgia, 'Times New Roman', serif;
--font-display: 'Fraunces Variable', 'Fraunces', Georgia, 'Times New Roman', serif;
--font-hand: 'Caveat', 'Bradley Hand', cursive;
--font-mono: 'JetBrains Mono Variable', ui-monospace, 'SF Mono', Menlo, monospace;
}
+174
View File
@@ -0,0 +1,174 @@
/* SALON — default. Aged parchment with romantic weight. */
:root, .salon {
--crust: #14100C;
--mantle: #2A1F18;
--base: #ECE0C6;
--surface0: #DDCEB0;
--surface1: #B69C70;
--surface2: #826846;
--overlay0: #5C463A;
--overlay1: #463226;
--overlay2: #2E1F17;
--text: #1A120C;
--subtext0: #5C463A;
--subtext1: #3D2B1E;
/* accents — mapped to the original token names so existing UI flows pick them up */
--blue: #1F3A78; /* Kahlo cobalt */
--lavender: #5C4D7A; /* faded violet */
--sapphire: #2B3E5C; /* deep ink-blue */
--sky: #4A6FA0; /* muted azure */
--teal: #4C7264; /* verdigris */
--green: #6A7341; /* olive */
--yellow: #C9882B; /* Friedrich ochre */
--peach: #C26847; /* terracotta */
--maroon: #6B2B2A; /* wine */
--red: #B83A2B; /* Matisse/Goya vermillion */
--mauve: #6B1F1A; /* oxblood — primary accent */
--pink: #B85A6C; /* rosehip */
--flamingo: #C77A6C; /* faded coral */
--rosewater: #E8D9BD; /* bone */
}
/* Salon Noir — black gallery wall variant (Goya black paintings, Abramović stark). */
.salon-noir {
--crust: #050402;
--mantle: #0E0A06;
--base: #16110B;
--surface0: #221A12;
--surface1: #3A2B1E;
--surface2: #5C4530;
--overlay0: #7A5D43;
--overlay1: #93755A;
--overlay2: #B69779;
--text: #ECE0C6;
--subtext0: #B69C70;
--subtext1: #D6C49E;
--blue: #5A7DC4;
--lavender: #9A8DBE;
--sapphire: #87A9D8;
--sky: #B0C4E0;
--teal: #84A89A;
--green: #B9C076;
--yellow: #E9B854;
--peach: #E89570;
--maroon: #A04A47;
--red: #E25940;
--mauve: #C24336; /* lifted oxblood for dark bg contrast */
--pink: #E090A0;
--flamingo: #EBA797;
--rosewater: #F4E5C9;
}
/* BREAKCORE — early-2000s web rot + breakcore. CRT-violet ground, hot
* magenta primary, acid green / electric cyan / hazard yellow accents.
* Glitchy, blown-out, MSN-era saturation. */
.breakcore {
--crust: #02000A;
--mantle: #06031A;
--base: #0A0612;
--surface0: #150929;
--surface1: #22113F;
--surface2: #3A1B62;
--overlay0: #5A2D8E;
--overlay1: #7B45B8;
--overlay2: #A06AD8;
--text: #F2F0FF;
--subtext0: #B9A8E0;
--subtext1: #D8CCFA;
--blue: #00B7FF; /* MSN cyan */
--lavender: #B98CFF; /* CRT violet */
--sapphire: #4B6BFF; /* hyperlink */
--sky: #66E1FF; /* aqua chrome */
--teal: #00F5C8; /* matrix mint */
--green: #B6FF00; /* acid */
--yellow: #FFD400; /* hazard */
--peach: #FF8A3D; /* GIF-era flame */
--maroon: #8B0A4B;
--red: #FF1F4F; /* siren */
--mauve: #FF2EA6; /* hot magenta — primary accent */
--pink: #FF7AD8; /* bubblegum */
--flamingo: #FFA2C4;
--rosewater: #FFE8F6;
}
/* GOTHIC — cathedral nightfall. Midnight violet ground, blood crimson,
* tarnished candle gold, stained-glass indigo. Catholic-gothic + Sisters of
* Mercy + Bauhaus stark. Primary accent: cathedral velvet mauve. */
.gothic {
--crust: #030104;
--mantle: #0A0710;
--base: #110B18;
--surface0: #1A1224;
--surface1: #261A36;
--surface2: #382550;
--overlay0: #4F3970;
--overlay1: #6E5293;
--overlay2: #8D72B1;
--text: #EDE3F2; /* bone, violet wash */
--subtext0: #9B8AB0;
--subtext1: #C0AED2;
--blue: #4239A4; /* stained-glass deep */
--lavender: #9B7BD4; /* candlelight through purple glass */
--sapphire: #5947B2;
--sky: #7C68C9;
--teal: #487B8A; /* verdigris on bronze */
--green: #5E7842; /* cemetery moss */
--yellow: #D4A82B; /* taper / tarnished brass */
--peach: #B45A38; /* rust */
--maroon: #5B1A24;
--red: #A41827; /* arterial */
--mauve: #8B2C9E; /* cathedral velvet — primary accent */
--pink: #B25288; /* dried rose */
--flamingo: #C57B96;
--rosewater: #F0DDE8;
}
/* CYBERSIGIL — Frostbite. Near-black ground, ice-cyan sigil linework,
* bruised-magenta primary accent, sterile bone-white text. Modern-breakcore
* melancholy: chromatic-aberration glitch, barbed sigil ornament, deep
* vignette + fine cold grain. Primary accent: bruised magenta (--mauve). */
.cybersigil {
--crust: #020203;
--mantle: #050507;
--base: #070709;
--surface0: #0C0D11;
--surface1: #13151B;
--surface2: #1E2129;
--overlay0: #2A2F3A;
--overlay1: #3D4654;
--overlay2: #566174;
--text: #DCE6EC; /* sterile bone-white, cool cast */
--subtext0: #7E8B99;
--subtext1: #AAB8C4;
--blue: #3FB4FF; /* cold electric */
--lavender: #8E7CFF; /* cold violet */
--sapphire: #3A5BFF; /* deep cold hyperlink */
--sky: #4FE9FF; /* ice-cyan — primary sigil line */
--teal: #2FD8D2; /* frost mint — secondary neon */
--green: #5BE0A8; /* cold jade */
--yellow: #E8C24A; /* muted amber — inline code only */
--peach: #E07A5F;
--maroon: #5A1530;
--red: #FF3B5C; /* siren — danger only */
--mauve: #C8327A; /* bruised magenta — primary accent */
--pink: #E86AAE; /* faded neon pink */
--flamingo: #E8A0C4;
--rosewater: #EAF2F6; /* brightest bone — on-accent text */
}
html {
font-family: var(--font-sans);
font-feature-settings: "kern", "liga", "calt", "onum";
}
body {
background-color: var(--base);
color: var(--text);
min-height: 100vh;
transition: background-color 0.3s ease, color 0.3s ease;
-webkit-font-smoothing: antialiased;
font-size: 1.0625rem;
line-height: 1.65;
position: relative;
}
@@ -0,0 +1,105 @@
/* Paper grain — applied as a fixed overlay so every page gets the texture.
* All three layers sit behind content (negative z-index) so fixed-positioned
* modals (e.g. the search palette) can escape ancestor stacking traps. */
body::before {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
z-index: -3;
background-color: var(--base);
}
body::after {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
z-index: -1;
opacity: 0.32;
mix-blend-mode: multiply;
background-image:
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10 0 0 0 0 0.07 0 0 0 0 0.04 0 0 0 0.22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.salon-noir body::after,
html.salon-noir body::after {
opacity: 0.5;
}
.gothic body::after,
html.gothic body::after {
opacity: 0.55;
background-image:
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.05 0 0 0 0 0.10 0 0 0 0.28 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
mix-blend-mode: screen;
}
/* Breakcore: blown-out RGB-tinted digital noise + CRT scanlines. */
.breakcore body::after,
html.breakcore body::after {
opacity: 0.55;
background-image:
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 0.18 0 0 0 0 0.65 0 0 0 0.45 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
repeating-linear-gradient(
0deg,
rgba(0, 0, 0, 0) 0,
rgba(0, 0, 0, 0) 2px,
rgba(0, 0, 0, 0.28) 3px,
rgba(0, 0, 0, 0) 4px
);
mix-blend-mode: screen;
}
.breakcore .salon-atmosphere::before { opacity: 0.32; }
.breakcore .salon-atmosphere::after { opacity: 0.28; }
/* Floating motes of pigment — far background, very subtle. */
.salon-atmosphere {
position: fixed;
inset: 0;
z-index: -2;
pointer-events: none;
overflow: hidden;
}
.salon-atmosphere::before,
.salon-atmosphere::after {
content: "";
position: absolute;
border-radius: 50%;
filter: blur(120px);
opacity: 0.18;
}
.salon-atmosphere::before {
width: 55vw; height: 55vw;
top: -15vw; left: -10vw;
background: var(--mauve);
}
.salon-atmosphere::after {
width: 45vw; height: 45vw;
bottom: -10vw; right: -10vw;
background: var(--blue);
opacity: 0.12;
}
code, pre, kbd, samp {
font-family: var(--font-mono);
}
/* Selection */
::selection {
background: var(--mauve);
color: var(--rosewater);
}
/* Breakcore: chromatic-aberration glow on display headings + nameplate. */
.breakcore .prose h1,
.breakcore .prose h2,
.breakcore h1.font-display,
.breakcore .nameplate-title {
text-shadow:
-1px 0 0 color-mix(in srgb, var(--teal) 70%, transparent),
1px 0 0 color-mix(in srgb, var(--mauve) 70%, transparent),
0 0 18px color-mix(in srgb, var(--mauve) 35%, transparent);
}
.breakcore ::selection {
background: var(--green);
color: var(--crust);
text-shadow: 0 0 6px var(--mauve);
}
+353
View File
@@ -0,0 +1,353 @@
/* ───── Display utilities ───── */
.font-display {
font-family: var(--font-display);
font-feature-settings: "kern", "liga", "calt", "lnum", "ss01";
letter-spacing: -0.01em;
}
.font-hand {
font-family: var(--font-hand);
font-weight: 400;
}
.font-display-italic {
font-family: var(--font-display);
font-style: italic;
font-feature-settings: "kern", "liga", "calt", "ss01";
}
/* Roman numerals get small-caps treatment */
.numeral {
font-family: var(--font-display);
font-variant-numeric: lining-nums;
letter-spacing: 0.08em;
font-weight: 500;
}
/* ───── Salon prose — exhibit plaque body ───── */
.prose {
color: var(--text);
max-width: none;
line-height: 1.75;
font-size: 1.125rem;
font-family: var(--font-sans);
}
@media (min-width: 768px) {
.prose { font-size: 1.1875rem; }
}
.prose > *:first-child { margin-top: 0; }
.prose h1 {
font-family: var(--font-display);
font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
font-weight: 600;
font-style: italic;
color: var(--text);
margin: 0 0 1.25rem;
line-height: 1.15;
letter-spacing: -0.02em;
padding-bottom: 0.06em;
}
.prose h2 {
font-family: var(--font-display);
font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
font-weight: 500;
color: var(--text);
margin: 3rem 0 1rem;
padding-bottom: 0.35rem;
line-height: 1.2;
letter-spacing: -0.01em;
border-bottom: 1px solid color-mix(in srgb, var(--mauve) 30%, transparent);
}
.prose h3 {
font-family: var(--font-display);
font-size: 1.4rem;
font-weight: 500;
font-style: italic;
color: var(--text);
margin: 2.25rem 0 0.75rem;
}
.prose h4 {
font-family: var(--font-display);
font-size: 1.2rem;
font-weight: 500;
color: var(--subtext1);
margin: 1.75rem 0 0.5rem;
}
.prose h5 {
font-size: 0.85rem;
font-weight: 600;
color: var(--subtext0);
text-transform: uppercase;
letter-spacing: 0.18em;
margin: 1.5rem 0 0.5rem;
}
.prose h6 {
font-size: 0.85rem;
font-weight: 500;
color: var(--overlay0);
font-style: italic;
margin: 1rem 0 0.5rem;
}
.prose :is(h1, h2, h3, h4, h5, h6) { scroll-margin-top: 5rem; }
.prose p { margin: 0 0 1.15rem; }
.prose blockquote {
border-left: 3px solid var(--mauve);
padding: 0.25rem 0 0.25rem 1.4rem;
margin: 1.75rem 0;
color: var(--subtext1);
font-style: italic;
}
.prose blockquote p { margin: 0 0 0.6rem; }
.prose blockquote p:last-child { margin: 0; }
.prose pre {
padding: 1rem 1.1rem;
border-radius: 0;
border: 1px solid var(--surface2);
border-left-width: 3px;
border-left-color: var(--mauve);
margin: 1.75rem 0;
background-color: color-mix(in srgb, var(--surface0) 70%, transparent);
font-size: 0.875rem;
line-height: 1.55;
overflow-x: auto;
}
.prose code {
background-color: color-mix(in srgb, var(--surface0) 90%, transparent);
padding: 0.1rem 0.4rem;
border-radius: 0;
border-bottom: 1px solid var(--surface1);
font-size: 0.9em;
color: var(--mauve);
}
.prose pre code {
background: transparent;
padding: 0;
border: 0;
color: inherit;
font-size: inherit;
}
.prose a code,
.prose :is(h1, h2, h3, h4) code { color: inherit; }
.prose a {
color: var(--mauve);
text-decoration: underline;
text-decoration-color: var(--surface1);
text-decoration-thickness: 1px;
text-underline-offset: 3px;
transition: color 0.15s, text-decoration-color 0.15s;
}
.prose a:hover {
color: var(--red);
text-decoration-color: var(--red);
}
.prose ul, .prose ol {
margin: 0 0 1.15rem;
padding-left: 1.6rem;
}
.prose ul { list-style: none; }
.prose ul > li { position: relative; padding-left: 0.2rem; }
.prose ul > li::before {
content: "";
position: absolute;
left: -1.1rem;
top: 0.62em;
width: 0.42em;
height: 0.42em;
background: var(--mauve);
transform: rotate(45deg);
}
.prose ol { list-style: decimal-leading-zero; }
.prose ol > li::marker { color: var(--mauve); font-family: var(--font-display); font-style: italic; }
.prose li { margin: 0.3rem 0; }
/* Loose lists wrap items in <p>; drop the paragraph block-margin inside li. */
.prose li > p { margin: 0; }
.prose li > p + p { margin-top: 0.6rem; }
/* GFM task lists — kill the diamond, keep the checkbox. */
.prose ul > li:has(input[type="checkbox"]) { padding-left: 0; }
.prose ul > li:has(input[type="checkbox"])::before { content: none; }
.prose li > input[type="checkbox"] {
margin: 0 0.5rem 0 0;
vertical-align: 0.04em;
accent-color: var(--mauve);
}
.prose hr {
margin: 3rem auto;
border: 0;
height: 1px;
width: 100%;
background: linear-gradient(
90deg,
transparent 0%,
color-mix(in srgb, var(--mauve) 55%, transparent) 22%,
transparent 45%,
transparent 55%,
color-mix(in srgb, var(--mauve) 55%, transparent) 78%,
transparent 100%
);
position: relative;
overflow: visible;
}
.prose hr::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 0.5rem;
height: 0.5rem;
transform: translate(-50%, -50%) rotate(45deg);
background: var(--mauve);
}
.prose strong { color: inherit; font-weight: 700; }
.prose em { color: inherit; font-style: italic; font-family: var(--font-display); }
.prose del { color: var(--overlay0); text-decoration: line-through; }
/* ───── Figure / image plate — the heart of the gallery body ───── */
.prose figure {
display: block;
text-align: center;
margin: 2.5rem 0;
}
.prose figure img,
.prose img {
display: block;
max-width: 100%;
/* A tall single image must never overrun the viewport: cap its height and
* let width track aspect so it scales down whole, centred. (figure-row
* images opt out below — their height is already bounded by --row-h.) */
max-height: 85vh;
width: auto;
height: auto;
margin: 0 auto;
border: 1px solid var(--surface2);
padding: 6px;
background:
linear-gradient(var(--rosewater), var(--rosewater)) padding-box,
linear-gradient(135deg, var(--surface2), var(--surface1)) border-box;
box-shadow:
0 1px 0 var(--surface0),
0 18px 38px -22px rgba(20, 16, 12, 0.45),
0 2px 6px -2px rgba(20, 16, 12, 0.2);
border-radius: 2px;
}
.salon-noir .prose figure img,
.salon-noir .prose img,
.gothic .prose figure img,
.gothic .prose img,
.breakcore .prose figure img,
.breakcore .prose img {
background:
linear-gradient(var(--surface0), var(--surface0)) padding-box,
linear-gradient(135deg, var(--surface2), var(--surface1)) border-box;
box-shadow:
0 18px 38px -22px rgba(0, 0, 0, 0.7),
0 2px 6px -2px rgba(0, 0, 0, 0.5);
}
.gothic .prose figure img,
.gothic .prose img {
box-shadow:
0 18px 38px -22px rgba(0, 0, 0, 0.85),
0 2px 6px -2px rgba(0, 0, 0, 0.6),
0 0 0 1px color-mix(in srgb, var(--mauve) 22%, transparent);
}
.prose figure figcaption {
font-family: var(--font-display);
font-style: italic;
font-size: 0.9rem;
color: var(--subtext0);
margin-top: 0.85rem;
letter-spacing: 0.02em;
line-height: 1.4;
}
/* Multi-image rows. Consecutive markdown images auto-collapse into a flex
* row; each figure gets `flex: <aspect-ratio>` inline so widths divide
* proportionally and heights line up. Wraps to a column on narrow screens. */
.prose .figure-row {
/* Target row height. Each figure's flex-basis is ratio × this value, so
* rows pack as many figures as fit at roughly --row-h tall, then wrap.
* --row-max caps how tall a sparsely-filled final row can grow. */
--row-h: 16rem;
--row-max: 30rem;
display: flex;
flex-wrap: wrap;
gap: 0.9rem;
align-items: flex-start;
margin: 2.5rem 0;
width: 100%;
}
@media (min-width: 1024px) {
.prose .figure-row {
--row-h: 18rem;
--row-max: 34rem;
}
}
.prose .figure-row figure {
margin: 0;
min-width: 0; /* allow flex children to shrink below content width */
flex-basis: 0;
}
.prose .figure-row figure img {
width: 100%;
max-width: 100%;
max-height: none;
height: auto;
margin: 0;
}
.prose .figure-row figure figcaption {
text-align: left;
margin-top: 0.55rem;
font-size: 0.82rem;
}
@media (max-width: 640px) {
.prose .figure-row {
flex-direction: column;
width: 100%;
margin-left: 0;
gap: 1.4rem;
}
.prose .figure-row figure {
flex: 1 1 100% !important;
}
.prose .figure-row figure figcaption {
text-align: center;
}
}
.prose figure figcaption::before {
content: "— ";
color: var(--mauve);
}
/* GFM tables — keep, slightly more editorial */
.prose table {
display: block;
width: 100%;
max-width: 100%;
overflow-x: auto;
margin: 1.75rem 0;
border-collapse: collapse;
border: 1px solid var(--surface2);
font-size: 0.95rem;
font-family: var(--font-sans);
}
.prose thead { background-color: color-mix(in srgb, var(--surface0) 80%, transparent); }
.prose th {
padding: 0.55rem 0.9rem;
text-align: left;
font-weight: 600;
color: var(--text);
border-bottom: 1px solid var(--surface2);
text-transform: uppercase;
letter-spacing: 0.08em;
font-size: 0.75rem;
}
.prose td {
padding: 0.5rem 0.9rem;
border-bottom: 1px solid color-mix(in srgb, var(--surface1) 60%, transparent);
}
.prose tr:last-child td { border-bottom: 0; }
@@ -0,0 +1,343 @@
/* ───── Salon plate — a single framed image card used on the gallery index ───── */
.plate {
position: relative;
background: var(--rosewater);
padding: 14px 14px 0 14px;
border: 1px solid var(--surface2);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 1px 0 var(--surface0),
0 22px 42px -28px rgba(20, 16, 12, 0.5),
0 4px 12px -6px rgba(20, 16, 12, 0.25);
border-radius: 2px;
transition: transform 0.4s cubic-bezier(0.2, 0.6, 0.2, 1),
box-shadow 0.4s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.salon-noir .plate,
.gothic .plate,
.breakcore .plate {
background: var(--surface0);
}
.salon-noir .plate,
.gothic .plate {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 22px 42px -28px rgba(0, 0, 0, 0.7),
0 4px 12px -6px rgba(0, 0, 0, 0.45);
}
.breakcore .plate {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--mauve) 35%, transparent),
0 0 0 1px color-mix(in srgb, var(--mauve) 20%, transparent),
0 22px 42px -28px rgba(255, 46, 166, 0.35),
0 0 24px -8px color-mix(in srgb, var(--mauve) 40%, transparent);
}
.plate:hover {
transform: translateY(-4px) rotate(-0.25deg);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 60%, transparent),
0 1px 0 var(--surface0),
0 32px 60px -28px rgba(20, 16, 12, 0.55),
0 8px 20px -8px rgba(20, 16, 12, 0.3);
}
.salon-noir .plate:hover,
.gothic .plate:hover {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 60%, transparent),
0 32px 60px -28px rgba(0, 0, 0, 0.8),
0 8px 20px -8px rgba(0, 0, 0, 0.55);
}
.breakcore .plate:hover {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--mauve) 45%, transparent),
0 0 0 1px color-mix(in srgb, var(--mauve) 30%, transparent),
0 32px 60px -28px rgba(255, 46, 166, 0.45),
0 0 32px -8px color-mix(in srgb, var(--mauve) 50%, transparent);
}
/* Keyboard focus for the card link — salon-appropriate inset frame + ring. */
.plate:focus-visible {
outline: none;
box-shadow:
inset 0 0 0 2px var(--mauve),
0 0 0 3px color-mix(in srgb, var(--mauve) 40%, transparent),
0 22px 42px -28px rgba(20, 16, 12, 0.5);
}
.breakcore .plate:focus-visible {
box-shadow:
inset 0 0 0 2px var(--mauve),
0 0 0 2px var(--green),
0 0 28px -6px color-mix(in srgb, var(--mauve) 60%, transparent);
}
.plate .plate-image {
position: relative;
overflow: hidden;
background: var(--mantle);
}
.plate .plate-image img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
filter: saturate(0.94) contrast(1.02);
transition: transform 0.8s cubic-bezier(0.2, 0.6, 0.2, 1), filter 0.4s ease;
}
/* Natural mode — container drops fixed aspect so image shows its true ratio. */
.plate .plate-image.is-natural {
height: auto;
}
.plate .plate-image.is-natural img {
height: auto;
object-fit: contain;
}
.plate:hover .plate-image img {
transform: scale(1.03);
filter: saturate(1.05) contrast(1.04);
}
.plate .plate-caption {
padding: 14px 6px 16px 6px;
margin-top: 2px;
border-top: 1px solid color-mix(in srgb, var(--surface2) 50%, transparent);
display: flex;
flex-direction: column;
gap: 0.4rem;
}
.plate .plate-caption-title {
font-family: var(--font-display);
font-style: italic;
font-weight: 500;
font-size: 1.18rem;
line-height: 1.3;
color: var(--text);
letter-spacing: -0.005em;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
/* line-clamp's overflow:hidden clips italic-Fraunces descenders (g, y, p).
* Pad the clip box and pull the layout back with a matching negative
* margin so descenders survive without shifting siblings. */
padding-bottom: 0.16em;
margin-bottom: -0.16em;
transition: color 0.25s ease;
}
.plate:hover .plate-caption-title {
color: var(--mauve);
}
.plate .plate-caption-summary {
font-family: var(--font-sans);
font-style: italic;
font-size: 0.82rem;
line-height: 1.45;
color: var(--subtext0);
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
padding-bottom: 0.14em;
margin-bottom: -0.14em;
}
.plate .plate-caption-meta {
font-family: var(--font-sans);
font-size: 0.68rem;
text-transform: uppercase;
letter-spacing: 0.22em;
color: var(--subtext0);
white-space: nowrap;
display: flex;
align-items: center;
gap: 0.5rem;
padding-top: 0.25rem;
}
.plate .plate-caption-sep {
color: var(--mauve);
opacity: 0.55;
}
.plate-tag-mini {
position: absolute;
bottom: 16px;
right: 16px;
background: color-mix(in srgb, var(--crust) 70%, transparent);
color: var(--rosewater);
border: 1px solid color-mix(in srgb, var(--rosewater) 18%, transparent);
border-radius: 999px;
font-family: var(--font-sans);
font-size: 0.6rem;
font-weight: 600;
letter-spacing: 0.22em;
padding: 4px 11px;
text-transform: uppercase;
backdrop-filter: blur(3px);
}
/* Draft/"Sketch" marker — same chip, pinned bottom-left, amber instead of
* the neutral catalogue tag. Themed per skin below (no inline colors). */
.plate-tag-mini--draft {
left: 16px;
right: auto;
background: color-mix(in srgb, var(--peach) 88%, var(--crust));
color: var(--crust);
border-color: color-mix(in srgb, var(--peach) 45%, transparent);
}
/* Breakcore: hard neon catalogue tag — sharp rect, offset shadow, glow.
* Matches the layer's hazard-tape / hard-offset chrome language. */
.breakcore .plate-tag-mini {
background: var(--crust);
color: var(--green);
border: 1px solid var(--mauve);
border-radius: 0;
font-family: var(--font-mono);
font-weight: 500;
letter-spacing: 0.14em;
text-shadow: 0 0 6px color-mix(in srgb, var(--green) 60%, transparent);
box-shadow:
2px 2px 0 var(--mauve),
0 0 14px -2px color-mix(in srgb, var(--mauve) 65%, transparent);
backdrop-filter: none;
}
.breakcore .plate-tag-mini--draft {
color: var(--peach);
border-color: var(--peach);
text-shadow: 0 0 6px color-mix(in srgb, var(--peach) 60%, transparent);
box-shadow:
2px 2px 0 var(--peach),
0 0 14px -2px color-mix(in srgb, var(--peach) 65%, transparent);
}
/* Nameplate — the museum-style header used in the site chrome */
.nameplate {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
gap: 2px;
position: relative;
}
.nameplate::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: -6px;
height: 2px;
background: linear-gradient(to right,
var(--mauve) 0%,
var(--mauve) 35%,
var(--surface2) 35%,
var(--surface2) 100%);
}
.nameplate-title {
font-family: var(--font-display);
font-weight: 600;
font-style: italic;
font-size: 1.6rem;
letter-spacing: -0.01em;
color: var(--text);
/* Loose enough that italic-Fraunces descenders (g, y, p) and the
* breakcore chromatic glow clear the line box — nothing slices them. */
line-height: 1.2;
padding-bottom: 0.06em;
}
.nameplate-subtitle {
font-family: var(--font-sans);
font-size: 0.65rem;
letter-spacing: 0.32em;
text-transform: uppercase;
color: var(--subtext0);
}
/* Section ornaments */
.section-rule {
display: flex;
align-items: center;
gap: 1rem;
color: var(--subtext0);
font-family: var(--font-display);
font-style: italic;
font-size: 0.95rem;
letter-spacing: 0.04em;
}
.section-rule::before,
.section-rule::after {
content: "";
flex: 1;
height: 1px;
background: var(--surface2);
}
.section-rule .ornament {
color: var(--mauve);
}
/* Scrawled handwritten margin notes */
.scrawl {
font-family: var(--font-hand);
color: var(--mauve);
font-size: 1.4rem;
line-height: 1;
transform: rotate(-6deg);
display: inline-block;
}
.scrawl-mark::before {
content: "✕";
font-family: var(--font-hand);
color: var(--red);
margin-right: 0.35em;
}
/* Stripe (Matisse cutout) chip used for tags */
.chip {
display: inline-flex;
align-items: center;
gap: 0.3rem;
font-family: var(--font-display);
font-style: italic;
font-size: 0.78rem;
padding: 0.15rem 0.6rem;
background: color-mix(in srgb, var(--surface0) 80%, transparent);
border: 1px solid var(--surface2);
color: var(--subtext1);
border-radius: 1px;
letter-spacing: 0.02em;
}
.chip-accent {
background: var(--mauve);
color: var(--rosewater);
border-color: var(--mauve);
}
.chip-draft {
background: color-mix(in srgb, var(--peach) 18%, transparent);
color: var(--peach);
border-color: color-mix(in srgb, var(--peach) 50%, transparent);
}
/* Card / glass — keep the name but reinterpret as a paper card */
.glass {
background-color: color-mix(in srgb, var(--surface0) 80%, transparent);
border: 1px solid var(--surface2);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 10px 30px -20px rgba(20, 16, 12, 0.45);
border-radius: 2px;
}
.salon-noir .glass,
.gothic .glass,
.breakcore .glass {
background-color: color-mix(in srgb, var(--surface0) 70%, transparent);
}
.salon-noir .glass {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 14px 40px -24px rgba(0, 0, 0, 0.8);
}
.gothic .glass {
border-color: color-mix(in srgb, var(--mauve) 35%, var(--surface2));
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--mauve) 18%, transparent),
0 14px 40px -24px rgba(0, 0, 0, 0.85);
}
.breakcore .glass {
border-color: color-mix(in srgb, var(--mauve) 45%, var(--surface2));
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--mauve) 25%, transparent),
0 0 0 1px color-mix(in srgb, var(--teal) 15%, transparent),
0 14px 40px -24px rgba(0, 0, 0, 0.9);
}
+176
View File
@@ -0,0 +1,176 @@
/*
* BLOG MODE — writing-first stacked rows.
*
* Same skin as the gallery (display font, palette, theme variants, paper
* grain, CyberFx) — only the *focus* flips: the post's words lead, the cover
* shrinks to a side thumbnail. Everything here is scoped under
* `html.mode-blog`; atelier (the default) never sees these rules, and the
* justified-gallery markup simply isn't emitted in blog mode.
*/
html.mode-blog .post-list {
width: 100%;
max-width: 52rem;
}
/* One post = one row, separated by a hairline like a printed contents page. */
html.mode-blog .post-row {
position: relative;
padding: 1.9rem 0;
border-bottom: 1px solid color-mix(in srgb, var(--surface2) 55%, transparent);
}
html.mode-blog .post-row:first-child {
padding-top: 0;
}
html.mode-blog .post-row:last-of-type {
border-bottom: none;
}
html.breakcore.mode-blog .post-row {
border-bottom-color: color-mix(in srgb, var(--mauve) 30%, transparent);
}
html.mode-blog .post-row-link {
display: flex;
align-items: flex-start;
gap: 1.75rem;
outline: none;
}
html.mode-blog .post-row-body {
flex: 1 1 auto;
min-width: 0;
}
html.mode-blog .post-row-title {
font-family: var(--font-display);
font-style: italic;
font-weight: 600;
font-size: clamp(1.55rem, 1.1rem + 1.8vw, 2.4rem);
line-height: 1.12;
letter-spacing: -0.012em;
color: var(--text);
/* clip-box padding so italic Fraunces descenders survive (same trick as
* .plate-caption-title) */
padding-bottom: 0.08em;
margin-bottom: -0.08em;
transition: color 0.3s ease;
}
html.mode-blog .post-row-link:hover .post-row-title,
html.mode-blog .post-row-link:focus-visible .post-row-title {
color: var(--mauve);
}
html.mode-blog .post-row-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
margin-top: 0.7rem;
font-family: var(--font-sans);
font-size: 0.78rem;
letter-spacing: 0.16em;
text-transform: uppercase;
color: var(--subtext0);
}
html.mode-blog .post-row-meta .sep {
color: var(--overlay0);
}
html.mode-blog .post-row-excerpt {
margin-top: 0.85rem;
font-family: var(--font-sans);
font-size: 1rem;
line-height: 1.65;
color: var(--subtext1);
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
html.mode-blog .post-row-tags {
display: flex;
flex-wrap: wrap;
gap: 0.4rem;
margin-top: 1rem;
}
/* Side thumbnail — framed like a small plate so the salon material carries
* over. position:relative + overflow:hidden so the cybersigil hover sigil
* (.cs-plate-sig, inset:0) pins to the image box, never the row. */
html.mode-blog .post-row-thumb {
position: relative;
flex: 0 0 auto;
width: clamp(96px, 22vw, 184px);
aspect-ratio: 4 / 3;
overflow: hidden;
background: var(--mantle);
border: 1px solid var(--surface2);
border-radius: 2px;
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 14px 30px -22px rgba(20, 16, 12, 0.5);
transition: box-shadow 0.4s cubic-bezier(0.2, 0.6, 0.2, 1);
}
html.salon-noir.mode-blog .post-row-thumb,
html.gothic.mode-blog .post-row-thumb {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 50%, transparent),
0 14px 30px -22px rgba(0, 0, 0, 0.75);
}
html.breakcore.mode-blog .post-row-thumb {
border-color: color-mix(in srgb, var(--mauve) 40%, var(--surface2));
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--mauve) 28%, transparent),
0 0 22px -10px color-mix(in srgb, var(--mauve) 45%, transparent);
}
html.mode-blog .post-row-thumb img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
filter: saturate(0.94) contrast(1.02);
transition: transform 0.7s cubic-bezier(0.2, 0.6, 0.2, 1), filter 0.4s ease;
}
html.mode-blog .post-row-link:hover .post-row-thumb img,
html.mode-blog .post-row-link:focus-visible .post-row-thumb img {
transform: scale(1.04);
filter: saturate(1.05) contrast(1.04);
}
html.mode-blog .post-row-link:hover .post-row-thumb,
html.mode-blog .post-row-link:focus-visible .post-row-thumb {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--surface1) 62%, transparent),
0 20px 38px -22px rgba(20, 16, 12, 0.55);
}
html.breakcore.mode-blog .post-row-link:hover .post-row-thumb,
html.breakcore.mode-blog .post-row-link:focus-visible .post-row-thumb {
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--mauve) 42%, transparent),
0 0 30px -8px color-mix(in srgb, var(--mauve) 55%, transparent);
}
/* Keyboard focus — inset salon ring on the whole row link. */
html.mode-blog .post-row-link:focus-visible {
box-shadow:
inset 0 0 0 2px var(--mauve),
0 0 0 3px color-mix(in srgb, var(--mauve) 35%, transparent);
border-radius: 2px;
}
html.mode-blog .post-row-draft {
font-family: var(--font-display);
font-style: italic;
letter-spacing: 0.04em;
}
/* Tighter stack on phones; thumbnail drops below the text. */
@media (max-width: 600px) {
html.mode-blog .post-row-link {
flex-direction: column-reverse;
gap: 1rem;
}
html.mode-blog .post-row-thumb {
width: 100%;
aspect-ratio: 16 / 9;
}
}
@@ -0,0 +1,454 @@
/* ───── Buttons — one system ─────
* Base .btn = layout + size + focus/disabled. One variant for color
* (--primary / --ghost / --danger), one size modifier (--sm / --lg),
* shape modifiers (--icon / --block). Never restyle buttons ad-hoc. */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
height: 2.5rem;
padding: 0 1.2rem;
font-family: var(--font-display);
font-style: italic;
font-weight: 500;
font-size: 0.95rem;
line-height: 1;
letter-spacing: 0.02em;
background: transparent;
color: var(--text);
border: 1px solid transparent;
border-radius: 1px;
text-decoration: none;
white-space: nowrap;
cursor: pointer;
transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease,
border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:focus-visible {
outline: none;
border-color: var(--mauve);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--mauve) 35%, transparent);
}
.btn:disabled,
.btn[aria-disabled="true"] {
opacity: 0.55;
cursor: default;
pointer-events: none;
}
.btn svg { width: 1.05em; height: 1.05em; flex-shrink: 0; }
/* Variants */
.btn--primary {
background: var(--mauve);
color: var(--rosewater);
border-color: color-mix(in srgb, var(--mauve) 80%, var(--crust));
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}
.btn--primary:hover {
transform: translateY(-1px);
background: var(--red);
border-color: color-mix(in srgb, var(--red) 80%, var(--crust));
box-shadow: 0 7px 16px -7px color-mix(in srgb, var(--red) 65%, transparent);
}
.btn--primary:active {
transform: translateY(0);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}
.btn--ghost {
color: var(--subtext1);
border-color: var(--surface2);
background: color-mix(in srgb, var(--surface0) 45%, transparent);
}
.btn--ghost:hover {
color: var(--mauve);
border-color: color-mix(in srgb, var(--mauve) 50%, var(--surface2));
background: color-mix(in srgb, var(--surface0) 80%, transparent);
}
.btn--danger {
color: var(--red);
border-color: color-mix(in srgb, var(--red) 55%, var(--surface2));
background: color-mix(in srgb, var(--red) 12%, transparent);
}
.btn--danger:hover {
color: var(--rosewater);
background: var(--red);
border-color: var(--red);
}
/* Pressed/selected state for toggle & tab buttons. Solid accent fill so an
* engaged toggle is unmistakable (label alone is too subtle). The
* `.btn--ghost.is-active` selector carries enough specificity (0,3,0) to beat
* the theme `.cybersigil/.breakcore .btn--ghost` rules (0,2,0) that load in
* later partials — without it the active state is invisible on those themes. */
.btn.is-active,
.btn.btn--ghost.is-active {
color: var(--rosewater);
background: var(--mauve);
border-color: var(--mauve);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--crust) 35%, transparent),
0 0 0 1px color-mix(in srgb, var(--mauve) 45%, transparent);
}
/* The vim toggle is desktop-only — vim mode auto-disables below 768px, so the
* button is a no-op there. Unlayered media query (Tailwind `hidden` would
* lose the cascade to `.btn { display: inline-flex }`). */
@media (max-width: 767px) {
.btn.vim-toggle { display: none !important; }
}
/* Sizes */
.btn--sm { height: 2rem; padding: 0 0.85rem; font-size: 0.85rem; gap: 0.35rem; }
.btn--lg { height: 3rem; padding: 0 1.6rem; font-size: 1.05rem; }
/* Shapes */
.btn--icon { padding: 0; width: 2.5rem; }
.btn--icon.btn--sm { width: 2rem; }
.btn--block { width: 100%; }
/* Back-link — a real affordance, not bare body text. One markup for
* every "← back" return link (post, admin, login). */
.back-link {
display: inline-flex;
align-items: center;
gap: 0.5rem;
font-family: var(--font-display);
font-style: italic;
font-size: 0.9rem;
line-height: 1;
color: var(--subtext1);
text-decoration: none;
padding: 0.35rem 0.1rem;
border-bottom: 1px solid color-mix(in srgb, var(--subtext1) 35%, transparent);
transition: color 0.15s ease, border-color 0.15s ease, gap 0.15s ease;
}
.back-link:hover,
.back-link:focus-visible {
color: var(--mauve);
border-color: var(--mauve);
gap: 0.7rem;
outline: none;
}
.back-link .bl-arrow {
display: inline-block;
transition: transform 0.15s ease;
}
.back-link:hover .bl-arrow,
.back-link:focus-visible .bl-arrow { transform: translateX(-3px); }
/* ───── Top-bar controls — one height, one language ─────
* `.topbar-cluster` lays the chrome controls out as one tidy, right-aligned
* group that wraps as a unit (never a ragged full-width column on mobile).
* Every control is the same 2rem height; icon-only variants are exact
* squares so they line up cleanly next to each other. */
.topbar-cluster {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0.4rem;
justify-content: flex-start;
}
@media (min-width: 768px) {
.topbar-cluster { justify-content: flex-end; }
}
/* A hairline divider between the public controls and the admin group. */
.topbar-divider {
align-self: stretch;
width: 1px;
margin: 0.15rem 0.15rem;
background: var(--surface2);
flex: none;
}
.topbar-control {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.4rem;
height: 2rem;
padding: 0 0.7rem;
flex: none;
font-family: var(--font-display);
font-style: italic;
font-size: 0.85rem;
line-height: 1;
color: var(--subtext1);
background: color-mix(in srgb, var(--surface0) 55%, transparent);
border: 1px solid var(--surface2);
border-radius: 1px;
text-decoration: none;
cursor: pointer;
white-space: nowrap;
transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.topbar-control:hover {
color: var(--mauve);
background: color-mix(in srgb, var(--surface0) 85%, transparent);
border-color: color-mix(in srgb, var(--mauve) 45%, var(--surface2));
}
.topbar-control:focus-visible {
outline: none;
border-color: var(--mauve);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--mauve) 40%, transparent);
}
.topbar-control:disabled { opacity: 0.5; cursor: default; }
.topbar-control svg { width: 15px; height: 15px; flex-shrink: 0; }
/* Exact-square icon-only variant — keeps the row aligned. */
.topbar-control--icon { width: 2rem; padding: 0; }
/* Keyboard-shortcut hover/focus tooltip — kept out of the button label,
* surfaced only on hover or keyboard focus. */
.kbd-tip-host { position: relative; }
.kbd-tip {
position: absolute;
top: calc(100% + 8px);
left: 50%;
display: flex;
align-items: center;
gap: 0.3rem;
white-space: nowrap;
padding: 4px 8px;
font-family: var(--font-sans);
font-size: 0.6rem;
font-style: normal;
letter-spacing: 0.16em;
text-transform: uppercase;
color: var(--subtext1);
background: color-mix(in srgb, var(--crust) 90%, transparent);
border: 1px solid color-mix(in srgb, var(--surface2) 70%, transparent);
border-radius: 4px;
box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.5);
opacity: 0;
transform: translate(-50%, 4px);
pointer-events: none;
transition: opacity 0.16s ease, transform 0.16s ease;
z-index: 60;
}
.kbd-tip kbd {
font-family: var(--font-mono);
font-size: 0.62rem;
line-height: 1;
padding: 2px 5px;
color: var(--text);
background: color-mix(in srgb, var(--surface0) 70%, transparent);
border: 1px solid color-mix(in srgb, var(--surface2) 80%, transparent);
border-radius: 3px;
}
.kbd-tip-host:hover .kbd-tip,
.kbd-tip-host:focus-visible .kbd-tip {
opacity: 1;
transform: translate(-50%, 0);
}
/* Breakcore: hard neon tooltip — matches the layer's offset-shadow chrome. */
.breakcore .kbd-tip {
background: var(--crust);
border-color: var(--mauve);
border-radius: 0;
color: var(--green);
box-shadow: 2px 2px 0 var(--mauve);
}
.breakcore .kbd-tip kbd {
color: var(--rosewater);
background: var(--surface0);
border-color: var(--mauve);
border-radius: 0;
}
@media (prefers-reduced-motion: reduce) {
.kbd-tip { transition: opacity 0.16s ease; transform: translate(-50%, 0); }
}
.topbar-control--danger:hover {
color: var(--red);
border-color: color-mix(in srgb, var(--red) 55%, var(--surface2));
}
/* Native <select> variant — leave room for the chevron overlay.
* Fixed width so switching themes never resizes the whole top bar. */
select.topbar-control {
appearance: none;
-webkit-appearance: none;
padding-right: 1.9rem;
}
select.topbar-control.theme-select {
width: 8.75rem;
justify-content: flex-start;
text-align: left;
}
.topbar-control kbd {
display: inline-flex;
align-items: center;
gap: 0.15rem;
font-family: var(--font-mono, monospace);
font-style: normal;
font-size: 0.62rem;
padding: 0.05rem 0.3rem;
border: 1px solid var(--surface2);
border-radius: 1px;
color: var(--subtext0);
}
/* Responsive collapse — below a breakpoint a control drops its label and
* becomes an exact 2rem square so the cluster stays a tidy aligned row on
* phones. Written unlayered (not Tailwind utilities) so it reliably wins
* over the `.topbar-control` base in the Tailwind v4 cascade. */
.topbar-control .tc-label { display: inline; }
@media (max-width: 767px) {
.topbar-control.tc-collapse-md { width: 2rem; padding: 0; }
.topbar-control.tc-collapse-md .tc-label { display: none; }
}
@media (max-width: 639px) {
.topbar-control.tc-collapse-sm { width: 2rem; padding: 0; }
.topbar-control.tc-collapse-sm .tc-label { display: none; }
}
/* Form input look */
.field-input {
width: 100%;
background: color-mix(in srgb, var(--surface0) 60%, transparent);
border: 1px solid var(--surface2);
border-radius: 1px;
padding: 0.65rem 0.9rem;
color: var(--text);
font-family: var(--font-sans);
font-size: 1rem;
transition: border-color 0.15s, background 0.15s;
}
.field-input:focus {
outline: none;
border-color: var(--mauve);
background: color-mix(in srgb, var(--surface0) 85%, var(--mauve) 8%);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--mauve) 22%, transparent);
}
.field-label {
display: block;
font-family: var(--font-sans);
font-size: 0.72rem;
letter-spacing: 0.22em;
text-transform: uppercase;
color: var(--subtext0);
margin-bottom: 0.4rem;
}
/* hljs token colors — driven by theme tokens, slightly muted for parchment bg */
.hljs { color: var(--text); background: transparent; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-operator { color: var(--mauve); font-weight: 600; }
.hljs-string, .hljs-attr, .hljs-regexp, .hljs-addition { color: var(--green); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--peach); }
.hljs-comment, .hljs-quote { color: var(--overlay0); font-style: italic; }
.hljs-title, .hljs-section, .hljs-name, .hljs-title.function_ { color: var(--blue); }
.hljs-type, .hljs-class .hljs-title, .hljs-title.class_ { color: var(--yellow); }
.hljs-variable, .hljs-template-variable, .hljs-params, .hljs-property { color: var(--red); }
.hljs-attribute, .hljs-meta, .hljs-meta .hljs-keyword { color: var(--subtext0); }
.hljs-deletion { color: var(--red); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
/* KaTeX */
.katex { color: var(--text); }
/* Skeleton loader */
.skeleton {
background: linear-gradient(
90deg,
color-mix(in srgb, var(--surface0) 50%, transparent) 0%,
color-mix(in srgb, var(--surface1) 50%, transparent) 50%,
color-mix(in srgb, var(--surface0) 50%, transparent) 100%
);
background-size: 200% 100%;
animation: skeleton-shimmer 1.5s ease-in-out infinite;
border-radius: 1px;
}
@keyframes skeleton-shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
/* Toast */
.toast {
position: fixed;
top: 1.25rem;
left: 50%;
transform: translateX(-50%);
background: var(--mantle);
border: 1px solid var(--surface2);
color: var(--rosewater);
padding: 0.65rem 1.1rem;
border-radius: 1px;
box-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.55);
font-family: var(--font-display);
font-style: italic;
font-size: 0.9rem;
z-index: 200;
cursor: pointer;
animation: toast-in 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes toast-in {
from { opacity: 0; transform: translate(-50%, -10px); }
to { opacity: 1; transform: translate(-50%, 0); }
}
.toast--out {
animation: toast-out 0.2s ease forwards;
}
@keyframes toast-out {
from { opacity: 1; transform: translate(-50%, 0); }
to { opacity: 0; transform: translate(-50%, -10px); }
}
/* Success variant — parallels .toast--error. */
.toast--success {
border-left: 3px solid var(--green);
color: var(--rosewater);
}
.toast--success::before {
content: "✓ ";
color: var(--green);
}
/* Justified gallery — JS solves each row's height so widths fill the line
* exactly (PostList.tsx). flex-grow on the tiles absorbs sub-pixel rounding;
* the pre-measure / no-JS fallback wraps and grows by aspect instead. */
.just-gallery { width: 100%; }
.just-row {
display: flex;
flex-wrap: nowrap;
align-items: flex-start;
gap: 18px;
}
.just-row--fallback {
flex-wrap: wrap;
row-gap: 40px;
}
.just-row > .plate-enter { min-width: 0; }
/* Very narrow viewports: let even the fallback stack cleanly. */
@media (max-width: 420px) {
.just-row--fallback > .plate-enter { flex-basis: 100% !important; }
}
/* Subtle page enter animation for gallery / plaque */
@keyframes plate-fade-up {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0); }
}
.plate-enter {
opacity: 0;
animation: plate-fade-up 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
/* Custom checkbox accent for form bits inside the salon */
input[type="checkbox"] { accent-color: var(--mauve); }
input[type="date"] { color-scheme: light; }
.salon-noir input[type="date"] { color-scheme: dark; }
.gothic input[type="date"] { color-scheme: dark; }
.breakcore input[type="date"] { color-scheme: dark; }
/* Reading progress bar - thin terracotta line */
.reading-progress {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 2px;
background: var(--mauve);
z-index: 150;
transform-origin: left;
transform: scaleX(0);
transition: transform 80ms linear;
}
@@ -0,0 +1,471 @@
/* ═══════════════════════════════════════════════════════════════════════
* BREAKCORE — refined-neon layer.
* Everything below is scoped to `.breakcore`; salon / salon-noir / gothic
* are untouched. Aesthetic: editorial serif body in deliberate tension with
* hard-edged web-rot chrome — RGB split, hazard tape, neon outline, hard
* offset shadows. Motion is *reactive only* (hover / focus / one-shot on
* load) and settles fast. All motion is killed by prefers-reduced-motion
* at the very end of this file.
* ═══════════════════════════════════════════════════════════════════════ */
/* CRT tube depth — static vignette layered on the existing base fill. */
.breakcore body::before {
background-image: radial-gradient(
ellipse at center,
transparent 52%,
color-mix(in srgb, var(--crust) 75%, transparent) 100%
);
}
/* Nameplate — breakcore reworks the underline: hard cyan offset + magenta
* neon glow (the layer's hard-offset chrome language) instead of the
* default two-tone rule. Plus a glitch-shear burst on hover. */
.breakcore .nameplate::after {
height: 2px;
bottom: -7px;
background: var(--mauve);
box-shadow:
2px 2px 0 var(--blue),
0 0 10px color-mix(in srgb, var(--mauve) 70%, transparent);
}
@keyframes bc-shear {
0% { clip-path: inset(0 0 0 0); transform: translateX(0);
text-shadow: -1px 0 0 var(--teal), 1px 0 0 var(--mauve); }
20% { clip-path: inset(16% 0 56% 0); transform: translateX(-5px);
text-shadow: -5px 0 0 var(--green), 5px 0 0 var(--mauve); }
40% { clip-path: inset(62% 0 10% 0); transform: translateX(5px);
text-shadow: 5px 0 0 var(--teal), -5px 0 0 var(--red); }
60% { clip-path: inset(30% 0 42% 0); transform: translateX(-3px);
text-shadow: -3px 0 0 var(--mauve), 3px 0 0 var(--green); }
80% { clip-path: inset(6% 0 78% 0); transform: translateX(2px);
text-shadow: 2px 0 0 var(--teal), -2px 0 0 var(--mauve); }
100% { clip-path: inset(0 0 0 0); transform: translateX(0);
text-shadow: -1px 0 0 var(--teal), 1px 0 0 var(--mauve); }
}
.breakcore .nameplate:hover .nameplate-title {
animation: bc-shear 200ms steps(3, jump-none) 1;
}
/* Display headings — one-shot glitch-in on page load. The static chromatic
* text-shadow (defined earlier) remains as the resting state. */
@keyframes bc-load-glitch {
0% { opacity: 0; clip-path: inset(46% 0 46% 0); transform: translateX(-9px); }
20% { opacity: 1; clip-path: inset(8% 0 70% 0); transform: translateX(7px); }
40% { clip-path: inset(68% 0 8% 0); transform: translateX(-5px); }
60% { clip-path: inset(24% 0 36% 0); transform: translateX(3px); }
80% { clip-path: inset(4% 0 84% 0); transform: translateX(-2px); }
/* End unclipped (none, not inset(0)) so italic-Fraunces descenders
* (g, y, p) aren't sliced at the box edge once the glitch settles. */
100% { opacity: 1; clip-path: none; transform: translateX(0); }
}
.breakcore .prose h1,
.breakcore h1.font-display {
/* `backwards` (not `both`): after the one-shot, props revert to base —
* clip-path: none — instead of persisting the final inset clip. */
animation: bc-load-glitch 460ms steps(5, jump-none) backwards;
}
/* Plate — hard hover (no soft lift), RGB-split image, scanline sweep. */
.breakcore .plate:hover {
transform: translateY(-3px);
}
.breakcore .plate:hover .plate-caption-title {
text-shadow: -1px 0 0 var(--teal), 1px 0 0 var(--mauve);
}
.breakcore .plate:hover .plate-image img {
filter:
drop-shadow(-3px 0 0 color-mix(in srgb, var(--mauve) 70%, transparent))
drop-shadow(3px 0 0 color-mix(in srgb, var(--teal) 70%, transparent))
saturate(1.12) contrast(1.06);
}
.breakcore .plate .plate-image::after {
content: "";
position: absolute;
inset: 0;
pointer-events: none;
opacity: 0;
transform: translateY(-110%);
mix-blend-mode: screen;
background: linear-gradient(
180deg,
transparent 0%,
color-mix(in srgb, var(--sky) 28%, transparent) 46%,
color-mix(in srgb, var(--mauve) 70%, transparent) 49%,
color-mix(in srgb, var(--green) 55%, transparent) 51%,
color-mix(in srgb, var(--sky) 28%, transparent) 54%,
transparent 100%
);
}
@keyframes bc-scan {
0% { transform: translateY(-110%); opacity: 0; }
12% { opacity: 1; }
88% { opacity: 1; }
100% { transform: translateY(110%); opacity: 0; }
}
.breakcore .plate:hover .plate-image::after,
.breakcore .plate:focus-visible .plate-image::after {
animation: bc-scan 0.62s cubic-bezier(0.4, 0, 0.2, 1) 1;
}
/* Section rule — hazard tape. Used on footer, post header, 404. */
.breakcore .section-rule {
color: var(--green);
font-family: var(--font-mono);
font-style: normal;
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 0.22em;
}
.breakcore .section-rule::before,
.breakcore .section-rule::after {
height: 1px;
opacity: 0.85;
background: linear-gradient(
to right,
transparent,
color-mix(in srgb, var(--mauve) 70%, transparent) 45%,
color-mix(in srgb, var(--teal) 70%, transparent) 55%,
transparent
);
}
.breakcore .section-rule .ornament {
color: var(--mauve);
}
/* Readability — `--overlay0` (#5A2D8E) is near-invisible on the breakcore
* ground. Lift the spots that use it as actual copy to the readable
* subtext ramp. */
.breakcore .prose h6,
.breakcore .prose del,
.breakcore .hljs-comment,
.breakcore .hljs-quote,
.breakcore .site-copyright,
.breakcore .slug-hint {
color: var(--subtext0);
}
/* Chips — neon outline, monospace caps. */
.breakcore .chip {
background: transparent;
border-color: color-mix(in srgb, var(--teal) 55%, transparent);
color: var(--teal);
font-family: var(--font-mono);
font-style: normal;
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: 0.1em;
border-radius: 0;
}
.breakcore .chip-accent {
background: var(--mauve);
color: var(--crust);
border-color: var(--mauve);
}
.breakcore .chip-draft {
background: transparent;
border-color: color-mix(in srgb, var(--green) 60%, transparent);
color: var(--green);
}
/* Plate caption meta — bracketed mono coordinates. */
.breakcore .plate-caption-meta {
font-family: var(--font-mono);
letter-spacing: 0.16em;
}
.breakcore .plate-caption-sep {
color: var(--green);
opacity: 1;
}
/* Buttons & inputs — square, hard offset block-shadow, neon focus. */
.breakcore .btn,
.breakcore .field-input,
.breakcore .topbar-control,
.breakcore .topbar-control kbd { border-radius: 0; }
.breakcore .btn--primary {
color: var(--crust);
border-color: var(--mauve);
box-shadow: 3px 3px 0 0 var(--green);
}
.breakcore .btn--primary:hover {
background: var(--green);
border-color: var(--green);
color: var(--crust);
box-shadow: 3px 3px 0 0 var(--mauve);
}
.breakcore .btn--primary:active {
transform: translate(2px, 2px);
box-shadow: 1px 1px 0 0 var(--mauve);
}
.breakcore .btn--danger {
box-shadow: 3px 3px 0 0 color-mix(in srgb, var(--red) 60%, var(--crust));
}
.breakcore .btn--danger:hover {
box-shadow: 3px 3px 0 0 var(--mauve);
}
.breakcore .btn--danger:active {
transform: translate(2px, 2px);
box-shadow: 1px 1px 0 0 var(--mauve);
}
.breakcore .btn:focus-visible {
border-color: var(--green);
box-shadow: 0 0 0 2px var(--green);
}
.breakcore .field-input:focus {
border-color: var(--green);
background: color-mix(in srgb, var(--surface0) 85%, var(--green) 8%);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 35%, transparent);
}
/* Ghost had no breakcore identity — drab subtext on faint surface,
* near-invisible on the violet ground. Give it the neon outline. */
.breakcore .btn--ghost {
color: var(--teal);
border-color: color-mix(in srgb, var(--teal) 55%, transparent);
background: color-mix(in srgb, var(--surface0) 60%, transparent);
box-shadow: 3px 3px 0 0 color-mix(in srgb, var(--teal) 35%, var(--crust));
}
.breakcore .btn--ghost:hover {
color: var(--crust);
background: var(--teal);
border-color: var(--teal);
box-shadow: 3px 3px 0 0 var(--mauve);
}
.breakcore .btn--ghost:active {
transform: translate(2px, 2px);
box-shadow: 1px 1px 0 0 var(--mauve);
}
/* Back-link → hard neon return tab. Impossible to miss against the
* CRT-violet ground; same offset-block language as .btn--primary. */
.breakcore .back-link {
font-family: var(--font-mono);
font-style: normal;
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: 0.16em;
color: var(--green);
padding: 7px 13px;
background: color-mix(in srgb, var(--crust) 65%, transparent);
border: 1px solid var(--mauve);
box-shadow: 3px 3px 0 0 var(--mauve);
text-shadow: 0 0 6px color-mix(in srgb, var(--green) 50%, transparent);
}
.breakcore .back-link:hover,
.breakcore .back-link:focus-visible {
color: var(--crust);
background: var(--green);
border-color: var(--green);
box-shadow: 3px 3px 0 0 var(--mauve);
text-shadow: none;
}
.breakcore .back-link:active {
transform: translate(3px, 3px);
box-shadow: 0 0 0 0 var(--mauve);
}
/* Top-bar chrome — neon UI, not drab subtext. Mono caps + hard offset. */
.breakcore .topbar-control {
font-family: var(--font-mono);
font-style: normal;
font-size: 0.72rem;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--teal);
background: color-mix(in srgb, var(--crust) 55%, transparent);
border-color: color-mix(in srgb, var(--teal) 50%, transparent);
}
.breakcore .topbar-control:hover {
color: var(--crust);
background: var(--mauve);
border-color: var(--mauve);
box-shadow: 2px 2px 0 0 var(--green);
}
.breakcore .topbar-control:focus-visible {
border-color: var(--green);
box-shadow: 0 0 0 2px var(--green);
}
.breakcore .topbar-control--danger:hover {
background: var(--red);
border-color: var(--red);
color: var(--rosewater);
box-shadow: 2px 2px 0 0 var(--mauve);
}
.breakcore .topbar-divider {
width: 2px;
background: repeating-linear-gradient(
180deg,
var(--mauve) 0 4px,
transparent 4px 7px
);
}
/* Post prev/next nav — neon offset panels + acid eyebrow (was dim text). */
.breakcore .post-nav a { transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.breakcore .post-nav a:hover {
border-color: var(--mauve);
box-shadow:
inset 0 0 0 1px color-mix(in srgb, var(--mauve) 40%, transparent),
4px 4px 0 0 var(--mauve);
}
.breakcore .post-nav .pn-eyebrow {
color: var(--green);
font-family: var(--font-mono);
letter-spacing: 0.18em;
text-shadow: 0 0 6px color-mix(in srgb, var(--green) 45%, transparent);
}
/* Prose / code — CRT pass: terminal block, hazard inline code, neon
* blockquote, hazard-tape rule. */
.breakcore .prose pre {
color: var(--teal);
background-color: color-mix(in srgb, var(--crust) 92%, transparent);
background-image: repeating-linear-gradient(
0deg,
rgba(0, 0, 0, 0) 0 2px,
color-mix(in srgb, var(--mauve) 9%, transparent) 2px 3px,
rgba(0, 0, 0, 0) 3px 4px
);
border-color: var(--mauve);
border-left-color: var(--green);
box-shadow:
0 0 0 1px color-mix(in srgb, var(--mauve) 28%, transparent),
4px 4px 0 0 color-mix(in srgb, var(--mauve) 35%, var(--crust));
}
.breakcore .prose pre code { color: inherit; }
.breakcore .prose :not(pre) code {
color: var(--yellow);
background: color-mix(in srgb, var(--yellow) 12%, transparent);
border-bottom-color: color-mix(in srgb, var(--yellow) 55%, transparent);
}
.breakcore .prose blockquote {
border-left-color: var(--mauve);
background: color-mix(in srgb, var(--mauve) 7%, transparent);
box-shadow: -3px 0 14px -5px color-mix(in srgb, var(--mauve) 55%, transparent);
padding: 0.5rem 0 0.5rem 1.4rem;
}
.breakcore .prose hr {
height: 3px;
opacity: 0.85;
background: repeating-linear-gradient(
90deg,
var(--mauve) 0 14px,
var(--green) 14px 28px
);
box-shadow: 0 0 10px color-mix(in srgb, var(--mauve) 40%, transparent);
}
.breakcore .prose hr::before {
background: var(--green);
box-shadow: 0 0 8px var(--green);
}
.breakcore .prose h3 { color: var(--pink); }
.breakcore .prose h4 { color: var(--teal); }
.breakcore .prose h5 { color: var(--green); font-family: var(--font-mono); }
/* Scrollbar + caret — full-immersion chrome (no default OS bar). */
.breakcore {
scrollbar-color: var(--mauve) var(--crust);
caret-color: var(--mauve);
}
.breakcore ::-webkit-scrollbar { width: 11px; height: 11px; }
.breakcore ::-webkit-scrollbar-track { background: var(--crust); }
.breakcore ::-webkit-scrollbar-thumb {
background: var(--mauve);
border: 2px solid var(--crust);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--green) 50%, transparent);
}
.breakcore ::-webkit-scrollbar-thumb:hover { background: var(--green); }
.breakcore ::-webkit-scrollbar-corner { background: var(--crust); }
/* Prose links — magenta resting, acid-green on hover. */
.breakcore .prose a {
text-decoration-color: color-mix(in srgb, var(--mauve) 55%, transparent);
}
.breakcore .prose a:hover {
color: var(--green);
text-decoration-color: var(--green);
}
/* Reading progress — acid scan with bloom. */
.breakcore .reading-progress {
background: var(--green);
box-shadow: 0 0 8px var(--green), 0 0 3px var(--mauve);
}
/* ───── Confirm dialog (replaces window.confirm) ───── */
.cdialog-overlay {
position: fixed;
inset: 0;
z-index: 300;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.cdialog-backdrop {
position: absolute;
inset: 0;
background: color-mix(in srgb, var(--crust) 60%, transparent);
backdrop-filter: blur(8px);
}
.cdialog-panel {
position: relative;
width: 100%;
max-width: 26rem;
padding: 1.6rem 1.6rem 1.4rem;
animation: cdialog-in 0.18s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes cdialog-in {
from { opacity: 0; transform: translateY(10px) scale(0.98); }
to { opacity: 1; transform: none; }
}
.cdialog-title {
font-family: var(--font-display);
font-style: italic;
font-weight: 600;
font-size: 1.4rem;
line-height: 1.15;
color: var(--text);
letter-spacing: -0.01em;
}
.cdialog-msg {
font-family: var(--font-sans);
font-size: 0.98rem;
line-height: 1.55;
color: var(--subtext1);
margin-top: 0.6rem;
}
.cdialog-actions {
display: flex;
justify-content: flex-end;
gap: 0.6rem;
margin-top: 1.5rem;
}
/* Breakcore: hard edges + neon cap + chromatic title. */
.breakcore .cdialog-panel {
border-radius: 0;
padding-top: 1.85rem;
}
.breakcore .cdialog-panel::before {
content: "";
position: absolute;
inset: 0 0 auto 0;
height: 2px;
background: linear-gradient(90deg, var(--mauve), var(--teal));
}
.breakcore .cdialog-title {
text-shadow: -1px 0 0 var(--teal), 1px 0 0 var(--mauve);
}
/* Toast error variant (replaces window.alert). */
.toast--error {
border-left: 3px solid var(--red);
color: var(--rosewater);
cursor: pointer;
}
.toast--error::before {
content: "⚠ ";
color: var(--red);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,25 @@
/* ─── Theme keyframes ─── */
@keyframes cs-blink {
0%, 49% { opacity: 1; }
50%, 100% { opacity: 0; }
}
@keyframes cs-flicker {
0%, 8% { opacity: 0.26; }
9% { opacity: 0.46; }
10%, 70% { opacity: 0.26; }
71% { opacity: 0.08; }
72% { opacity: 0.34; }
73%, 100% { opacity: 0.26; }
}
@keyframes cs-tear {
0%, 21% { opacity: 0; top: 18%; }
22% { opacity: 0.85; top: 18%; transform: translateX(-7px); }
23% { opacity: 0; }
46% { opacity: 0; top: 63%; }
47% { opacity: 0.7; top: 63%; transform: translateX(6px) skewX(-12deg); }
48%, 49% { opacity: 0; }
79% { opacity: 0; top: 41%; }
80% { opacity: 0.9; top: 41%; transform: translateX(-4px); }
81% { opacity: 0.2; }
82%, 100% { opacity: 0; }
}
@@ -0,0 +1,20 @@
/* ═══ Reduced motion — universal kill-switch. Final word in the file so it
* overrides every animation/transition above, all themes. Content still
* resolves to its final state (forwards-filled keyframes complete). ═══ */
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.001ms !important;
scroll-behavior: auto !important;
}
/* The looping sigils would otherwise collapse to their hidden end-state —
* pin them fully drawn instead so they stay visible, just still. */
.cybersigil .cs-fx-wire .cs-sigil path,
.cybersigil .cs-fx-corner--sig .cs-sigil path {
animation: none !important;
stroke-dashoffset: 0 !important;
}
}
+10
View File
@@ -0,0 +1,10 @@
import { defineConfig } from 'vitest/config';
// Pure-logic unit tests only (no Astro/DOM). Component/integration tests, if
// added later, should switch to `getViteConfig` from 'astro/config'.
export default defineConfig({
test: {
environment: 'node',
include: ['src/**/*.test.ts'],
},
});
@@ -0,0 +1 @@
{"version":"4.1.6","results":[[":frontend/src/lib/cybersigil.test.ts",{"duration":66.06918499999995,"failed":false}]]}