mez,
@mez@mastodon.nz avatar

What’s your favourite way to add working examples of code in your blog posts that isn’t CodePen? Both for CSS and JS example code.

Thinking a basic web component with declarative shadow DOM might do it nicely since it will fully encapsulate the code? Maybe wrap it in @zachleat browser-window or resize-asaurus component.

#WebDev #Blogs

mez,
@mez@mastodon.nz avatar

I think my solution will need to be a web component and some custom code for Eleventy. What I’d like to do is have code sections that I can wrap in a custom element which then renders the raw code text AND the demo of said code. But I want to do it progressively, so the code also shows and when JS kicks off, the demo is shown. But HTML in code blocks is encoded and styled with PrismJS which means lots of extra markup. Not sure how to handle this yet. 🤔

(I appreciate the help to the above toot)

mez,
@mez@mastodon.nz avatar

Also, it doesn’t actually need to be progressively enhanced if it’s an HTML/CSS demo. So maybe the iframe route is the right idea? Or Eleventy’s WebC might be the winner here?

zachleat,
@zachleat@zachleat.com avatar

@mez I tried to find it but couldn’t—there was a discussion about this on mastodon in the last week or two!

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