diff options
author | 2021-06-02 10:53:33 -0500 | |
---|---|---|
committer | 2021-06-02 11:53:33 -0400 | |
commit | ffb6380c3fde97e67c94a374d177b7fb4ca809c5 (patch) | |
tree | 55a4d1bd9d77ec0100263f8ed272037f39af63a0 /docs/markdown.md | |
parent | d2330a58256c212288bbba04ca41f1d65d37e711 (diff) | |
download | astro-ffb6380c3fde97e67c94a374d177b7fb4ca809c5.tar.gz astro-ffb6380c3fde97e67c94a374d177b7fb4ca809c5.tar.zst astro-ffb6380c3fde97e67c94a374d177b7fb4ca809c5.zip |
Dynamic Markdown content (#273)
* wip: serverside render dynamic Markdown content
* docs: update Markdown.astro comments
* Use existing markdown infrastructure to render external MD
* Update Markdown docs
* Add a changeset
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Diffstat (limited to 'docs/markdown.md')
-rw-r--r-- | docs/markdown.md | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/docs/markdown.md b/docs/markdown.md index 116f807a6..c20124096 100644 --- a/docs/markdown.md +++ b/docs/markdown.md @@ -97,7 +97,7 @@ const expressions = 'Lorem ipsum'; ### Remote Markdown -If you have Markdown in a remote source, you may pass it directly to the Markdown component. For example, the example below fetches the README from Snowpack's GitHub repository and renders it as HTML. +If you have Markdown in a remote source, you may pass it directly to the Markdown component through the `content` attribute. For example, the example below fetches the README from Snowpack's GitHub repository and renders it as HTML. ```jsx --- @@ -107,7 +107,27 @@ const content = await fetch('https://raw.githubusercontent.com/snowpackjs/snowpa --- <Layout> - <Markdown>{content}</Markdown> + <Markdown content={content} /> +</Layout> +``` + +Some times you might want to combine dynamic markdown with static markdown. You can nest `Markdown` components to get the best of both worlds. + +```jsx +--- +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> ``` |