Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/we-lib/auto-favicon

Sets favicon for you based on title, with emoji support.
https://github.com/we-lib/auto-favicon

canvas emoji favicon

Last synced: 23 days ago
JSON representation

Sets favicon for you based on title, with emoji support.

Awesome Lists containing this project

README

        

# auto-favicon

> Sets favicon for you based on title, with emoji support.

*This module is separated from [silent](https://github.com/fritx/silent?tab=readme-ov-file#funny--fancy--performance), a static blog framework.*

![](https://blog.fritx.me/p/projects/silent_2.0/WechatIMG533.png)

![](https://blog.fritx.me/p/projects/silent_2.0/WX20220927-173925.png)

## Example

```html
Β 

// πŸ‘‰πŸ» https://blog.fritx.me/?projects/react-drag-sizing/
libAutoFavicon.autoFavicon('βœ‹πŸ» react-drag-sizing: ζ‹–ζ‹½ηΌ©ζ”Ύη»„δ»Ά')
// πŸ‘‰πŸ» https://blog.fritx.me/?projects/vue-at/
libAutoFavicon.autoFavicon('πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦ vue-at: ζ–‡ζœ¬ζ‘†@δΊΊη»„δ»Ά')

```

```js
// As NPM library
let libAutoFavicon = require('auto-favicon')
// πŸ‘‰πŸ» https://blog.fritx.me/?2022/09/blog-setup-via-github-fork
libAutoFavicon.autoFavicon('πŸš€ Blog Setup via Github Fork')

// Also, supports plain title, without an emoji
// πŸ‘‰πŸ» https://blog.fritx.me/?projects/silent_2.0/
libAutoFavicon.autoFavicon('silent 2.0')
```

## Respond to Dark Mode Change

```js
// addEventListener on page/component create
libAutoFavicon.startListenDarkMode()

// don't forget to removeEventListener on page/component destroy
libAutoFavicon.stopListenDarkMode()
```

## API & Options

- autoFavicon(title=document.title, setDocTitle=true, emojiOnly=false): string
- setFavicon(text: string): boolean
- detectShouldApply(userAgent=navigator.userAgent): boolean
- startListenDarkMode()
- stopListenDarkMode()

## License

MIT