Skip to content

Commit

Permalink
feat: update site root to 'dist', enhance VSCode settings, and improv…
Browse files Browse the repository at this point in the history
…e routing for SSR
  • Loading branch information
Phosphorus-M committed Jan 1, 2025
1 parent c5cebb7 commit 3025f32
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
Empty file added .github/workflows/deploy.yml
Empty file.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ Cargo.lock

node_modules

dist

1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
"strings": true
},
"css.validate": false,
"rust-analyzer.cargo.features": ["ssr"]
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tailwind-input-file = "style/input.css"
tailwind-config-file = "tailwind.config.js"

# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"
site-root = "dist"

# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
Expand Down
7 changes: 3 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use leptos::prelude::*;
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
use leptos_router::{
components::{Route, Router, Routes},
StaticSegment,
components::{Route, Router, Routes}, static_routes::StaticRoute, SsrMode, StaticSegment
};
use reactive_stores::Store;

Expand Down Expand Up @@ -39,13 +38,13 @@ pub fn App() -> impl IntoView {
<Stylesheet id="leptos" href="/pkg/rust-peru.css"/>

// sets the document title
<Title text="Welcome to Leptos"/>
<Title text="Rust Perú"/>

// content for this welcome page
<Router>
<main>
<Routes fallback=|| "Page not found.".into_view()>
<Route path=StaticSegment("") view=HomePage/>
<Route path=StaticSegment("") view=HomePage ssr=SsrMode::Static(StaticRoute::new())/>
</Routes>
</main>
</Router>
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ async fn main() {
use axum::Router;
use leptos::logging::log;
use leptos::prelude::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::{generate_route_list_with_ssg, LeptosRoutes};
use rust_peru::app::*;

let conf = get_configuration(None).unwrap();
let addr = conf.leptos_options.site_addr;
let leptos_options = conf.leptos_options;
// Generate the list of routes in your Leptos App
let routes = generate_route_list(App);
let (routes, static_route_generator) = generate_route_list_with_ssg({
let leptos_options = leptos_options.clone();
move || shell(leptos_options.clone())
});

static_route_generator.generate(&leptos_options).await;

let app = Router::new()
.leptos_routes(&leptos_options, routes, {
Expand Down

0 comments on commit 3025f32

Please sign in to comment.