Remark utils
Reusable utils to build markdown service power by remarkjs and elasticlunr.
Installation
$ yarn add remark-utils
Usage
mdToHtml
type string;
; const html = ; // <h1 id="heading"><a href="#heading" aria-hidden class="anchor"><svg aria-hidden="true" height="24" version="1.1" viewBox="0 0 24 24" width="24"><path fill-rule="evenodd" d="..."></path></svg></a>heading</h1>
mdToElasticlunrIndex
type IndexingItem = title: string body: string url: string; type MdToElasticlunrIndex = filenames: Array<string> IndexingItem string;
// Server side;;const filenames = glob;const index: string = ; // Client side;const idx = Index;const results = idx ;
Check the tests and Query from Index section for more details.
API
Options
Use with lazysizes
// Server side preprocessconst base64Json = '../images/AWS_Icons-300x200.png': imagePath: '../images/AWS_Icons-300x200.png' width: 300 height: 200 format: 'png' base64: 'data:image/png;base64,mock' ; // Mappingconst html = ;// Output html:<div style="max-width: 300px;"> <div style="width: 100%; padding-bottom: 66.66%; height: 0; position: relative;"> <img src="data:image/png;base64,mock" alt="AWS_Icons-300x200.png" title="aws" data-src="../images/AWS_Icons-300x200.png" class="lazyload" style="position: absolute; width: 100%;"> </div></div> // Client sideimport'lazysizes';
Development
- node 11.9.0
- yarn 1.13.0
$ yarn install --pure-lockfile
Test
$ yarn run format$ yarn run eslint$ yarn run flow$ yarn run test:watch$ yarn run build
Publish
$ npm version patch$ npm run changeloggit commit & push
CONTRIBUTING
- ⇄ Pull requests and ★ Stars are always welcome.
- For bugs and feature requests, please create an issue.
- Pull requests must be accompanied by passing automated tests.