Skip to content

Can't render string Markdown with compile() #697

@AnzeKop

Description

@AnzeKop

We have a project where we store markdown data in the database and need to fetch this on the server to then render on the frontend.

Reading the docs the compile function looks to be the way to implement this but as this spits out svelte code wrapped in a string its not possible to render it using `{@render content()} and rendering using {@html content} gives wierd outcomes:

const questionData = {
	title: 'Sample Question',
	content: `## This is a sample question. 
	It is used to test the FAQ page when no question is found. 
	\`\`\`ts
	const sample = 'sample';
	\`\`\`
	`,
	slug: 'sample-question'
};

const compiledContent = await compile(questionData.content);
Image
<div class="container">
	<div class="prose">
		{@html questionData.content.code}
	</div>
</div>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions