🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

eleventy-plugin-unfurl

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eleventy-plugin-unfurl

Unfurl links into preview cards in Eleventy

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
29
26.09%
Maintainers
1
Weekly downloads
 
Created
Source

eleventy-plugin-unfurl

npm

Turn URLs into rich cards. Show a preview image, page title, description and other meta information all inside a neatly presented card. Collaborative effort between Sara Soueidan and myself.

See the live demo and the demo directory in the repo to see it all in action.

Installation

  • Install plugin using npm:

    npm install eleventy-plugin-unfurl
    
  • Add plugin to your .eleventy.js config:

    const pluginUnfurl = require("eleventy-plugin-unfurl");
    
    module.exports = (eleventyConfig) => {
      eleventyConfig.addPlugin(pluginUnfurl);
    };
    
  • Use the shortcode in your templates (.md, .njk, .liquid or .js) like so:

    {% unfurl "https://www.sarasoueidan.com/blog/prefers-color-scheme-browser-vs-os/" %}
    

Options

  • duration: The duration of time before the cache is busted and new data is captured from the URL. Default is 1m, check out the Eleventy Fetch documentation for more info.

  • template: A custom template to present unfurled links. Can be a totally custom HTML template string.

    Example:

    eleventyConfig.addPlugin(pluginUnfurl, {
      template: ({ title, url }) => `<a href="${url}">${title}</a>`,
    });
    

    Check out the Microlink API documentation for a full list of possible data fields.

Development

  • Amend the .eleventy.js file within demo so it points to the source code in the parent directory:

    // const pluginUnfurl = require("../");
    const pluginUnfurl = require("eleventy-plugin-unfurl");
    
  • Install the demo dependencies:

    cd demo
    npm install
    
  • Run the demo locally:

    npm run dev
    

Credits

Keywords

11ty

FAQs

Package last updated on 03 Jan 2023

Did you know?

Socket

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