Skip to contents

This function takes a Mastodon toot identifier, a Mastodon instance, and a Mastodon username to create a fragment that can be embedded in a Markdown file.

Usage

create_embed_fragment(
  x,
  tokenname = getOption("quartodon_tokenname", "RTOOT_DEFAULT_TOKEN"),
  instance = getOption("quartodon_instance", NULL),
  username = getOption("quartodon_username", FALSE)
)

Arguments

x

A Mastodon toot id

tokenname

The name of the environment variable containing the rtoot token produced with rtoot::auth_setup() and rtoot::convert_token_to_envvar().

instance

A Mastodon instance

username

A Mastodon username

Value

A character vector.

Examples

cat(
  quartodon::create_embed_fragment(
    "109445312966461935",
    "mastodon.nl",
    "matherion"
  )
);
#> Warning: 
#> 
#> To create this embed fragment, I need to know your username. Store it in an option named 'quartodon_username' using the 'option()' function. For example:
#> 
#>   option(quartodon_username = 'matherion');
#> 
#> Alternatively, you can also rerun this function and specify the username yourself:
#> 
#>   quartodon::create_embed_fragment(
#>     109445312966461935
#>     username = 'YOUR_USERNAME_HERE'
#>   );
#> 
#> For now, using 'YOUR_USERNAME_HERE' as username in the fragment I generate, so you will have to replace that manually yourself, sorry! (It occurs twice, don't forget to replace both.)
#> 
#> 
#> This is a Mastodon thread. [The original thread is available here](https://matherion/@YOUR_USERNAME_HERE/109445312966461935){.external target="_blank"}:
#> 
#> <iframe src="https://matherion/@YOUR_USERNAME_HERE/109445312966461935/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://matherion/embed.js" async="async"></script>
#>