How to input/parse CHANGELOG.md in-app?


#1

My goal is to have a version number that the user can click, which will pop up the changelog, which would be pulled directly from CHANGELOG.md. Is this doable? I’m not even sure where to start.


#2

You can use an npm package for that: https://www.npmjs.com/package/marked

Load your file:

var file = require('fs').readFileSync('path/to/CHANGELOG.md');

Parse the Markdown Syntax into readable HTML:

var parsedMarkdown = require('marked')(file)

You can search through the whole string and output only the section you’re interested in (based on the version number that was clicked).

Does this help?


#3

I thought about that approach… which of course would have to be server-side. I could call a Meteor method upon the user clicking the version number, which would summon up the contents of the file and render them.


#4

You basically have no other way.
The client doesn’t know about the files on your server, you could do an HTTP request, but that’s just overkill if you have Meteor.methods available…


#5

If your code lives in a GitHub repo you could use gitraw to get the content of CHANGELOG.MD and parse it with markedjs.

Or you could put your CHANGELOG.MD in the public folder so your code doesn’t have to be on GitHub (especially when the repo is private)