-
Hi there, I'm wondering if there's any way, in a vue layout file, to render markdown using a component or a specific function. I've got a bunch of markdown files with that kind of content: ---
title: Some page title here
date: 2017-11-23
description: >
And in the description, **some** markdown content that I need to _render_.
---
And here the actual page content.
And I'm trying to process them using a layout file like this: <script setup lang="ts">
const { page } = usePage();
</script>
<template>
<Topbar />
<main>
<!-- I need to render the markdown contained in `page.description` here ... -->
</main>
</template> My first idea was to use a so called MDX Component and give the Or may be there is another way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi Julien! @YuukanOO You can use any markdown-in-JS solution to render the markdown, for example, <script setup lang="ts">
import { VueShowdown } from 'vue-showdown'
</script>
<template>
<Topbar />
<main>
<VueShowdown :markdown="$page.description"/>
</main>
</template> This won't affect the production bundle size if you use it outside islands, zero JS required. Try it out and let me know how it goes 😃 This is something I've been thinking about adding this out of the box, although I haven't yet run into the need myself. An îles native version would use the dev server and compile the markdown using XDM, which would apply any remark or rehype plugins that you've configured, making it consistent with any other markdown in the site. |
Beta Was this translation helpful? Give feedback.
Hi Julien! @YuukanOO
You can use any markdown-in-JS solution to render the markdown, for example,
vue-showdown
:This won't affect the production bundle size if you use it outside islands, zero JS required.
Try it out and let me know how it goes 😃
This is something I've been thinking about adding this out of the box, although I haven't yet run into the need myself.
An îles native version would use the dev server and compile the markdown using XDM, which would apply any remark or rehype plugins that you've con…