0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix passing Markdown content through props (#1259) (#1343)

Co-authored-by: Kelvin Soh <kelvinsoh@pop-os.localdomain>
Co-authored-by: Fred K. Schott <fkschott@gmail.com>
This commit is contained in:
kelvinsjk 2021-09-15 08:03:45 +08:00 committed by GitHub
parent 9cf2df81db
commit 09b2f0e470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix passing Markdown content through props (#1259)

View file

@ -810,6 +810,7 @@ async function compileHtml(enterNode: TemplateNode, state: CodegenState, compile
async leave(node, parent, prop, index) {
switch (node.type) {
case 'Fragment': {
if (curr === 'markdown') curr = 'out';
buffers[curr] += `)`;
break;
}

View file

@ -128,4 +128,14 @@ Markdown('Can render markdown with --- for horizontal rule', async ({ runtime })
// It works!
});
Markdown('Can render markdown content prop (#1259)', async ({ runtime }) => {
const result = await runtime.load('/content');
assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('h1').text(), 'Foo', 'Markdown rendered correctly via content prop');
// It works!
});
Markdown.run();

View file

@ -0,0 +1,6 @@
---
import { Markdown } from 'astro/components';
const content = '# Foo';
---
<Markdown content={content} />