From 301129403f067c75d74b37f63b9d3bc55d9b582b Mon Sep 17 00:00:00 2001 From: Alexey Date: Fri, 24 Apr 2026 22:31:50 +0500 Subject: [PATCH] mantra v0.4.1: SPA-navigated lang toggle + RU core_claim extraction --- crates/mantra-server/src/corpus_loader.rs | 4 ++++ crates/mantra-ui/src/pages/shared.rs | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/mantra-server/src/corpus_loader.rs b/crates/mantra-server/src/corpus_loader.rs index 56bdcb9..34c0473 100644 --- a/crates/mantra-server/src/corpus_loader.rs +++ b/crates/mantra-server/src/corpus_loader.rs @@ -235,7 +235,11 @@ fn parse_source(path: &Path, cycle_slug: &str) -> Result { .map(|l| l.trim_start_matches("# ").trim().to_string()) .unwrap_or_else(|| slug.clone()); + // Try known heading variants: EN original + RU translation batch + // used «Ключевое утверждение». let core_claim = extract_section(&body_md, "## Core claim") + .or_else(|| extract_section(&body_md, "## Ключевое утверждение")) + .or_else(|| extract_section(&body_md, "## Ключевой тезис")) .unwrap_or_default() .trim() .replace('\n', " "); diff --git a/crates/mantra-ui/src/pages/shared.rs b/crates/mantra-ui/src/pages/shared.rs index c70c85f..61949af 100644 --- a/crates/mantra-ui/src/pages/shared.rs +++ b/crates/mantra-ui/src/pages/shared.rs @@ -1,6 +1,7 @@ //! Shared UI atoms. use leptos::prelude::*; +use leptos_router::components::A; use leptos_router::hooks::{use_location, use_query_map}; use crate::corpus::Lang; @@ -8,6 +9,10 @@ use crate::corpus::Lang; /// Minimal top-right language toggle. Two links; current is dimmed, /// the other is hot. Preserves the rest of the URL (path + remaining /// query params) so toggling on a deep page keeps you there. +/// +/// Uses the router's `` component so clicks are SPA-navigated and +/// the `use_query_map` signal updates without a page reload (Resources +/// keyed on lang re-fetch and the view re-renders in place). #[component] pub fn LangToggle(current: Memo) -> impl IntoView { let location = use_location(); @@ -23,15 +28,15 @@ pub fn LangToggle(current: Memo) -> impl IntoView { view! { } }