Current section

Files

Jump to
inlay src inlay.erl
Raw

src/inlay.erl

-module(inlay).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/inlay.gleam").
-export([default_config/0, detect_with/2, detect/1, render/1, embed/1, bluesky_config/0, twitter_config/0, tiktok_config/0, instagram_config/0, youtube_config/0, vimeo_config/0, spotify_config/0, twitch_config/1, openstreetmap_config/0, ted_config/0, soundcloud_config/0, mastodon_config/1, pixelfed_config/2, pixelfed_full/2, pixelfed_compact/0, apple_music_config/0, new/0, youtube_no_cookie/2, vimeo_dnt/2, bluesky_resolver/2, youtube_aspect_ratio/2, vimeo_aspect_ratio/2, twitch_aspect_ratio/2, ted_aspect_ratio/2, openstreetmap_aspect_ratio/2, spotify_width/2, spotify_height/2, spotify_track_height/2, soundcloud_width/2, soundcloud_height/2, apple_music_width/2, apple_music_height/2, apple_music_song_height/2, mastodon_width/2, mastodon_height/2, pixelfed_width/2, pixelfed_height/2, bluesky_height/2, twitter_height/2, tiktok_height/2, instagram_height/2, youtube/2, no_youtube/1, vimeo/2, no_vimeo/1, spotify/2, no_spotify/1, twitter/2, no_twitter/1, tiktok/2, no_tiktok/1, bluesky/2, no_bluesky/1, instagram/2, no_instagram/1, twitch/2, no_twitch/1, openstreetmap/2, no_openstreetmap/1, ted/2, no_ted/1, soundcloud/2, no_soundcloud/1, mastodon/2, no_mastodon/1, pixelfed/2, no_pixelfed/1, apple_music/2, no_apple_music/1, render_with/2, embed_with/2, a_component_with/2, a_component/1, a_component_default/0, configure/1, register/0, embed_element/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Render embedded previews for social media links as Lustre HTML elements.\n"
"\n"
" Use `detect` to parse a URL into an `Embed`, `render` to turn it into\n"
" HTML, or `embed` to do both in one step. All functions have `_with`\n"
" variants that accept a custom `Config`.\n"
"\n"
" ## Example\n"
"\n"
" ```gleam\n"
" case inlay.embed(\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\") {\n"
" Some(element) -> element\n"
" None -> html.text(\"Not an embeddable link\")\n"
" }\n"
" ```\n"
"\n"
" ## Configuration\n"
"\n"
" ```gleam\n"
" let config =\n"
" inlay.new()\n"
" |> inlay.youtube(inlay.youtube_config())\n"
" |> inlay.mastodon(inlay.mastodon_config([\"mastodon.social\"]))\n"
" ```\n"
).
-file("src/inlay.gleam", 194).
?DOC(
" Create a configuration with commonly used providers enabled.\n"
"\n"
" Enabled: YouTube, Vimeo, Spotify, Twitter/X, TikTok, Bluesky,\n"
" Instagram, OpenStreetMap, TED, SoundCloud, Apple Music.\n"
"\n"
" Disabled (require explicit setup): Twitch, Mastodon, Pixelfed.\n"
).
-spec default_config() -> inlay@embed:config().
default_config() ->
inlay@embed:default_config().
-file("src/inlay.gleam", 529).
?DOC(" Detect an embeddable link from a URL using a custom configuration.\n").
-spec detect_with(binary(), inlay@embed:config()) -> gleam@option:option(inlay@embed:embed()).
detect_with(Url, Config) ->
inlay@detect:detect_with(Url, Config).
-file("src/inlay.gleam", 524).
?DOC(" Detect an embeddable link from a URL using the default configuration.\n").
-spec detect(binary()) -> gleam@option:option(inlay@embed:embed()).
detect(Url) ->
detect_with(Url, default_config()).
-file("src/inlay.gleam", 534).
?DOC(" Render a detected embed as HTML using the default configuration.\n").
-spec render(inlay@embed:embed()) -> lustre@vdom@vnode:element(any()).
render(Embed) ->
inlay@detect:render_with(Embed, default_config()).
-file("src/inlay.gleam", 544).
?DOC(" Detect and render in one step using the default configuration.\n").
-spec embed(binary()) -> gleam@option:option(lustre@vdom@vnode:element(any())).
embed(Url) ->
case detect(Url) of
{some, E} ->
{some, render(E)};
none ->
none
end.
-file("src/inlay.gleam", 100).
?DOC(" Create a default Bluesky configuration with no handle resolver.\n").
-spec bluesky_config() -> inlay@embed:bluesky_config().
bluesky_config() ->
inlay@embed:bluesky_config().
-file("src/inlay.gleam", 105).
?DOC(" Create a default Twitter/X configuration.\n").
-spec twitter_config() -> inlay@embed:twitter_config().
twitter_config() ->
inlay@embed:twitter_config().
-file("src/inlay.gleam", 110).
?DOC(" Create a default TikTok configuration.\n").
-spec tiktok_config() -> inlay@embed:tik_tok_config().
tiktok_config() ->
inlay@embed:tiktok_config().
-file("src/inlay.gleam", 115).
?DOC(" Create a default Instagram configuration.\n").
-spec instagram_config() -> inlay@embed:instagram_config().
instagram_config() ->
inlay@embed:instagram_config().
-file("src/inlay.gleam", 120).
?DOC(" Create a default YouTube configuration with privacy-enhanced mode enabled.\n").
-spec youtube_config() -> inlay@embed:youtube_config().
youtube_config() ->
inlay@embed:youtube_config().
-file("src/inlay.gleam", 125).
?DOC(" Create a default Vimeo configuration with Do Not Track enabled.\n").
-spec vimeo_config() -> inlay@embed:vimeo_config().
vimeo_config() ->
inlay@embed:vimeo_config().
-file("src/inlay.gleam", 130).
?DOC(" Create a default Spotify configuration.\n").
-spec spotify_config() -> inlay@embed:spotify_config().
spotify_config() ->
inlay@embed:spotify_config().
-file("src/inlay.gleam", 136).
?DOC(
" Create a Twitch configuration. The `parent` domain is required by\n"
" Twitch's embed API.\n"
).
-spec twitch_config(binary()) -> inlay@embed:twitch_config().
twitch_config(Parent) ->
inlay@embed:twitch_config(Parent).
-file("src/inlay.gleam", 141).
?DOC(" Create a default OpenStreetMap configuration.\n").
-spec openstreetmap_config() -> inlay@embed:open_street_map_config().
openstreetmap_config() ->
inlay@embed:openstreetmap_config().
-file("src/inlay.gleam", 146).
?DOC(" Create a default TED configuration.\n").
-spec ted_config() -> inlay@embed:ted_config().
ted_config() ->
inlay@embed:ted_config().
-file("src/inlay.gleam", 151).
?DOC(" Create a default SoundCloud configuration.\n").
-spec soundcloud_config() -> inlay@embed:sound_cloud_config().
soundcloud_config() ->
inlay@embed:soundcloud_config().
-file("src/inlay.gleam", 157).
?DOC(
" Create a Mastodon configuration. Only posts from the listed `servers`\n"
" will be detected.\n"
).
-spec mastodon_config(list(binary())) -> inlay@embed:mastodon_config().
mastodon_config(Servers) ->
inlay@embed:mastodon_config(Servers).
-file("src/inlay.gleam", 163).
?DOC(
" Create a Pixelfed configuration. Only posts from the listed `servers`\n"
" will be detected.\n"
).
-spec pixelfed_config(list(binary()), inlay@embed:pixelfed_layout()) -> inlay@embed:pixelfed_config().
pixelfed_config(Servers, Layout) ->
inlay@embed:pixelfed_config(Servers, Layout).
-file("src/inlay.gleam", 171).
?DOC(" Pixelfed embed layout that shows the post with optional caption and likes.\n").
-spec pixelfed_full(boolean(), boolean()) -> inlay@embed:pixelfed_layout().
pixelfed_full(Caption, Likes) ->
{full, Caption, Likes}.
-file("src/inlay.gleam", 179).
?DOC(" Pixelfed embed layout that shows a compact view of the post.\n").
-spec pixelfed_compact() -> inlay@embed:pixelfed_layout().
pixelfed_compact() ->
compact.
-file("src/inlay.gleam", 184).
?DOC(" Create a default Apple Music configuration.\n").
-spec apple_music_config() -> inlay@embed:apple_music_config().
apple_music_config() ->
inlay@embed:apple_music_config().
-file("src/inlay.gleam", 200).
?DOC(
" Create a configuration with all providers disabled.\n"
" Enable providers selectively with the builder functions.\n"
).
-spec new() -> inlay@embed:config().
new() ->
inlay@embed:new().
-file("src/inlay.gleam", 206).
?DOC(
" Set whether YouTube embeds use the privacy-enhanced `youtube-nocookie.com`\n"
" domain. Enabled by default.\n"
).
-spec youtube_no_cookie(inlay@embed:youtube_config(), boolean()) -> inlay@embed:youtube_config().
youtube_no_cookie(Config, No_cookie) ->
{youtube_config, No_cookie, erlang:element(3, Config)}.
-file("src/inlay.gleam", 215).
?DOC(
" Set whether Vimeo embeds include the Do Not Track flag.\n"
" Enabled by default.\n"
).
-spec vimeo_dnt(inlay@embed:vimeo_config(), boolean()) -> inlay@embed:vimeo_config().
vimeo_dnt(Config, Dnt) ->
{vimeo_config, Dnt, erlang:element(3, Config)}.
-file("src/inlay.gleam", 221).
?DOC(
" Set a function that resolves a Bluesky handle (e.g. `\"user.bsky.social\"`)\n"
" to a DID. When provided, embeds render with richer Bluesky markup.\n"
).
-spec bluesky_resolver(
inlay@embed:bluesky_config(),
fun((binary()) -> {ok, binary()} | {error, nil})
) -> inlay@embed:bluesky_config().
bluesky_resolver(Config, Resolve) ->
{bluesky_config, {some, Resolve}, erlang:element(3, Config)}.
-file("src/inlay.gleam", 229).
?DOC(" Set the CSS aspect ratio (e.g. `\"56.25%\"`) for responsive YouTube embeds.\n").
-spec youtube_aspect_ratio(inlay@embed:youtube_config(), binary()) -> inlay@embed:youtube_config().
youtube_aspect_ratio(Config, Aspect_ratio) ->
{youtube_config, erlang:element(2, Config), {some, Aspect_ratio}}.
-file("src/inlay.gleam", 237).
?DOC(" Set the CSS aspect ratio (e.g. `\"56.25%\"`) for responsive Vimeo embeds.\n").
-spec vimeo_aspect_ratio(inlay@embed:vimeo_config(), binary()) -> inlay@embed:vimeo_config().
vimeo_aspect_ratio(Config, Aspect_ratio) ->
{vimeo_config, erlang:element(2, Config), {some, Aspect_ratio}}.
-file("src/inlay.gleam", 245).
?DOC(" Set the CSS aspect ratio (e.g. `\"56.25%\"`) for responsive Twitch embeds.\n").
-spec twitch_aspect_ratio(inlay@embed:twitch_config(), binary()) -> inlay@embed:twitch_config().
twitch_aspect_ratio(Config, Aspect_ratio) ->
{twitch_config, erlang:element(2, Config), {some, Aspect_ratio}}.
-file("src/inlay.gleam", 253).
?DOC(" Set the CSS aspect ratio (e.g. `\"56.25%\"`) for responsive TED embeds.\n").
-spec ted_aspect_ratio(inlay@embed:ted_config(), binary()) -> inlay@embed:ted_config().
ted_aspect_ratio(Config, Aspect_ratio) ->
{ted_config, _} = Config,
{ted_config, {some, Aspect_ratio}}.
-file("src/inlay.gleam", 260).
?DOC(
" Set the CSS aspect ratio (e.g. `\"56.25%\"`) for responsive OpenStreetMap\n"
" embeds.\n"
).
-spec openstreetmap_aspect_ratio(inlay@embed:open_street_map_config(), binary()) -> inlay@embed:open_street_map_config().
openstreetmap_aspect_ratio(Config, Aspect_ratio) ->
{open_street_map_config, _} = Config,
{open_street_map_config, {some, Aspect_ratio}}.
-file("src/inlay.gleam", 269).
?DOC(" Set the Spotify embed width in pixels.\n").
-spec spotify_width(inlay@embed:spotify_config(), integer()) -> inlay@embed:spotify_config().
spotify_width(Config, Width) ->
{spotify_config,
{some, Width},
erlang:element(3, Config),
erlang:element(4, Config)}.
-file("src/inlay.gleam", 275).
?DOC(
" Set the Spotify embed height in pixels for albums, playlists, artists,\n"
" episodes, and shows.\n"
).
-spec spotify_height(inlay@embed:spotify_config(), integer()) -> inlay@embed:spotify_config().
spotify_height(Config, Height) ->
{spotify_config,
erlang:element(2, Config),
{some, Height},
erlang:element(4, Config)}.
-file("src/inlay.gleam", 280).
?DOC(" Set the Spotify embed height in pixels for individual tracks.\n").
-spec spotify_track_height(inlay@embed:spotify_config(), integer()) -> inlay@embed:spotify_config().
spotify_track_height(Config, Track_height) ->
{spotify_config,
erlang:element(2, Config),
erlang:element(3, Config),
{some, Track_height}}.
-file("src/inlay.gleam", 288).
?DOC(" Set the SoundCloud embed width in pixels.\n").
-spec soundcloud_width(inlay@embed:sound_cloud_config(), integer()) -> inlay@embed:sound_cloud_config().
soundcloud_width(Config, Width) ->
{sound_cloud_config, {some, Width}, erlang:element(3, Config)}.
-file("src/inlay.gleam", 296).
?DOC(" Set the SoundCloud embed height in pixels.\n").
-spec soundcloud_height(inlay@embed:sound_cloud_config(), integer()) -> inlay@embed:sound_cloud_config().
soundcloud_height(Config, Height) ->
{sound_cloud_config, erlang:element(2, Config), {some, Height}}.
-file("src/inlay.gleam", 304).
?DOC(" Set the Apple Music embed maximum width in pixels.\n").
-spec apple_music_width(inlay@embed:apple_music_config(), integer()) -> inlay@embed:apple_music_config().
apple_music_width(Config, Width) ->
{apple_music_config,
{some, Width},
erlang:element(3, Config),
erlang:element(4, Config)}.
-file("src/inlay.gleam", 313).
?DOC(
" Set the Apple Music embed height in pixels for albums, artists, playlists,\n"
" and music videos.\n"
).
-spec apple_music_height(inlay@embed:apple_music_config(), integer()) -> inlay@embed:apple_music_config().
apple_music_height(Config, Height) ->
{apple_music_config,
erlang:element(2, Config),
{some, Height},
erlang:element(4, Config)}.
-file("src/inlay.gleam", 321).
?DOC(" Set the Apple Music embed height in pixels for individual songs.\n").
-spec apple_music_song_height(inlay@embed:apple_music_config(), integer()) -> inlay@embed:apple_music_config().
apple_music_song_height(Config, Song_height) ->
{apple_music_config,
erlang:element(2, Config),
erlang:element(3, Config),
{some, Song_height}}.
-file("src/inlay.gleam", 329).
?DOC(" Set the Mastodon static embed width in pixels.\n").
-spec mastodon_width(inlay@embed:mastodon_config(), integer()) -> inlay@embed:mastodon_config().
mastodon_width(Config, Width) ->
{mastodon_config,
erlang:element(2, Config),
{some, Width},
erlang:element(4, Config)}.
-file("src/inlay.gleam", 334).
?DOC(" Set the initial Mastodon component-path iframe height in pixels.\n").
-spec mastodon_height(inlay@embed:mastodon_config(), integer()) -> inlay@embed:mastodon_config().
mastodon_height(Config, Height) ->
{mastodon_config,
erlang:element(2, Config),
erlang:element(3, Config),
{some, Height}}.
-file("src/inlay.gleam", 339).
?DOC(" Set the Pixelfed static embed width in pixels.\n").
-spec pixelfed_width(inlay@embed:pixelfed_config(), integer()) -> inlay@embed:pixelfed_config().
pixelfed_width(Config, Width) ->
{pixelfed_config,
erlang:element(2, Config),
erlang:element(3, Config),
{some, Width},
erlang:element(5, Config)}.
-file("src/inlay.gleam", 344).
?DOC(" Set the initial Pixelfed component-path iframe height in pixels.\n").
-spec pixelfed_height(inlay@embed:pixelfed_config(), integer()) -> inlay@embed:pixelfed_config().
pixelfed_height(Config, Height) ->
{pixelfed_config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
{some, Height}}.
-file("src/inlay.gleam", 349).
?DOC(" Set the initial Bluesky component-path iframe height in pixels.\n").
-spec bluesky_height(inlay@embed:bluesky_config(), integer()) -> inlay@embed:bluesky_config().
bluesky_height(Config, Height) ->
{bluesky_config, erlang:element(2, Config), {some, Height}}.
-file("src/inlay.gleam", 354).
?DOC(" Set the initial Twitter/X component-path iframe height in pixels.\n").
-spec twitter_height(inlay@embed:twitter_config(), integer()) -> inlay@embed:twitter_config().
twitter_height(Config, Height) ->
{twitter_config, _} = Config,
{twitter_config, {some, Height}}.
-file("src/inlay.gleam", 360).
?DOC(" Set the initial TikTok component-path iframe height in pixels.\n").
-spec tiktok_height(inlay@embed:tik_tok_config(), integer()) -> inlay@embed:tik_tok_config().
tiktok_height(Config, Height) ->
{tik_tok_config, _} = Config,
{tik_tok_config, {some, Height}}.
-file("src/inlay.gleam", 366).
?DOC(" Set the initial Instagram component-path iframe height in pixels.\n").
-spec instagram_height(inlay@embed:instagram_config(), integer()) -> inlay@embed:instagram_config().
instagram_height(Config, Height) ->
{instagram_config, _} = Config,
{instagram_config, {some, Height}}.
-file("src/inlay.gleam", 375).
?DOC(" Enable YouTube embeds with the given configuration.\n").
-spec youtube(inlay@embed:config(), inlay@embed:youtube_config()) -> inlay@embed:config().
youtube(Config, Youtube_config) ->
{config,
{some, Youtube_config},
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 380).
?DOC(" Disable YouTube embeds.\n").
-spec no_youtube(inlay@embed:config()) -> inlay@embed:config().
no_youtube(Config) ->
{config,
none,
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 385).
?DOC(" Enable Vimeo embeds with the given configuration.\n").
-spec vimeo(inlay@embed:config(), inlay@embed:vimeo_config()) -> inlay@embed:config().
vimeo(Config, Vimeo_config) ->
{config,
erlang:element(2, Config),
{some, Vimeo_config},
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 390).
?DOC(" Disable Vimeo embeds.\n").
-spec no_vimeo(inlay@embed:config()) -> inlay@embed:config().
no_vimeo(Config) ->
{config,
erlang:element(2, Config),
none,
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 395).
?DOC(" Enable Spotify embeds with the given configuration.\n").
-spec spotify(inlay@embed:config(), inlay@embed:spotify_config()) -> inlay@embed:config().
spotify(Config, Spotify_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
{some, Spotify_config},
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 400).
?DOC(" Disable Spotify embeds.\n").
-spec no_spotify(inlay@embed:config()) -> inlay@embed:config().
no_spotify(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
none,
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 405).
?DOC(" Enable Twitter/X embeds with the given configuration.\n").
-spec twitter(inlay@embed:config(), inlay@embed:twitter_config()) -> inlay@embed:config().
twitter(Config, Twitter_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
{some, Twitter_config},
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 410).
?DOC(" Disable Twitter/X embeds.\n").
-spec no_twitter(inlay@embed:config()) -> inlay@embed:config().
no_twitter(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
none,
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 415).
?DOC(" Enable TikTok embeds with the given configuration.\n").
-spec tiktok(inlay@embed:config(), inlay@embed:tik_tok_config()) -> inlay@embed:config().
tiktok(Config, Tiktok_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
{some, Tiktok_config},
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 420).
?DOC(" Disable TikTok embeds.\n").
-spec no_tiktok(inlay@embed:config()) -> inlay@embed:config().
no_tiktok(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
none,
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 425).
?DOC(" Enable Bluesky embeds with the given configuration.\n").
-spec bluesky(inlay@embed:config(), inlay@embed:bluesky_config()) -> inlay@embed:config().
bluesky(Config, Bluesky_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
{some, Bluesky_config},
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 430).
?DOC(" Disable Bluesky embeds.\n").
-spec no_bluesky(inlay@embed:config()) -> inlay@embed:config().
no_bluesky(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
none,
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 435).
?DOC(" Enable Instagram embeds with the given configuration.\n").
-spec instagram(inlay@embed:config(), inlay@embed:instagram_config()) -> inlay@embed:config().
instagram(Config, Instagram_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
{some, Instagram_config},
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 440).
?DOC(" Disable Instagram embeds.\n").
-spec no_instagram(inlay@embed:config()) -> inlay@embed:config().
no_instagram(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
none,
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 445).
?DOC(" Enable Twitch embeds with the given configuration.\n").
-spec twitch(inlay@embed:config(), inlay@embed:twitch_config()) -> inlay@embed:config().
twitch(Config, Twitch_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
{some, Twitch_config},
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 450).
?DOC(" Disable Twitch embeds.\n").
-spec no_twitch(inlay@embed:config()) -> inlay@embed:config().
no_twitch(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
none,
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 455).
?DOC(" Enable OpenStreetMap embeds with the given configuration.\n").
-spec openstreetmap(inlay@embed:config(), inlay@embed:open_street_map_config()) -> inlay@embed:config().
openstreetmap(Config, Osm_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
{some, Osm_config},
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 463).
?DOC(" Disable OpenStreetMap embeds.\n").
-spec no_openstreetmap(inlay@embed:config()) -> inlay@embed:config().
no_openstreetmap(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
none,
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 468).
?DOC(" Enable TED talk embeds with the given configuration.\n").
-spec ted(inlay@embed:config(), inlay@embed:ted_config()) -> inlay@embed:config().
ted(Config, Ted_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
{some, Ted_config},
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 473).
?DOC(" Disable TED talk embeds.\n").
-spec no_ted(inlay@embed:config()) -> inlay@embed:config().
no_ted(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
none,
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 478).
?DOC(" Enable SoundCloud embeds with the given configuration.\n").
-spec soundcloud(inlay@embed:config(), inlay@embed:sound_cloud_config()) -> inlay@embed:config().
soundcloud(Config, Soundcloud_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
{some, Soundcloud_config},
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 486).
?DOC(" Disable SoundCloud embeds.\n").
-spec no_soundcloud(inlay@embed:config()) -> inlay@embed:config().
no_soundcloud(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
none,
erlang:element(13, Config),
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 491).
?DOC(" Enable Mastodon embeds with the given configuration.\n").
-spec mastodon(inlay@embed:config(), inlay@embed:mastodon_config()) -> inlay@embed:config().
mastodon(Config, Mastodon_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
{some, Mastodon_config},
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 496).
?DOC(" Disable Mastodon embeds.\n").
-spec no_mastodon(inlay@embed:config()) -> inlay@embed:config().
no_mastodon(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
none,
erlang:element(14, Config),
erlang:element(15, Config)}.
-file("src/inlay.gleam", 501).
?DOC(" Enable Pixelfed embeds with the given configuration.\n").
-spec pixelfed(inlay@embed:config(), inlay@embed:pixelfed_config()) -> inlay@embed:config().
pixelfed(Config, Pixelfed_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
{some, Pixelfed_config},
erlang:element(15, Config)}.
-file("src/inlay.gleam", 506).
?DOC(" Disable Pixelfed embeds.\n").
-spec no_pixelfed(inlay@embed:config()) -> inlay@embed:config().
no_pixelfed(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
none,
erlang:element(15, Config)}.
-file("src/inlay.gleam", 511).
?DOC(" Enable Apple Music embeds with the given configuration.\n").
-spec apple_music(inlay@embed:config(), inlay@embed:apple_music_config()) -> inlay@embed:config().
apple_music(Config, Apple_music_config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
{some, Apple_music_config}}.
-file("src/inlay.gleam", 519).
?DOC(" Disable Apple Music embeds.\n").
-spec no_apple_music(inlay@embed:config()) -> inlay@embed:config().
no_apple_music(Config) ->
{config,
erlang:element(2, Config),
erlang:element(3, Config),
erlang:element(4, Config),
erlang:element(5, Config),
erlang:element(6, Config),
erlang:element(7, Config),
erlang:element(8, Config),
erlang:element(9, Config),
erlang:element(10, Config),
erlang:element(11, Config),
erlang:element(12, Config),
erlang:element(13, Config),
erlang:element(14, Config),
none}.
-file("src/inlay.gleam", 539).
?DOC(" Render a detected embed as HTML using a custom configuration.\n").
-spec render_with(inlay@embed:embed(), inlay@embed:config()) -> lustre@vdom@vnode:element(any()).
render_with(Embed, Config) ->
inlay@detect:render_with(Embed, Config).
-file("src/inlay.gleam", 552).
?DOC(" Detect and render in one step using a custom configuration.\n").
-spec embed_with(binary(), inlay@embed:config()) -> gleam@option:option(lustre@vdom@vnode:element(any())).
embed_with(Url, Config) ->
case detect_with(Url, Config) of
{some, E} ->
{some, render_with(E, Config)};
none ->
none
end.
-file("src/inlay.gleam", 571).
?DOC(" Create an anchor component with a custom configuration.\n").
-spec a_component_with(
inlay@embed:config(),
fun((gleam@dict:dict(binary(), binary()), binary(), gleam@option:option(binary()), list(lustre@vdom@vnode:element(SUU))) -> lustre@vdom@vnode:element(SUU))
) -> fun((gleam@dict:dict(binary(), binary()), binary(), gleam@option:option(binary()), list(lustre@vdom@vnode:element(SUU))) -> lustre@vdom@vnode:element(SUU)).
a_component_with(Config, Fallback) ->
fun(Attributes, Href, Title, Children) -> case embed_with(Href, Config) of
{some, El} ->
El;
none ->
Fallback(Attributes, Href, Title, Children)
end end.
-file("src/inlay.gleam", 562).
?DOC(
" Create an anchor component that renders embeds for recognized URLs\n"
" and delegates to `fallback` for unrecognized ones.\n"
" Uses the default configuration.\n"
).
-spec a_component(
fun((gleam@dict:dict(binary(), binary()), binary(), gleam@option:option(binary()), list(lustre@vdom@vnode:element(SUH))) -> lustre@vdom@vnode:element(SUH))
) -> fun((gleam@dict:dict(binary(), binary()), binary(), gleam@option:option(binary()), list(lustre@vdom@vnode:element(SUH))) -> lustre@vdom@vnode:element(SUH)).
a_component(Fallback) ->
a_component_with(default_config(), Fallback).
-file("src/inlay.gleam", 601).
-spec default_fallback(
gleam@dict:dict(binary(), binary()),
binary(),
gleam@option:option(binary()),
list(lustre@vdom@vnode:element(SVO))
) -> lustre@vdom@vnode:element(SVO).
default_fallback(_, Href, Title, Children) ->
Attrs = [lustre@attribute:href(Href)],
Attrs@1 = case Title of
{some, T} ->
[lustre@attribute:title(T) | Attrs];
none ->
Attrs
end,
lustre@element@html:a(Attrs@1, Children).
-file("src/inlay.gleam", 592).
?DOC(
" Create an anchor component using the default configuration and\n"
" a standard `<a>` tag fallback.\n"
).
-spec a_component_default() -> fun((gleam@dict:dict(binary(), binary()), binary(), gleam@option:option(binary()), list(lustre@vdom@vnode:element(SVH))) -> lustre@vdom@vnode:element(SVH)).
a_component_default() ->
a_component(fun default_fallback/4).
-file("src/inlay.gleam", 621).
?DOC(
" Register the `<inlay-embed url=\"…\">` custom element with the given base\n"
" configuration. Call this once from a browser `main`, then use the tag in your\n"
" markup or [`embed_element`](#embed_element) in a Lustre view.\n"
"\n"
" Registration is browser-only; on other targets it returns\n"
" `lustre.NotABrowser`.\n"
).
-spec configure(inlay@embed:config()) -> {ok, nil} | {error, lustre:error()}.
configure(Config) ->
inlay@component:configure(Config).
-file("src/inlay.gleam", 626).
?DOC(" Register `<inlay-embed>` with the default configuration.\n").
-spec register() -> {ok, nil} | {error, lustre:error()}.
register() ->
inlay@component:register().
-file("src/inlay.gleam", 631).
?DOC(" Render the `<inlay-embed>` custom-element tag with the given attributes.\n").
-spec embed_element(list(lustre@vdom@vattr:attribute(SVW))) -> lustre@vdom@vnode:element(SVW).
embed_element(Attributes) ->
inlay@component:embed_element(Attributes).