DavidDarnes,
@DavidDarnes@mastodon.design avatar

New addition to my #WebComponents collection: <mastodon-post>!

Embed mastodon posts on your web pages by progressively enhancing a regular link and without the need for an <iframe>. Use the built in semantic template or apply your own! Read more about it here:
https://darn.es/mastodon-post-web-component/

#InideWeb #Webmentions #Mastodon

Thanks to @robb and @mariohamann for the inspiration ✨

jm3,
@jm3@trunk.lol avatar

@DavidDarnes great idea

DavidDarnes,
@DavidDarnes@mastodon.design avatar

@jm3 thanks!

ariel,

@DavidDarnes Lovely work Dave!

DavidDarnes,
@DavidDarnes@mastodon.design avatar

@ariel thank you!

DavidDarnes,
@DavidDarnes@mastodon.design avatar

Made a quick demo for someone who wanted a static fallback. It's effectively a static HTML copy of the Mastodon post but the Web Component grabs the link to the post and “hydrates" into having the current data:
https://codepen.io/daviddarnes/pen/dyrrBRp?editors=1100

sarajw,
@sarajw@front-end.social avatar

@DavidDarnes @robb @mariohamann this is very cool! Thanks Dave!

julian,
@julian@fietkau.social avatar

@DavidDarnes Nice work, I'm into it. 👍

As embeddable solutions go, this one beats iframes IMO, but I'm still kinda on the lookout for one that contains a plain-text copy of the post it can fall back on for displaying if the Mastodon server is down. You think that'd be potentially in scope for yours?

DavidDarnes,
@DavidDarnes@mastodon.design avatar

@julian thanks very much! Sounds like what you need to do is just copy the Mastodon post content itself and then wrap it with this component. That way you'll get the best of both worlds.

Something like this? https://codepen.io/daviddarnes/pen/dyrrBRp?editors=1100

julian,
@julian@fietkau.social avatar

@DavidDarnes Yeah, pretty much. Mastodon servers vanish often enough that I think the fallback text is critical. I'd likely add the posting date/time too, but the principle's the same.

I haven't tried out your script myself yet, but for me it'd be ready to replace the default iframe embeds if the per-post code snippet can easily be copypasted in without futzing with style sheets or one-off scripts, doesn't choke if multiple posts are embedded within the same page, etc.

Again, very cool to see.

DavidDarnes,
@DavidDarnes@mastodon.design avatar

@julian it should work pretty well with multiple posts, granted though it will end up making a fetch request for each. However it's far less overhead than the whole iframe. Let us know how you get on!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • mastodon
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • anitta
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • provamag3
  • tester
  • Leos
  • megavids
  • JUstTest
  • All magazines