1.0.0 • Published 5 years ago

md-mirror v1.0.0

Weekly downloads
5
License
ISC
Repository
gitlab
Last release
5 years ago

md-mirror

Fetch and mirror remote md files

Primary goal is to mirror files on GitHub but it should works with other services

Build status npm version Dependencies ISC license

Installation

npm i md-mirror

Usage

Methods can be used statically, or through an instance holding options. One of them return html content, this other call the supplied render method with that html content

Statically

// Logging html from a remote md file
const MdMirror = require('md-mirror')

MdMirror.html('/Meshtastic-esp32/master/README.md', {
  baseLocalUrl: '',
  baseRemoteUrl: 'https://raw.githubusercontent.com/meshtastic',
}).then(console.log)

With an instance

// Here we are rendering html from https://raw.githubusercontent.com/username repositories at the website root
// local url in the form : /reponame/branchname/whatever
const MdMirror = require('md-mirror')

app.get('/*', (req, res) => {
  const mm = new MdMirror({
    baseLocalUrl: '',
    baseRemoteUrl: 'https://raw.githubusercontent.com/username',
    viewManager: content => res.render('someview', { content })
  })

  return mm.render(req.url)
})

Caching

Caching have not been tried yet. @todo

Example

An example application is included. Run it with :

npm run dev

and open your browser at localhost:8080

Contributing

Issue reports, pull requests, suggestions and comments are very welcome, don't hesitate !

Commits with commitizen. Style : standard

License

ISC

Copyright (c) 2020, 121593