declanbyrd / eleventy-plugin-mastoarchive

Eleventy plugin to expose your Mastodon posts as a global data object.
https://www.npmjs.com/package/eleventy-plugin-mastoarchive
12 stars 1 forks source link

Custom emoji #3

Open EllyLoel opened 1 year ago

EllyLoel commented 1 year ago

Hey there, love the plugin, thanks for making it.

Currently custom emojis just show up as text e.g. :blob_cat_aww:

Would be great if the image url was returned or even better if the emoji shortcodes were transformed into <img> tags.

declanbyrd commented 1 year ago

Nice catch! The custom emoji data is included in the status, so this definitely feels achievable.

{
  "shortcode": "blobaww",
  "url": "https://files.mastodon.social/custom_emojis/images/000/011/739/original/blobaww.png",
  "static_url": "https://files.mastodon.social/custom_emojis/images/000/011/739/static/blobaww.png",
  "visible_in_picker": true,
  "category": "Blobs"
}

I'll need to see how the Mastodon UI decides the alt text. "blobaww" is somewhat descriptive but I have a feeling not all shortcodes are going to be suitable as alt text.

EllyLoel commented 1 year ago

It seems they just use the shortcode as the alt text from what I can tell. I agree though, that's not always going to be super descriptive, tricky issue.

declanbyrd commented 1 year ago

There is a Mastodon feature request asking for alt text for custom emojis but it's been around since 2018 and doesn't look like its a priority item in the backlog (https://github.com/mastodon/mastodon/issues/9269). If/when this gets implemented I would consider swapping custom emoji with images in the plugin so the post content can be rendered as is.

For now, I can include the custom emoji data for the status so that you have the shortcode and the static url. You would still need to map the shortcode to the image in your template file, but you would be able to provide more descriptive alt text.