Skip to main content

hyperlink

Function hyperlink 

Source
pub const fn hyperlink<'a, T: Display, U: Display>(
    content: T,
    url: U,
) -> Hyperlink<'a, T, U>
Expand description

Shows content as a link to url, with a title shown on hover if set (D-213).

Wrap the URL in <…> (hyperlink("docs", hide_link_embed(url))) to avoid an embed preview.

discord.js counterpart: hyperlink.

§Examples

use djs_formatters::hyperlink;

assert_eq!(
    hyperlink("the docs", "https://docs.rs").to_string(),
    "[the docs](https://docs.rs)"
);
assert_eq!(
    hyperlink("the docs", "https://docs.rs").title("Rust docs").to_string(),
    r#"[the docs](https://docs.rs "Rust docs")"#
);