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 🙏

© 2026 – Pkg Stats / Ryan Hefner

emdash-plugin-cookie-consent

v1.0.1

Published

A fully customizable cookie consent banner plugin for EmDash CMS with category-level opt-in, theming, and an admin settings panel.

Readme

emdash-plugin-cookie-consent

CI Security npm version

A fully customizable cookie consent banner plugin for EmDash CMS with category-level opt-in, theming, and an admin settings panel.

Features

  • 4 consent categories — Necessary (always required), Functional, Analytics, Marketing
  • Granular opt-in — Accept All, Reject All, or custom selection via inline panel
  • Cookie persistence — 365-day expiry with SameSite=Lax
  • Admin settings panel — Full UI at /_emdash/admin
  • 6 built-in themes — Dark, Light, Midnight, Clean, Warm, Forest, plus custom colors
  • Mobile responsive — Collapses to stacked layout on small screens
  • No external dependencies — Zero runtime deps, all CSS/JS inlined (~5 KB per page)

Installation

npm install emdash-plugin-cookie-consent

Usage

Register the plugin in astro.config.mjs:

import { cookieConsentPlugin } from "emdash-plugin-cookie-consent";

export default defineConfig({
  integrations: [
    emdash({
      plugins: [cookieConsentPlugin()],
    }),
  ],
});

The banner appears automatically on all pages using EmDashHead and EmDashBodyEnd.

How It Works

The plugin injects three fragments via the page:fragments hook:

  1. CSS (<style> in <head>) — Banner and toggle styles
  2. Gate script (<script> in <head>) — Reads cookie_consent cookie into window.__ccConsent
  3. Banner script (<script> at <body:end>) — Shows/hides the banner, handles Accept/Reject/Customize/Save

All logic runs client-side. No server state required beyond plugin settings.

Admin Settings

Navigate to /_emdash/adminCookie Consent.

| Field | Default | Description | |---|---|---| | Enabled | true | Show/hide the banner | | Consent Message | (customizable) | Banner body text | | Accept/Reject/Customize Label | (customizable) | Button text | | Footer Reopen Text | Cookie Preferences | Floating reopen button | | Privacy Policy URL | (empty) | Optional link | | Banner Position | bottom | top or bottom | | Color Theme | dark | Preset or custom | | Background / Text / Button Color | (per theme) | Manual colors in custom mode |

Each category (Necessary, Functional, Analytics, Marketing) has configurable name and description fields.

Integrating Third-Party Scripts

This plugin manages consent preferences — it does not block or load scripts. Use window.__ccConsent to gate your own scripts:

interface ConsentState {
  necessary: true;       // Always active
  functional: boolean;
  analytics: boolean;
  marketing: boolean;
}

Quick example — Google Analytics 4

<script is:inline>
  if (window.__ccConsent?.analytics) {
    // Load gtag.js only when analytics consented
  }
</script>

Category reference

| Service | Category | Notes | |---|---|---| | Google Analytics 4 | analytics | Load gtag.js conditionally | | Google Tag Manager | analytics / marketing | Map consent types | | Facebook / Meta Pixel | marketing | Load fbevents.js conditionally | | YouTube / Vimeo embeds | functional | Click-to-load or conditional iframe | | Stripe / payment | necessary | Always load |

See the integration examples above for GA4, GTM, Facebook Pixel, and YouTube.

Development

git clone https://github.com/adrianoamalfi/emdash-plugin-cookie-consent.git
cd emdash-plugin-cookie-consent
npm install
npm run typecheck
npm test

Versioning

This project follows Semantic Versioning. Releases are automated via semantic-release — pushing fix:, feat:, or BREAKING CHANGE: commits to main triggers a release to npm and GitHub.

License

MIT © Adriano Amalfi