Giter Club home page Giter Club logo

Comments (9)

matthewp avatar matthewp commented on May 5, 2024 1

@natemoo-re this seems to be caused by moving the markdown to the compiler. I don't see an obvious solution without reversing that (which I don't think we should do).

I'm also unsure of what should be expected here. In this case it's desirable to render the dynamic content but I can see cases where you don't want it to be rendered (to display the raw markdown code for example).

Perhaps we could support this via an attribute?

<Markdown content={content} />

from astro.

natemoo-re avatar natemoo-re commented on May 5, 2024

This is a regression! Thanks for filing, I'll take a look.

from astro.

natemoo-re avatar natemoo-re commented on May 5, 2024

Yep, this was definitely caused by moving the markdown to the compiler. We definitely shouldn't move it back to the runtime, but this behavior was a huge selling point of the Markdown component, IMO.

I'm okay moving to a content prop. That would cover "render this entire Markdown document" but sidestep some potentially thorny issues with dynamic content.

My thought is that the Markdown component would POST content to some path in /_astro_internal which would act like an API route. It would return the rendered HTML. Bonus: we'd already have a hook into the user's astro.config.mjs settings, so we can automatically use any configured plugins (when the time comes).

from astro.

matthewp avatar matthewp commented on May 5, 2024

Not sure I follow the API idea, what would be the reason to do it that way?

from astro.

matthewp avatar matthewp commented on May 5, 2024

Just an update here, #273 is a fix for this issue. It will be a breaking change however, as you'll now need to pass your dynamic markdown as an attribute. For example you can do:

---
import Markdown from 'astro/components/Markdown.astro';

const content = await fetch('https://raw.githubusercontent.com/snowpackjs/snowpack/main/README.md').then(res => res.text());
---

<Layout>
  <Markdown>
    ## Markdown example

    Here we have some __Markdown__ code. We can also dynamically render content from remote places.

    <Markdown content={content} />
  </Mardown>
</Layout>

This is to allow both static and dynamic markdown to be treated separately and compiled at the appropriate time (static is compiled at .astro compile time, dynamic at runtime).

from astro.

georges-gomes avatar georges-gomes commented on May 5, 2024

We will try that πŸ‘
Released soon?

from astro.

matthewp avatar matthewp commented on May 5, 2024

It's out in 0.12.x. Closing this issue!

from astro.

georges-gomes avatar georges-gomes commented on May 5, 2024

Thanks team πŸ™‡

from astro.

matthewp avatar matthewp commented on May 5, 2024

There's another bug you might run into (will be obvious), which we should have a fix for shortly.

from astro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.