shime / livedown

Live Markdown previews for your favorite editor.
MIT License
765 stars 51 forks source link

Proposal to add functionality to view files #32

Closed niftylettuce closed 6 years ago

niftylettuce commented 6 years ago

In a Readme.md file you might have a link LICENSE which points to LICENSE (a file in the root of your project). I suggest we drop this in favor of another static server that serves up the entire directory (this would also handle the image extension case you had built in by default):

+app.use(express.static(path.join(__dirname)))
-app.use(function (req, res, next) {
-  if (new RegExp('.' + ImageExtensions.join('|') + '$').test(req.path)) {
-    res.sendFile(path.join(filePath, '../' + req.path), sendFileOpts)
-  } else {
-    next()
-  }
-})

Curious if you had thoughts AGAINST this @shime ?

shime commented 6 years ago

Yeah, looks good. 🙌 Feel free to add enhancements like this in the future without asking for my permission. 😁

niftylettuce commented 6 years ago

@shime I used path.dirname instead of __dirname and released v2.1.0.