npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eleventy-plugin-green-links

v0.1.5

Published

An Eleventy plugin which checks if links on a website are hosted on verified green hosting providers from The Green Web Foundation's Green Web dataset.

Downloads

16

Readme

Eleventy Plugin: Green Links

An Eleventy plugin which checks if links on a website are hosted on verified green hosting providers from The Green Web Foundation's Green Web dataset.

What is a Green Web Host?

Verified green hosting providers are organisations that can demonstrate they are taking steps to avoid, reduce or offset the greenhouse gas emissions caused by using electricity to provide their services. They provide evidence to The Green Web Foundation to show that they do this on a yearly basis, or better.

Why does Green Web hosting matter?

Choosing a green web host for a website is one of the most impactful decisions any website owner can make. Based on peer-reviewed research, the Sustainable Web Design model says hosting accounts for 15% of a website’s total energy usage. Beyond making your own site more sustainable, it also sends a message to other hosting providers that their potential customers value services that are powered by renewable energy.

Installation

The plugin is available on npm. Install it as a dev dependency in your Eleventy project.

npm install eleventy-plugin-green-links --save-dev

Then add the plugin in your .eleventy.js configuration file.

const greenLinks = require("eleventy-plugin-green-links");

module.exports = (eleventyConfig) => {
  eleventyConfig.addPlugin(greenLinks);
};

Usage

You can use the plugin as it is if you've followed the installation steps. However, if you want to ignore one or more domains you can pass a config object when initialising the plugin.

// .eleventy.js

const greenLinks = require("eleventy-plugin-green-links");

module.exports = (eleventyConfig) => {
  eleventyConfig.addPlugin(greenLinks, {
    ignore: ["fershad.com", "thegreenwebfoundation.org"],
  });
};

Config object

How it works

  1. This transform goes through each page of an Eleventy site, and checks for valid external links.
  2. It then gets all the unique domain names of those links & uses CO2.js to check them against The Green Web Foundation's Green Web dataset.
  3. The Green Web dataset returns an array of all checked the domains hosted on known green web hosts.
  4. All links hosted on green domains then have the data-green-link="true" attribute added to them.

Highlighting green links

Since all green hosted links now have a data-green-link="true" attribute, you can target that using CSS to apply some custom styles to those links. An example below, which puts a teal coloured wavy underline on those links. You can also see it in action on my personal website: fershad.com.

a[data-green-link="true"] {
  text-decoration: underline wavy 2px teal;
}