Socket
Socket
Sign inDemoInstall

eleventy-plugin-vibrant

Package Overview
Dependencies
897
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eleventy-plugin-vibrant

Extract prominent colors from your Eleventy site's images.


Version published
Weekly downloads
2
Maintainers
1
Install size
21.5 MB
Created
Weekly downloads
 

Readme

Source

eleventy-plugin-vibrant

Extract prominent colors from your Eleventy site's images.

Installation

Avaliable on npm:

npm install eleventy-plugin-vibrant --save-dev

Open up your Eleventy config file (probably .eleventy.js) and use addPlugin:

const pluginVibrant = require('eleventy-plugin-vibrant');
module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(pluginVibrant);
};

This supplies the following asynchronous Nunjucks filter:

  • vibrant(swatch): Extract prominent colors from the image at a given path.

Usage

In your Nunjucks templates:

<img src="{{ path }}" style="background: {{ path | vibrant('muted') }}">

Result:

<img src="/path/to/image.png" style="background: #ff0000" />

The vibrant filter transforms a string that points to an image and returns a hex color. Up to 6 color swatches are extracted from the image, and they can be selected by passing in the corresponding keywords to the filter.

The following color swatch types can be used:

  • vibrant
  • muted
  • darkvibrant
  • darkmuted
  • lightvibrant
  • lightmuted

Not every image returns all swatch types. A fallback list can be provided, and the first matching type will be used.

<img src="{{ path }}" style="background: {{ path | vibrant(['darkmuted', 'muted', 'lightmuted']) }}">

Keywords

FAQs

Last updated on 23 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc