mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
Merge pull request #89 from mondeja/fix-core-url-ssr
Fix SSR detection from an url query parameter for `use_color_mode`
This commit is contained in:
commit
bfcf0837c7
2 changed files with 15 additions and 2 deletions
|
@ -3,6 +3,12 @@
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fix 🍕
|
||||||
|
|
||||||
|
- Fixed SSR detection from an url query parameter for `use_color_mode`.
|
||||||
|
|
||||||
## [0.10.4] - 2024-03-05
|
## [0.10.4] - 2024-03-05
|
||||||
|
|
||||||
### New Functions 🚀
|
### New Functions 🚀
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use leptos::window;
|
use leptos::window;
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "ssr", allow(dead_code))]
|
||||||
fn get() -> web_sys::Url {
|
fn get() -> web_sys::Url {
|
||||||
web_sys::Url::new(
|
web_sys::Url::new(
|
||||||
&window()
|
&window()
|
||||||
|
@ -11,10 +12,16 @@ fn get() -> web_sys::Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod params {
|
pub mod params {
|
||||||
use super::get as current_url;
|
use cfg_if::cfg_if;
|
||||||
|
|
||||||
/// Get a URL param value from the URL of the browser
|
/// Get a URL param value from the URL of the browser
|
||||||
pub fn get(k: &str) -> Option<String> {
|
pub fn get(k: &str) -> Option<String> {
|
||||||
current_url().search_params().get(k)
|
cfg_if! { if #[cfg(feature = "ssr")] {
|
||||||
|
_ = k;
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
use super::get as current_url;
|
||||||
|
current_url().search_params().get(k)
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue