Update configuration loading with Cargo.toml path and clean up .gitignore

---

This commit message concisely communicates the key changes:

1. The code now builds an absolute path to the `Cargo.toml` file, enhancing clarity in configuration loading.
2. The addition of `PathBuf` usage improves type safety.
3. The removal of unnecessary entries from `.gitignore` helps maintain a clean project structure.

These updates reflect improvements in both functionality and project organization.
This commit is contained in:
geoffsee
2025-08-31 14:06:44 -04:00
parent 7bc9479a11
commit 38d51722f2
3 changed files with 14 additions and 15 deletions

View File

@@ -1,3 +1,5 @@
use std::path::PathBuf;
pub mod app;
#[cfg(feature = "hydrate")]
@@ -15,7 +17,17 @@ pub fn create_leptos_router() -> axum::Router {
use leptos::prelude::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
let conf = get_configuration(None).unwrap();
// Build an absolute path to THIS crate's Cargo.toml
let mut cargo_toml = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
cargo_toml.push("Cargo.toml");
let conf = get_configuration(Some(
cargo_toml.to_str().expect("valid utf-8 path to Cargo.toml"),
))
.expect("load leptos config");
let conf = get_configuration(Some(cargo_toml.to_str().unwrap())).unwrap();
let leptos_options = conf.leptos_options;
// Generate the list of routes in your Leptos App
let routes = generate_route_list(App);