mirror of
https://github.com/leptos-rs/leptos
synced 2024-09-20 14:32:00 +00:00
docs: warn if you are using leptos_meta
without features (#797)
This commit is contained in:
parent
db9b7db53d
commit
64e056ffa9
3 changed files with 16 additions and 0 deletions
|
@ -83,6 +83,9 @@ pub fn Body(
|
|||
#[prop(optional, into)]
|
||||
attributes: Option<MaybeSignal<AdditionalAttributes>>,
|
||||
) -> impl IntoView {
|
||||
#[cfg(debug_assertions)]
|
||||
crate::feature_warning();
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
||||
let el = document().body().expect("there to be a <body> element");
|
||||
|
|
|
@ -98,6 +98,9 @@ pub fn Html(
|
|||
#[prop(optional, into)]
|
||||
attributes: Option<MaybeSignal<AdditionalAttributes>>,
|
||||
) -> impl IntoView {
|
||||
#[cfg(debug_assertions)]
|
||||
crate::feature_warning();
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
||||
let el = document().document_element().expect("there to be a <html> element");
|
||||
|
|
|
@ -206,6 +206,9 @@ pub fn provide_meta_context(cx: Scope) {
|
|||
/// call `use_head()` but a single [MetaContext] has not been provided at the application root.
|
||||
/// The best practice is always to call [provide_meta_context] early in the application.
|
||||
pub fn use_head(cx: Scope) -> MetaContext {
|
||||
#[cfg(debug_assertions)]
|
||||
feature_warning();
|
||||
|
||||
match use_context::<MetaContext>(cx) {
|
||||
None => {
|
||||
debug_warn!(
|
||||
|
@ -343,3 +346,10 @@ where
|
|||
TextProp(Rc::new(s))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub(crate) fn feature_warning() {
|
||||
if !cfg!(any(feature = "csr", feature = "hydrate", feature = "ssr")) {
|
||||
leptos::debug_warn!("WARNING: `leptos_meta` does nothing unless you enable one of its features (`csr`, `hydrate`, or `ssr`). See the docs at https://docs.rs/leptos_meta/latest/leptos_meta/ for more information.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue