|
| 1 | +use std::collections::HashMap; |
| 2 | + |
1 | 3 | use yew::prelude::*; |
| 4 | +use yew::virtual_dom::AttrValue; |
| 5 | +use yew_router::history::{AnyHistory, History, MemoryHistory}; |
2 | 6 | use yew_router::prelude::*; |
3 | 7 |
|
4 | 8 | use crate::components::nav::Nav; |
@@ -47,53 +51,40 @@ pub fn App() -> Html { |
47 | 51 | } |
48 | 52 | } |
49 | 53 |
|
50 | | -#[cfg(not(target_arch = "wasm32"))] |
51 | | -mod arch_native { |
52 | | - use super::*; |
53 | | - |
54 | | - use yew::virtual_dom::AttrValue; |
55 | | - use yew_router::history::{AnyHistory, History, MemoryHistory}; |
56 | | - |
57 | | - use std::collections::HashMap; |
58 | | - |
59 | | - #[derive(Properties, PartialEq, Debug)] |
60 | | - pub struct ServerAppProps { |
61 | | - pub url: AttrValue, |
62 | | - pub queries: HashMap<String, String>, |
63 | | - } |
| 54 | +#[derive(Properties, PartialEq, Debug)] |
| 55 | +pub struct ServerAppProps { |
| 56 | + pub url: AttrValue, |
| 57 | + pub queries: HashMap<String, String>, |
| 58 | +} |
64 | 59 |
|
65 | | - #[function_component] |
66 | | - pub fn ServerApp(props: &ServerAppProps) -> Html { |
67 | | - let history = AnyHistory::from(MemoryHistory::new()); |
68 | | - history |
69 | | - .push_with_query(&*props.url, &props.queries) |
70 | | - .unwrap(); |
| 60 | +#[function_component] |
| 61 | +pub fn ServerApp(props: &ServerAppProps) -> Html { |
| 62 | + let history = AnyHistory::from(MemoryHistory::new()); |
| 63 | + history |
| 64 | + .push_with_query(&*props.url, &props.queries) |
| 65 | + .unwrap(); |
71 | 66 |
|
72 | | - html! { |
73 | | - <Router history={history}> |
74 | | - <Nav /> |
| 67 | + html! { |
| 68 | + <Router history={history}> |
| 69 | + <Nav /> |
75 | 70 |
|
76 | | - <main> |
77 | | - <Switch<Route> render={Switch::render(switch)} /> |
78 | | - </main> |
79 | | - <footer class="footer"> |
80 | | - <div class="content has-text-centered"> |
81 | | - { "Powered by " } |
82 | | - <a href="https://yew.rs">{ "Yew" }</a> |
83 | | - { " using " } |
84 | | - <a href="https://bulma.io">{ "Bulma" }</a> |
85 | | - { " and images from " } |
86 | | - <a href="https://unsplash.com">{ "Unsplash" }</a> |
87 | | - </div> |
88 | | - </footer> |
89 | | - </Router> |
90 | | - } |
| 71 | + <main> |
| 72 | + <Switch<Route> render={Switch::render(switch)} /> |
| 73 | + </main> |
| 74 | + <footer class="footer"> |
| 75 | + <div class="content has-text-centered"> |
| 76 | + { "Powered by " } |
| 77 | + <a href="https://yew.rs">{ "Yew" }</a> |
| 78 | + { " using " } |
| 79 | + <a href="https://bulma.io">{ "Bulma" }</a> |
| 80 | + { " and images from " } |
| 81 | + <a href="https://unsplash.com">{ "Unsplash" }</a> |
| 82 | + </div> |
| 83 | + </footer> |
| 84 | + </Router> |
91 | 85 | } |
92 | 86 | } |
93 | 87 |
|
94 | | -#[cfg(not(target_arch = "wasm32"))] |
95 | | -pub use arch_native::*; |
96 | | - |
97 | 88 | fn switch(routes: &Route) -> Html { |
98 | 89 | match routes.clone() { |
99 | 90 | Route::Post { id } => { |
|
0 commit comments