Implement hash fragments in the router (#2320)

* implement hash fragments in the router

* clean up query and search example

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2024-04-25 14:30:25 -04:00
1 parent dd8e69635b
commit 08da9a1253
17 files changed
+550 -190

No files matched your search

+11 -1
View File
@@ -3,6 +3,7 @@ use quote::{format_ident, quote};
use syn::LitStr;
use crate::{
hash::HashFragment,
nest::NestId,
query::QuerySegment,
segment::{create_error_type, parse_route_segments, RouteSegment},
@@ -14,6 +15,7 @@ pub(crate) struct Redirect {
pub nests: Vec<NestId>,
pub segments: Vec<RouteSegment>,
pub query: Option<QuerySegment>,
pub hash: Option<HashFragment>,
pub function: syn::ExprClosure,
pub index: usize,
}
@@ -40,6 +42,13 @@ impl Redirect {
}
}
pub fn parse_hash(&self) -> TokenStream {
match &self.hash {
Some(hash) => hash.parse(),
None => quote! {},
}
}
pub fn parse(
input: syn::parse::ParseStream,
active_nests: Vec<NestId>,
@@ -73,7 +82,7 @@ impl Redirect {
}
}
let (segments, query) = parse_route_segments(
let (segments, query, hash) = parse_route_segments(
path.span(),
#[allow(clippy::map_identity)]
closure_arguments.iter().map(|(name, ty)| (name, ty)),
@@ -85,6 +94,7 @@ impl Redirect {
nests: active_nests,
segments,
query,
hash,
function,
index,
})