mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
chore(leptos_meta): enhance links in docs (#1783)
This commit is contained in:
parent
c9d132f007
commit
de9fb5e382
7 changed files with 21 additions and 18 deletions
|
@ -4,10 +4,10 @@
|
|||
//! # Leptos Meta
|
||||
//!
|
||||
//! Leptos Meta allows you to modify content in a document’s `<head>` from within components
|
||||
//! using the [Leptos](https://github.com/leptos-rs/leptos) web framework.
|
||||
//! using the [`Leptos`](https://github.com/leptos-rs/leptos) web framework.
|
||||
//!
|
||||
//! Document metadata is updated automatically when running in the browser. For server-side
|
||||
//! rendering, after the component tree is rendered to HTML, [MetaContext::dehydrate] can generate
|
||||
//! rendering, after the component tree is rendered to HTML, [`MetaContext::dehydrate`] can generate
|
||||
//! HTML that should be injected into the `<head>` of the HTML document being rendered.
|
||||
//!
|
||||
//! ```
|
||||
|
@ -75,10 +75,10 @@ pub use style::*;
|
|||
pub use stylesheet::*;
|
||||
pub use title::*;
|
||||
|
||||
/// Contains the current state of meta tags. To access it, you can use [use_head].
|
||||
/// Contains the current state of meta tags. To access it, you can use [`use_head`].
|
||||
///
|
||||
/// This should generally by provided somewhere in the root of your application using
|
||||
/// [provide_meta_context].
|
||||
/// [`provide_meta_context`].
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct MetaContext {
|
||||
/// Metadata associated with the `<html>` element
|
||||
|
@ -186,8 +186,8 @@ impl MetaTagsContext {
|
|||
}
|
||||
}
|
||||
|
||||
/// Provides a [MetaContext], if there is not already one provided. This ensures that you can provide it
|
||||
/// at the highest possible level, without overwriting a [MetaContext] that has already been provided
|
||||
/// Provides a [`MetaContext`], if there is not already one provided. This ensures that you can provide it
|
||||
/// at the highest possible level, without overwriting a [`MetaContext`] that has already been provided
|
||||
/// (for example, by a server-rendering integration.)
|
||||
pub fn provide_meta_context() {
|
||||
if use_context::<MetaContext>().is_none() {
|
||||
|
@ -195,14 +195,14 @@ pub fn provide_meta_context() {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the current [MetaContext].
|
||||
/// Returns the current [`MetaContext`].
|
||||
///
|
||||
/// If there is no [MetaContext] in this or any parent scope, this will
|
||||
/// create a new [MetaContext] and provide it to the current scope.
|
||||
/// If there is no [`MetaContext`] in this or any parent scope, this will
|
||||
/// create a new [`MetaContext`] and provide it to the current scope.
|
||||
///
|
||||
/// Note that this may cause confusing behavior, e.g., if multiple nested routes independently
|
||||
/// 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.
|
||||
/// 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() -> MetaContext {
|
||||
#[cfg(debug_assertions)]
|
||||
feature_warning();
|
||||
|
@ -225,7 +225,7 @@ pub fn use_head() -> MetaContext {
|
|||
}
|
||||
|
||||
impl MetaContext {
|
||||
/// Creates an empty [MetaContext].
|
||||
/// Creates an empty [`MetaContext`].
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::use_head;
|
||||
use leptos::{nonce::use_nonce, *};
|
||||
|
||||
/// Injects an [HTMLLinkElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement) into the document
|
||||
/// Injects an [`HTMLLinkElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement) into the document
|
||||
/// head, accepting any of the valid attributes for that tag.
|
||||
///
|
||||
/// ```
|
||||
/// use leptos::*;
|
||||
/// use leptos_meta::*;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{use_head, TextProp};
|
||||
use leptos::{component, IntoView};
|
||||
|
||||
/// Injects an [HTMLMetaElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMetaElement) into the document
|
||||
/// Injects an [`HTMLMetaElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMetaElement) into the document
|
||||
/// head to set metadata
|
||||
///
|
||||
/// ```
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::use_head;
|
||||
use leptos::{nonce::use_nonce, *};
|
||||
|
||||
/// Injects an [HTMLScriptElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement) into the document
|
||||
/// Injects an [`HTMLScriptElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement) into the document
|
||||
/// head, accepting any of the valid attributes for that tag.
|
||||
///
|
||||
/// ```
|
||||
/// use leptos::*;
|
||||
/// use leptos_meta::*;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::use_head;
|
||||
use leptos::{nonce::use_nonce, *};
|
||||
|
||||
/// Injects an [HTMLStyleElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement) into the document
|
||||
/// Injects an [`HTMLStyleElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement) into the document
|
||||
/// head, accepting any of the valid attributes for that tag.
|
||||
///
|
||||
/// ```
|
||||
/// use leptos::*;
|
||||
/// use leptos_meta::*;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::Link;
|
||||
use leptos::*;
|
||||
|
||||
/// Injects an [HTMLLinkElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement) into the document
|
||||
/// Injects an [`HTMLLinkElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement) into the document
|
||||
/// head that loads a stylesheet from the URL given by the `href` property.
|
||||
///
|
||||
/// ```
|
||||
|
|
|
@ -48,7 +48,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// A component to set the document’s title by creating an [HTMLTitleElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTitleElement).
|
||||
/// A component to set the document’s title by creating an [`HTMLTitleElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTitleElement).
|
||||
///
|
||||
/// The `title` and `formatter` can be set independently of one another. For example, you can create a root-level
|
||||
/// `<Title formatter=.../>` that will wrap each of the text values of `<Title/>` components created lower in the tree.
|
||||
|
|
Loading…
Reference in a new issue