diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-29 00:27:42 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-29 00:27:42 +0200 |
commit | 370d3037f9b7490af855d43f5ab9fbfb3bff494b (patch) | |
tree | f354f046caef997cd3619fad606614af4b449c20 | |
parent | Indexer: Implement basic priority calculation of words in a site (diff) | |
download | OSSE-370d3037f9b7490af855d43f5ab9fbfb3bff494b.tar.gz OSSE-370d3037f9b7490af855d43f5ab9fbfb3bff494b.tar.bz2 OSSE-370d3037f9b7490af855d43f5ab9fbfb3bff494b.zip |
Frontend: Use ResultComponent to display search results
-rw-r--r-- | frontend/src/main.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/frontend/src/main.rs b/frontend/src/main.rs index 38879f9..d2441d5 100644 --- a/frontend/src/main.rs +++ b/frontend/src/main.rs @@ -11,7 +11,7 @@ use yew::prelude::*; //TODO: we should import this from the indexer #[derive(Debug, Clone, Deserialize)] -struct CrawledResource { +pub struct CrawledResource { url: String, title: String, description: String, @@ -46,6 +46,18 @@ impl Hash for CrawledResource { } } +#[derive(Properties, Clone, PartialEq, Eq)] +pub struct ResultComponentProps { + result: CrawledResource, +} + +#[function_component(ResultComponent)] +fn result_component(props: &ResultComponentProps) -> Html { + html! { + <a href={props.result.url.clone()}>{props.result.url.clone()}{"--"}{props.result.title.clone()}{"----"}{props.result.description.clone()}{format!("PRIO: {}", props.result.priority)}</a> + } +} + #[derive(Debug, Clone)] struct State { pub search_query: String, @@ -73,8 +85,7 @@ fn osse() -> Html { .map(|r| { html! { <div key={r.url.to_owned()}> - //Show page title and description - <a href={r.url.to_owned()}>{r.url.to_owned()}{"--"}{r.title.to_owned()}{"----"}{r.description.to_owned()}{format!("PRIO: {}", r.priority)}</a> + <ResultComponent result={r.clone()} /> </div> } }) |