How to render .md file to Vue Template?

I would like to render .md file to Vue

// changelog.md
............
------
// Vue template
<template>
.....
</template

Please help me

I tried, but don’t work.
Could example?

1 Like

Sorry man, I’m kind of busy, but I can.

I had this same issue (Blaze not Vue but u should be able to hack it together) where I ended up creating a method that returns the HTML to the client generated from the .md file.

I use the themeteorchef:commonmark package to convert the md file to html.

You also have to add the markdown file as an asset to in your package.js file for this to work

api.addAssets(['mymarkdown.md'], 'server');

You grab the contents from your markdown file from your md file like this:

const mymarkdownsource = Assets.getText('mymarkdown.md');

Once you do your method can just return the html - something like this using the commonmark.parseMarkdown exported function to do the conversion:

return parseMarkdown(mymarkdownsource)

Then in the client you display the thing like this (Blaze again):

// start the spinner

Meteor.call('getMarkDownMethod', function (err, result){
        // stop the spinner

        if (err) {
            $('#markDown').html('No fancy markdown found :(');
        }
        else {
            $('#markDown').html(result);
        }
});

There may be a more elegant solution but this worked great for my use case with Blaze.

I use it for my terms of use, privacy statement etc.

1 Like

Thanks, I will try :smile: