summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/thirty-clouds-end.md5
-rw-r--r--packages/astro/src/compiler/codegen/index.ts1
-rw-r--r--packages/astro/test/astro-markdown.test.js10
-rw-r--r--packages/astro/test/fixtures/astro-markdown/src/pages/content.astro6
4 files changed, 22 insertions, 0 deletions
diff --git a/.changeset/thirty-clouds-end.md b/.changeset/thirty-clouds-end.md
new file mode 100644
index 000000000..e783e39a3
--- /dev/null
+++ b/.changeset/thirty-clouds-end.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix passing Markdown content through props (#1259)
diff --git a/packages/astro/src/compiler/codegen/index.ts b/packages/astro/src/compiler/codegen/index.ts
index ff807108e..dd83cdea5 100644
--- a/packages/astro/src/compiler/codegen/index.ts
+++ b/packages/astro/src/compiler/codegen/index.ts
@@ -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;
}
diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js
index 9e13c0dc2..cf7511dc9 100644
--- a/packages/astro/test/astro-markdown.test.js
+++ b/packages/astro/test/astro-markdown.test.js
@@ -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();
diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/content.astro b/packages/astro/test/fixtures/astro-markdown/src/pages/content.astro
new file mode 100644
index 000000000..8c07debd2
--- /dev/null
+++ b/packages/astro/test/fixtures/astro-markdown/src/pages/content.astro
@@ -0,0 +1,6 @@
+---
+import { Markdown } from 'astro/components';
+const content = '# Foo';
+---
+
+<Markdown content={content} /> \ No newline at end of file