Skip to content

Commit

Permalink
Fix Markdown rendering inside templates. (#1219)
Browse files Browse the repository at this point in the history
* Fix Markdown rendering inside templates.

* Changeset
  • Loading branch information
carloskelly13 authored Sep 12, 2022
1 parent f37c35d commit 055d9c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-buses-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'spectacle': patch
---

Fixed Notes node tree generation inside Markdown component.
13 changes: 9 additions & 4 deletions packages/spectacle/src/components/markdown/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,15 @@ export const Markdown = forwardRef<HTMLDivElement, MarkdownProps>(
});

// Transform and compile the notes AST.
const transformedNotesAst = notesCompiler.runSync(extractedNotes);
const noteElements = notesCompiler.stringify(transformedNotesAst);

return [templateProps, noteElements] as const;
if (
Array.isArray(extractedNotes.children) &&
extractedNotes.children.length >= 1
) {
const transformedNotesAst = notesCompiler.runSync(extractedNotes);
const noteElements = notesCompiler.stringify(transformedNotesAst);
return [templateProps, noteElements] as const;
}
return [templateProps, null] as const;
}, [
rawMarkdownText,
getPropsForAST,
Expand Down

0 comments on commit 055d9c6

Please sign in to comment.