Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(leptos_meta): enhance links in docs #1783

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
//! ```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -186,23 +186,23 @@ 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() {
provide_context(MetaContext::new());
}
}

/// 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();
Expand All @@ -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()
}
Expand Down
3 changes: 2 additions & 1 deletion meta/src/link.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion meta/src/meta_tags.rs
Original file line number Diff line number Diff line change
@@ -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
///
/// ```
Expand Down
3 changes: 2 additions & 1 deletion meta/src/script.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
3 changes: 2 additions & 1 deletion meta/src/style.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion meta/src/stylesheet.rs
Original file line number Diff line number Diff line change
@@ -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.
///
/// ```
Expand Down
2 changes: 1 addition & 1 deletion meta/src/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading