Inline svg icons in HTML
npm install posthtml-inline-svgPostHTML plugin that inline svg icons in HTML. Like GitHub does with Octicons.
``html`
`html`
`bash`
npm i -D posthtml posthtml-inline-svg
`js
const path = require('path')
const fs = require('fs')
const posthtml = require('posthtml');
const inlineSVG = require('posthtml-inline-svg');
posthtml(inlineSVG({
cwd: path.resolve('src'),
tag: 'icon',
attr: 'src',
}))
.process(fs.readFileSync('index.html', 'utf8'))
.then((result) => console.log(result.html));
`
|Option|Default|Description|
|:-:|:--|:--|
| cwd | process.cwd() | Path icon source related to |icon
| tag | | HTML-tag to process |src
| attr | | Attribute to get icon path |false
| comment | | Render HTML comment with icon source before icon markup |since 0.2.0
| svgo | null` | Custom SVGO config |