• About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
AimactGrow
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
AimactGrow
No Result
View All Result

Astro Markdown Part Utility for Any Framework

Admin by Admin
June 1, 2026
Home Coding
Share on FacebookShare on Twitter


Within the earlier article, I spoke in regards to the why and use a Markdown element in Astro.

Right here, we’re going to develop on that and enable you to use Markdown in every single place — whatever the framework you utilize. So, this works for React, Vue, and Svelte.

Your entire course of hinges on the Markdown utility I’ve constructed for Splendid Labz.

Why This Utility?

I hit a snag when utilizing most Markdown libraries. I naturally write Markdown content material like this:

It is a paragraph It is a second paragraph

However since most markdown libraries don’t account for whitespace indentation, they create an output with

 and  tags.

It is because Markdown treats the indentation past 4 areas as a code block:

  It is a paragraph

      It is a second paragraph
    

So that you’re compelled to strip all indentation and write it like this as an alternative:

It is a paragraph It is a second paragraph

That’s laborious to learn and annoying to keep up.

My Markdown utility handles this whitespace situation and generates the proper HTML no matter how your code is indented:

It is a paragraph

It is a second paragraph

Utilizing This in Your Framework

It’s straightforward. You need to cross the Markdown textual content into the utility. If inline is true, then markdown will return an output with out paragraph tags.

Right here’s an instance with Astro.

---
import { markdown } from '@splendidlabz/utils'
const { inline = false, content material } = Astro.props
const slotContent = await Astro.slots.render('default')

// Course of content material
const html = markdown(content material || slotContent, { inline })
---

You may then use it like this:


   

Right here’s one other instance for Svelte.

Svelte can not learn dynamic content material from slots, so we are able to solely cross it by a prop.




{@html html}

And you need to use it like this:

It’s reasonably easy to construct the identical for React and Vue so I’d go away that as much as you.

Taking it Additional

I’ve been constructing for the net — lengthy sufficient to expertise the frustration of doing the identical issues again and again.

So I consolidated all the things I take advantage of into a couple of easy libraries — like Splendid Utils, and some others for layouts, Astro and Svelte parts.

I write about all of them on my weblog. Come by for those who’re occupied with higher DX as you construct your websites and apps!

Tags: AstroComponentFrameworkMarkdownutility
Admin

Admin

Next Post
7 Variations Between dVPNs and Conventional VPNs

7 Variations Between dVPNs and Conventional VPNs

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

DDL, DML, DQL, DCL, and TCL – SitePoint

DDL, DML, DQL, DCL, and TCL – SitePoint

May 13, 2025
Return To Silent Hill Is The First Really Horrible Film Of 2026

Return To Silent Hill Is The First Really Horrible Film Of 2026

January 22, 2026

Trending.

The Obtain: the tech reshaping IVF and the rise of balcony photo voltaic

The Obtain: the tech reshaping IVF and the rise of balcony photo voltaic

May 7, 2026
Undertaking possession (fairness and fairness)

Your work diary | Seth’s Weblog

May 6, 2026
Nsfw Chatgpt Options – Examples I’ve Used

Nsfw Chatgpt Options – Examples I’ve Used

October 13, 2025
From Shader Uniforms to Clip-Path Wipes: How GSAP Drives My Portfolio

From Shader Uniforms to Clip-Path Wipes: How GSAP Drives My Portfolio

May 7, 2026
I Used Each and This is How They Differ

I Used Each and This is How They Differ

May 7, 2026

AimactGrow

Welcome to AimactGrow, your ultimate source for all things technology! Our mission is to provide insightful, up-to-date content on the latest advancements in technology, coding, gaming, digital marketing, SEO, cybersecurity, and artificial intelligence (AI).

Categories

  • AI
  • Coding
  • Cybersecurity
  • Digital marketing
  • Gaming
  • SEO
  • Technology

Recent News

The Simpsons Monopoly Go! Crossover: New Cellular Occasion Particulars

The Simpsons Monopoly Go! Crossover: New Cellular Occasion Particulars

June 1, 2026
9 Sprint Cams Amazon Customers Swear By For Below $100

9 Sprint Cams Amazon Customers Swear By For Below $100

June 1, 2026
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved

No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved