"Building the Future of Trusted System Software Together"
@@ -15,32 +15,6 @@ pub fn Main() -> impl IntoView { "Leading technology partners creating secure, reusable, and reliable firmware for modern client devices.""Content not found"
}.into_any(), + } +} + +/// Parse the `id=` query parameter (without depending on a URL parser). +/// Returns the slug substring up to the next `&`, if any. +fn slug_from_query(search: &str) -> Option<&str> { + let id_start = search.find("id=")?; + let rest = &search[id_start + 3..]; + Some(match rest.find('&') { + Some(end) => &rest[..end], + None => rest, + }) +} + #[component] pub fn AnnouncementsPage() -> impl IntoView { let location = use_location(); let navigate = use_navigate(); - // List of announcement links and their content (display_text, title, slug) - let announcements = vec![( - "Oct-7-2025 Welcome Patina!", - "Patina Project to Launch at UEFI 2025 Developer Conference & Plugfest", - "welcome-patina-announcement", - )]; - let (selected, set_selected) = signal(0); - // Set selected from query param if present + // Sync the selected index from the `?id=slug` query param. { let location = location.clone(); - let announcements_clone = announcements.clone(); Effect::new(move |_| { let search = location.search.get(); - - // Check for new slug-based format: ?id=slug - if search.contains("id=") { - // Try to extract the id value more flexibly - if let Some(id_start) = search.find("id=") { - let slug = &search[id_start + 3..]; - // Remove any trailing parameters - let slug = if let Some(amp_pos) = slug.find('&') { - &slug[..amp_pos] - } else { - slug - }; - if let Some(idx) = announcements_clone.iter().position(|(_, _, s)| *s == slug) { - set_selected.set(idx); - } + if let Some(slug) = slug_from_query(&search) { + if let Some(idx) = index_of(slug) { + set_selected.set(idx); } } }); @@ -129,12 +130,12 @@ pub fn AnnouncementsPage() -> impl IntoView {-
- {announcements
+ {ANNOUNCEMENTS
.iter()
.enumerate()
- .map(|(i, (link, _, slug))| {
+ .map(|(i, a)| {
let navigate = navigate.clone();
- let slug = *slug;
+ let slug = a.slug;
view! {
- } @@ -157,25 +158,21 @@ pub fn AnnouncementsPage() -> impl IntoView {
"Content not found"
}.into_any(), - }; - (title.to_string(), content) + let idx = selected.get(); + if let Some(a) = ANNOUNCEMENTS.get(idx) { + view! { +{""}
}.into_any(), - ) - }; - view! { -{""}
+"body text"
+-
+
-
+
"Probe announcement body."
+