about summary refs log tree commit diff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/Cargo.toml1
-rw-r--r--frontend/index.html4
-rw-r--r--frontend/src/main.rs35
3 files changed, 37 insertions, 3 deletions
diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml
index e348451..7cc9e0b 100644
--- a/frontend/Cargo.toml
+++ b/frontend/Cargo.toml
@@ -7,6 +7,7 @@ edition = "2021"
 
 [dependencies]
 yew = "0.19"
+yew-router = "0.16"
 gloo = "0.8.0"
 web-sys = "0.3.60"
 wasm-bindgen = "0.2.83"
diff --git a/frontend/index.html b/frontend/index.html
index 35e10c8..abf3b18 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -7,7 +7,7 @@
     <title>OSSE</title>
     <link data-trunk rel="copy-dir" href="css">
     <link data-trunk rel="copy-dir" href="js">
-    <link href="./css/bootstrap.min.css" rel="stylesheet">
+    <link href="/css/bootstrap.min.css" rel="stylesheet">
     <style>
         body,
         html {
@@ -17,7 +17,7 @@
 </head>
 
 <body>
-    <script src="./js/bootstrap.bundle.min.js"></script>
+    <script src="/js/bootstrap.bundle.min.js"></script>
 </body>
 
 </html>
\ No newline at end of file
diff --git a/frontend/src/main.rs b/frontend/src/main.rs
index fd19fb4..95b52e5 100644
--- a/frontend/src/main.rs
+++ b/frontend/src/main.rs
@@ -1,6 +1,39 @@
 mod app;
 
-use app::App;
+use yew::prelude::*;
+use yew_router::prelude::*;
+use app::OSSE;
+
+
+#[derive(Clone, Routable, PartialEq)]
+enum Route {
+    #[at("/")]
+    OSSEHome,
+    #[at("/search/:query")]
+    OSSESearch { query: String },
+}
+
+fn switch_routes(routes: &Route) -> Html {
+    match routes {
+        Route::OSSEHome => html! {
+            <OSSE api_endpoint={"http://127.0.0.1:4444"}/>
+        },
+        Route::OSSESearch { query } => html! {
+            <OSSE api_endpoint={"http://127.0.0.1:4444"}/>
+        },
+    }
+}
+
+#[function_component(App)]
+fn yew_app() -> Html {
+    html! {
+        <>
+            <BrowserRouter>
+                <Switch<Route> render={Switch::render(switch_routes)} />
+            </BrowserRouter>
+        </>
+    }
+}
 
 fn main() {
     yew::start_app::<App>();