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

@igloonet/gatsby-plugin-cookiebot

v1.0.2

Published

Gatsby plugin for Cookiebot CMP

Downloads

14

Readme

@igloonet/gatsby-plugin-cookiebot

NPM MIT License Forked from  Nitro Modified by igloonet

Easily add Cookiebot on a Gatsby site. Especially useful when using Cookiebot's manual mode and gatsby-plugin-google-tagmanager.

Main features

  • Adds Cookiebot script to the page <head>
  • Blocks Google Tag Manager's <script> and <noscript> tags created by gatsby-plugin-google-tagmanager when using Cookiebot's manual mode by setting data-cookieconsent="statistics" and type="text/plain" to the tags

How to use

Install package

Yarn

yarn add @igloonet/gatsby-plugin-cookiebot

NPM

npm i @igloonet/gatsby-plugin-cookiebot

Configure gatsby-config.js

plugins: [
  {
    resolve: "@igloonet/gatsby-plugin-cookiebot",
    options: {
      // Required. Site's Cookiebot ID.
      cookiebotId: "00000000-0000-0000-0000-000000000000",
      // Optional. Turns on Cookiebot's manual mode. Defaults to false.
      manualMode: true,
      //  Optional. Skip blocking of GTM. Defaults to true if manualMode is set to true.
      blockGtm: false,
      // Optional. Enables plugin in development. Will cause gatsby-plugin-google-tagmanager to thrown an error when pushing to dataLayer. Defaults to false.
      includeInDevelopment: true,
      // Optional. Disable Consent Mode. Default false.
      disableConsentMode: true,
    },
  },
];

Make sure gatsby-plugin-google-tagmanager is listed before gatsby-plugin-cookiebot

Adding Cookiebot's cookie declaration to a site

This plugin doesn't provide a way to inject the cookie declaration to your site because there's multiple ways to achieve the same thing. Here's a useful snippet you can copy that ensures the declaration is loaded on internal site navigation events.

import React from "react";

isBrowser = () => typeof window !== "undefined";

const COOKIEBOT_DECLARATION_WRAPPER_ID = "cookiebot-declaration-wrapper";

export function CookieDeclaration() {
  React.useEffect(() => {
    // Inject Cookiebot declaration
    if (isBrowser()) {
      const cookiebotCookieDeclaratioScript = document.createElement("script");
      cookiebotCookieDeclaratioScript.src =
        "https://consent.cookiebot.com/00000000-0000-0000-0000-000000000000/cd.js";
      cookiebotCookieDeclaratioScript.type = "text/javascript";
      cookiebotCookieDeclaratioScript.async = true;

      const cookiebotWrapperEl = document.getElementById(
        COOKIEBOT_DECLARATION_WRAPPER_ID
      );
      if (cookiebotWrapperEl) {
        cookiebotWrapperEl.appendChild(cookiebotCookieDeclaratioScript);
      }
    }
  }, []);

  return <div id={COOKIEBOT_DECLARATION_WRAPPER_ID}></div>;
}

Contributing to gatsby-plugin-cookiebot

# You will need yalc in the destination project so better to install yalc globally
npm i -g yalc
# Watch for changes and publish locally with yalc
npm run develop
cd ../destination-gatsby-project
# Link local package to a project
yalc link @igloonet/gatsby-plugin-cookiebot
# Alternative way of attaching the published package with yalc
# yalc add @igloonet/gatsby-plugin-cookiebot
# Run gatsby clean and restart development server on plugin changes
gatsby clean && gatsby develop
## When changes are ready. Build and publish to NPM
npm run npm:publish

Made with passion by Nitro

We are a hybrid marketing agency ready to set your business on fire by bringing together marketing communication and digital services in a unique way. We love Gatsby and we hope this plugin makes your day. If you're ever in need of Gatsby expertise why not consider us at nitro.fi :).