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

https://github.com/bmuenzenmeyer/eleventy-plugin-inline-link-favicon

Eleventy shortcodes and filters to add an inline favicon image to a link.
https://github.com/bmuenzenmeyer/eleventy-plugin-inline-link-favicon

11ty 11ty-plugin eleventy eleventy-plugin favicon

Last synced: 5 days ago
JSON representation

Eleventy shortcodes and filters to add an inline favicon image to a link.

Awesome Lists containing this project

README

          

# eleventy-plugin-inline-link-favicon

Eleventy shortcodes and filters to add an inline favicon image to a link.

[![A screenshot of the plugins output. Links display their favicon inline.](/screenshot.png)](https://eleventy-plugin-inline-link-favicon.netlify.app/)

[Live Demo](https://eleventy-plugin-inline-link-favicon.netlify.app/) | [Blog Demo](https://brianmuenzenmeyer.com/hubs/opensource/)

## Install

```bash
npm install eleventy-plugin-inline-link-favicon
```

## Configuration

Add the plugin to your `.eleventy.js` config file:

```js
const pluginInlineLinkFavicon = require("eleventy-plugin-inline-link-favicon")

module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(pluginInlineLinkFavicon)
}
```

## Usage

This plugin comes with two mechanisms to create an inline link favicon. You can use a [paired shortcode](https://www.11ty.dev/docs/shortcodes/#paired-shortcodes) or a [filter](https://www.11ty.dev/docs/filters/), both referenced as `ai`. `ai` is short for anchor-image.

### Paired Shortcode

~~~~~~~~~~njk
{% ai "https://front-end.social/@brian" %}@brian{% endai %}
~~~~~~~~~~

returns

~~~~~~~~~~html
favicon for https://front-end.social/@brian@brian
~~~~~~~~~~

### Filter

~~~~~~~~~~njk
{{ "https://front-end.social/@brian" | ai("@brian") | safe }}
~~~~~~~~~~

returns the same as above.

### Snippets / Completions

Authoring content with this plugin is aided by user-defined snippets:

- [Visual Studio Code](https://code.visualstudio.com/docs/editor/userdefinedsnippets)

```json
{
"ai": {
"scope": "markdown,nunjucks",
"prefix": "ai",
"body": ["{% ai \"$1\"%}$2{% endai %}$0"],
"description": "add an inline link favicon"
}
}
```

## Credits

- Thanks to [5t3ph/eleventy-plugin-template](https://github.com/5t3ph/eleventy-plugin-template) for inspiration
- Thanks to this [blog by Jim Nielsen](https://blog.jim-nielsen.com/2021/displaying-favicons-for-any-domain/) as inspiration.