From cde776a9c037eb6e9b99875bbc360738919acdda Mon Sep 17 00:00:00 2001 From: Fangdun Tsai Date: Mon, 25 Sep 2023 08:21:11 +0800 Subject: [PATCH] chore(leptos_meta): enhance links in docs --- meta/src/lib.rs | 24 ++++++++++++------------ meta/src/link.rs | 3 ++- meta/src/meta_tags.rs | 2 +- meta/src/script.rs | 3 ++- meta/src/style.rs | 3 ++- meta/src/stylesheet.rs | 2 +- meta/src/title.rs | 2 +- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/meta/src/lib.rs b/meta/src/lib.rs index 883e16c0d7..7d1dd0478f 100644 --- a/meta/src/lib.rs +++ b/meta/src/lib.rs @@ -4,10 +4,10 @@ //! # Leptos Meta //! //! Leptos Meta allows you to modify content in a document’s `` 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 `` 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 `` 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::().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() } diff --git a/meta/src/link.rs b/meta/src/link.rs index 3e0d14491f..3fa6673c08 100644 --- a/meta/src/link.rs +++ b/meta/src/link.rs @@ -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::*; diff --git a/meta/src/meta_tags.rs b/meta/src/meta_tags.rs index ef90fb981a..214b8db2d2 100644 --- a/meta/src/meta_tags.rs +++ b/meta/src/meta_tags.rs @@ -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 /// /// ``` diff --git a/meta/src/script.rs b/meta/src/script.rs index e135a31854..aaaa4abf2d 100644 --- a/meta/src/script.rs +++ b/meta/src/script.rs @@ -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::*; diff --git a/meta/src/style.rs b/meta/src/style.rs index 3b1a3a185a..09981f7a00 100644 --- a/meta/src/style.rs +++ b/meta/src/style.rs @@ -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::*; diff --git a/meta/src/stylesheet.rs b/meta/src/stylesheet.rs index 916efb160d..50439bf16c 100644 --- a/meta/src/stylesheet.rs +++ b/meta/src/stylesheet.rs @@ -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. /// /// ``` diff --git a/meta/src/title.rs b/meta/src/title.rs index a4bb18819a..d2d41a4b6f 100644 --- a/meta/src/title.rs +++ b/meta/src/title.rs @@ -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 /// `` that will wrap each of the text values of `<Title/>` components created lower in the tree.