https://github.com/posthtml/posthtml-inline-favicon
PostHTML plugin to inline favicons
https://github.com/posthtml/posthtml-inline-favicon
data-uri favicon inline posthtml posthtml-plugin
Last synced: 4 days ago
JSON representation
PostHTML plugin to inline favicons
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-inline-favicon
- Owner: posthtml
- License: mit
- Created: 2019-08-18T00:32:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-20T07:40:04.000Z (over 1 year ago)
- Last Synced: 2024-10-29T21:06:06.158Z (about 1 year ago)
- Topics: data-uri, favicon, inline, posthtml, posthtml-plugin
- Language: HTML
- Homepage:
- Size: 311 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# posthtml-inline-favicon 
[![NPM][npm]][npm-url]
`posthtml-inline-favicon` is a [PostHTML](https://github.com/posthtml/posthtml) plugin to inline favicons.
**Before:**
```html
```
**After:**
```html
```
## Install
```bash
# npm
npm i -D posthtml-inline-favicon
# pnpm
pnpm add -D posthtml-inline-favicon
# Yarn
yarn add -D posthtml-inline-favicon
```
## Usage
```js
const fs = require("fs");
const posthtml = require("posthtml");
const { inlineFavicon } = require("posthtml-inline-favicon");
const html = fs.readFileSync("./index.html");
posthtml()
.use(inlineFavicon())
.process(html)
.then((result) => fs.writeFileSync("./after.html", result.html));
```
## Options
By default, the plugin assumes that the file to process is in the same directory as the posthtml script. If not, specify the relative path to the html file in the options:
```js
const fs = require("fs");
const posthtml = require("posthtml");
const { inlineFavicon } = require("posthtml-inline-favicon");
const html = fs.readFileSync("./public/index.html");
posthtml()
.use(inlineFavicon({ path: "public" }))
.process(html)
.then((result) => fs.writeFileSync("./after.html", result.html));
```
## [Example](example)
## Contributing
See the [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/docs).
## [Changelog](CHANGELOG.md)
## License
[MIT](LICENSE)
[npm]: https://img.shields.io/npm/v/posthtml-inline-favicon.svg?color=blue
[npm-url]: https://npmjs.com/package/posthtml-inline-favicon