inlay
Render embedded previews for social media links as Lustre HTML elements.
Use detect to parse a URL into an Embed, render to turn it into
HTML, or embed to do both in one step. All functions have _with
variants that accept a custom Config.
Example
case inlay.embed("https://www.youtube.com/watch?v=dQw4w9WgXcQ") {
Some(element) -> element
None -> html.text("Not an embeddable link")
}
Configuration
let config =
inlay.new()
|> inlay.youtube(inlay.youtube_config())
|> inlay.mastodon(inlay.mastodon_config(["mastodon.social"]))
Types
pub type AppleMusicConfig =
embed.AppleMusicConfig
pub type AppleMusicMediaType =
embed.AppleMusicMediaType
pub type BlueskyConfig =
embed.BlueskyConfig
Provider configuration. Create with default_config() or new(),
then customize with builder functions like youtube(), no_twitter().
pub type Config =
embed.Config
A detected embeddable link with provider-specific data. Match on variants to inspect or handle providers individually.
pub type Embed =
embed.Embed
pub type InstagramPostType =
embed.InstagramPostType
pub type MastodonConfig =
embed.MastodonConfig
pub type OpenStreetMapConfig =
embed.OpenStreetMapConfig
pub type PixelfedConfig =
embed.PixelfedConfig
pub type PixelfedLayout =
embed.PixelfedLayout
pub type SoundCloudConfig =
embed.SoundCloudConfig
pub type SpotifyConfig =
embed.SpotifyConfig
pub type SpotifyMediaType =
embed.SpotifyMediaType
pub type TedConfig =
embed.TedConfig
pub type TwitchConfig =
embed.TwitchConfig
pub type VimeoConfig =
embed.VimeoConfig
pub type YoutubeConfig =
embed.YoutubeConfig
Values
pub fn a_component(
fallback: fn(
String,
option.Option(String),
List(element.Element(msg)),
) -> element.Element(msg),
) -> fn(String, option.Option(String), List(element.Element(msg))) -> element.Element(
msg,
)
Create an anchor component that renders embeds for recognized URLs
and delegates to fallback for unrecognized ones.
Uses the default configuration.
pub fn a_component_default() -> fn(
String,
option.Option(String),
List(element.Element(msg)),
) -> element.Element(msg)
Create an anchor component using the default configuration and
a standard <a> tag fallback.
pub fn a_component_with(
config: embed.Config,
fallback: fn(
String,
option.Option(String),
List(element.Element(msg)),
) -> element.Element(msg),
) -> fn(String, option.Option(String), List(element.Element(msg))) -> element.Element(
msg,
)
Create an anchor component with a custom configuration.
pub fn apple_music(
config: embed.Config,
apple_music_config: embed.AppleMusicConfig,
) -> embed.Config
Enable Apple Music embeds with the given configuration.
pub fn apple_music_config() -> embed.AppleMusicConfig
Create a default Apple Music configuration.
pub fn bluesky(
config: embed.Config,
bluesky_config: embed.BlueskyConfig,
) -> embed.Config
Enable Bluesky embeds with the given configuration.
pub fn bluesky_config() -> embed.BlueskyConfig
Create a default Bluesky configuration with no handle resolver.
pub fn bluesky_resolver(
config: embed.BlueskyConfig,
resolve: fn(String) -> Result(String, Nil),
) -> embed.BlueskyConfig
Set a function that resolves a Bluesky handle (e.g. "user.bsky.social")
to a DID. When provided, embeds render with richer Bluesky markup.
pub fn default_config() -> embed.Config
Create a configuration with commonly used providers enabled.
Enabled: YouTube, Vimeo, Spotify, Twitter/X, TikTok, Bluesky, Instagram, OpenStreetMap, TED, SoundCloud, Apple Music.
Disabled (require explicit setup): Twitch, Mastodon, Pixelfed.
pub fn detect(url: String) -> option.Option(embed.Embed)
Detect an embeddable link from a URL using the default configuration.
pub fn detect_with(
url: String,
config: embed.Config,
) -> option.Option(embed.Embed)
Detect an embeddable link from a URL using a custom configuration.
pub fn embed(url: String) -> option.Option(element.Element(msg))
Detect and render in one step using the default configuration.
pub fn embed_with(
url: String,
config: embed.Config,
) -> option.Option(element.Element(msg))
Detect and render in one step using a custom configuration.
pub fn mastodon(
config: embed.Config,
mastodon_config: embed.MastodonConfig,
) -> embed.Config
Enable Mastodon embeds with the given configuration.
pub fn mastodon_config(
servers: List(String),
) -> embed.MastodonConfig
Create a Mastodon configuration. Only posts from the listed servers
will be detected.
pub fn new() -> embed.Config
Create a configuration with all providers disabled. Enable providers selectively with the builder functions.
pub fn no_apple_music(config: embed.Config) -> embed.Config
Disable Apple Music embeds.
pub fn no_instagram(config: embed.Config) -> embed.Config
Disable Instagram embeds.
pub fn no_openstreetmap(config: embed.Config) -> embed.Config
Disable OpenStreetMap embeds.
pub fn no_soundcloud(config: embed.Config) -> embed.Config
Disable SoundCloud embeds.
pub fn openstreetmap(
config: embed.Config,
osm_config: embed.OpenStreetMapConfig,
) -> embed.Config
Enable OpenStreetMap embeds with the given configuration.
pub fn openstreetmap_config() -> embed.OpenStreetMapConfig
Create a default OpenStreetMap configuration.
pub fn pixelfed(
config: embed.Config,
pixelfed_config: embed.PixelfedConfig,
) -> embed.Config
Enable Pixelfed embeds with the given configuration.
pub fn pixelfed_compact() -> embed.PixelfedLayout
Pixelfed embed layout that shows a compact view of the post.
pub fn pixelfed_config(
servers: List(String),
layout: embed.PixelfedLayout,
) -> embed.PixelfedConfig
Create a Pixelfed configuration. Only posts from the listed servers
will be detected.
pub fn pixelfed_full(
caption caption: Bool,
likes likes: Bool,
) -> embed.PixelfedLayout
Pixelfed embed layout that shows the post with optional caption and likes.
pub fn render(embed: embed.Embed) -> element.Element(msg)
Render a detected embed as HTML using the default configuration.
pub fn render_with(
embed: embed.Embed,
config: embed.Config,
) -> element.Element(msg)
Render a detected embed as HTML using a custom configuration.
pub fn soundcloud(
config: embed.Config,
soundcloud_config: embed.SoundCloudConfig,
) -> embed.Config
Enable SoundCloud embeds with the given configuration.
pub fn soundcloud_config() -> embed.SoundCloudConfig
Create a default SoundCloud configuration.
pub fn spotify(
config: embed.Config,
spotify_config: embed.SpotifyConfig,
) -> embed.Config
Enable Spotify embeds with the given configuration.
pub fn spotify_config() -> embed.SpotifyConfig
Create a default Spotify configuration.
pub fn ted(
config: embed.Config,
ted_config: embed.TedConfig,
) -> embed.Config
Enable TED talk embeds with the given configuration.
pub fn twitch(
config: embed.Config,
twitch_config: embed.TwitchConfig,
) -> embed.Config
Enable Twitch embeds with the given configuration.
pub fn twitch_config(parent: String) -> embed.TwitchConfig
Create a Twitch configuration. The parent domain is required by
Twitch’s embed API.
pub fn vimeo(
config: embed.Config,
vimeo_config: embed.VimeoConfig,
) -> embed.Config
Enable Vimeo embeds with the given configuration.
pub fn vimeo_config() -> embed.VimeoConfig
Create a default Vimeo configuration with Do Not Track enabled.
pub fn vimeo_dnt(
config: embed.VimeoConfig,
dnt: Bool,
) -> embed.VimeoConfig
Set whether Vimeo embeds include the Do Not Track flag. Enabled by default.
pub fn youtube(
config: embed.Config,
youtube_config: embed.YoutubeConfig,
) -> embed.Config
Enable YouTube embeds with the given configuration.
pub fn youtube_config() -> embed.YoutubeConfig
Create a default YouTube configuration with privacy-enhanced mode enabled.
pub fn youtube_no_cookie(
config: embed.YoutubeConfig,
no_cookie: Bool,
) -> embed.YoutubeConfig
Set whether YouTube embeds use the privacy-enhanced youtube-nocookie.com
domain. Enabled by default.