astro/packages/astro/components/Markdown.astro
Nate Moore a136c85e6b
New Props API (#515)
* wip: update props api

* feat(#139, #309): enable new props api

* chore: migrate examples to new props API

* docs: update syntax guide for new props API

* chore: update examples to new props API

* chore: update docs to new Props API

* fix: hide __astroInternal from `Astro.props` consumers

* chore: remove scratchpad file

* chore: fix script error

* test: fix failing collection tests

* fix: set __astroInternal to `enumerable: false`

* chore: add changeset

* feat: warn users using old props api
2021-06-24 17:48:24 -05:00

23 lines
515 B
Text

---
import { renderMarkdown } from '@astrojs/markdown-support';
const { content, $scope } = Astro.props;
let html = null;
// This flow is only triggered if a user passes `<Markdown content={content} />`
if (content) {
const { content: htmlContent } = await renderMarkdown(content, {
mode: 'md',
$: {
scopedClassName: $scope
}
});
html = htmlContent;
}
/*
If we have rendered `html` for `content`, render that
Otherwise, just render the slotted content
*/
---
{html ? html : <slot />}