{"_id":"emdash-plugin-cookie-consent","_rev":"2-b290a424ddfeb62dd10ddd8c805a70d3","name":"emdash-plugin-cookie-consent","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"emdash-plugin-cookie-consent","version":"1.0.0","keywords":["emdash","emdash-plugin","cookie-consent","cookies","gdpr","privacy","cms"],"author":{"url":"https://adrianoamalfi.com","name":"Adriano Amalfi","email":"adrianoamalfi@gmail.com"},"license":"MIT","_id":"emdash-plugin-cookie-consent@1.0.0","maintainers":[{"name":"adrianoamalfi","email":"adrianoamalfi@gmail.com"}],"homepage":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent#readme","bugs":{"url":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent/issues"},"dist":{"shasum":"23f31783069bc18fbd6cde33cefd5ab68372c41b","tarball":"https://registry.npmjs.org/emdash-plugin-cookie-consent/-/emdash-plugin-cookie-consent-1.0.0.tgz","fileCount":5,"integrity":"sha512-I2myPjDOPjpjs//yt61+yYwibMb4dWtolDup9eI9E74JDzDvXFWaLh/JJVn3agElBL+XZfcoAASTMwVmenDF2w==","signatures":[{"sig":"MEQCIChgReQbyT4U6DVjslDsRAXv2q3Y/co3TCoWdCAhTDN6AiBIWAgpejPOxDQK8XERJ5FFA8Ippwm9AzR1Chm/1Gpa0Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23211},"type":"module","exports":{".":"./src/index.ts","./sandbox":"./src/sandbox-entry.ts"},"gitHead":"39de1f3b6f7dd88be3f9cbbd646f2b7835040cbd","release":{"plugins":["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator","@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"],"branches":["main"]},"scripts":{"test":"vitest run","version":"node -p \"require('./package.json').version\"","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"adrianoamalfi","email":"adrianoamalfi@gmail.com"},"repository":{"url":"git+https://github.com/adrianoamalfi/emdash-plugin-cookie-consent.git","type":"git"},"_npmVersion":"11.14.1","description":"A fully customizable cookie consent banner plugin for EmDash CMS with category-level opt-in, theming, and an admin settings panel.","directories":{},"_nodeVersion":"22.22.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.1.2","typescript":"^6.0.3","semantic-release":"^25.0.3","@semantic-release/git":"^10.0.1","@semantic-release/changelog":"^6.0.3"},"peerDependencies":{"emdash":"^0.12.0"},"_npmOperationalInternal":{"tmp":"tmp/emdash-plugin-cookie-consent_1.0.0_1778740489584_0.022292455214299345","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"emdash-plugin-cookie-consent","version":"1.0.1","description":"A fully customizable cookie consent banner plugin for EmDash CMS with category-level opt-in, theming, and an admin settings panel.","type":"module","license":"MIT","author":{"name":"Adriano Amalfi","email":"adrianoamalfi@gmail.com","url":"https://adrianoamalfi.com"},"repository":{"type":"git","url":"git+https://github.com/adrianoamalfi/emdash-plugin-cookie-consent.git"},"keywords":["emdash","emdash-plugin","cookie-consent","cookies","gdpr","privacy","cms"],"exports":{".":"./src/index.ts","./sandbox":"./src/sandbox-entry.ts"},"scripts":{"typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","version":"node -p \"require('./package.json').version\""},"publishConfig":{"access":"public"},"release":{"branches":["main"],"plugins":["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator","@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"]},"peerDependencies":{"emdash":"^0.12.0"},"devDependencies":{"@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","semantic-release":"^25.0.3","typescript":"^6.0.3","vitest":"^3.1.2"},"gitHead":"391710ad624d14cfcaa20d5a4416387a2d308ebf","_id":"emdash-plugin-cookie-consent@1.0.1","bugs":{"url":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent/issues"},"homepage":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent#readme","_nodeVersion":"22.22.2","_npmVersion":"11.14.1","dist":{"integrity":"sha512-hSMA5J4jV+G8QLu0yF4TRBsxy7xCbHxVIW1Q4TdkZQZQ2l2QXZ4ArPTcG4f8rI4sZIyfOooIWWG2sWhJ/B2iLw==","shasum":"bc95f096ac2c32e0224bec67146481771325c5d8","tarball":"https://registry.npmjs.org/emdash-plugin-cookie-consent/-/emdash-plugin-cookie-consent-1.0.1.tgz","fileCount":5,"unpackedSize":24579,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDbffodX/mJhmM6jwXf3p1RlvYdu0NYQhQKQAzbjChFkAiBPsDDgBCxKGfMCtZv69rTrcGN3ouqxPP7OA7/JmPNpUg=="}]},"_npmUser":{"name":"adrianoamalfi","email":"adrianoamalfi@gmail.com"},"directories":{},"maintainers":[{"name":"adrianoamalfi","email":"adrianoamalfi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/emdash-plugin-cookie-consent_1.0.1_1778762391098_0.9515418886167395"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T06:34:49.511Z","modified":"2026-05-14T12:39:51.374Z","1.0.0":"2026-05-14T06:34:49.727Z","1.0.1":"2026-05-14T12:39:51.253Z"},"bugs":{"url":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent/issues"},"author":{"name":"Adriano Amalfi","email":"adrianoamalfi@gmail.com","url":"https://adrianoamalfi.com"},"license":"MIT","homepage":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent#readme","keywords":["emdash","emdash-plugin","cookie-consent","cookies","gdpr","privacy","cms"],"repository":{"type":"git","url":"git+https://github.com/adrianoamalfi/emdash-plugin-cookie-consent.git"},"description":"A fully customizable cookie consent banner plugin for EmDash CMS with category-level opt-in, theming, and an admin settings panel.","maintainers":[{"name":"adrianoamalfi","email":"adrianoamalfi@gmail.com"}],"readme":"# emdash-plugin-cookie-consent\n\n[![CI](https://github.com/adrianoamalfi/emdash-plugin-cookie-consent/actions/workflows/ci.yml/badge.svg)](https://github.com/adrianoamalfi/emdash-plugin-cookie-consent/actions/workflows/ci.yml)\n[![Security](https://github.com/adrianoamalfi/emdash-plugin-cookie-consent/actions/workflows/security.yml/badge.svg)](https://github.com/adrianoamalfi/emdash-plugin-cookie-consent/actions/workflows/security.yml)\n[![npm version](https://img.shields.io/npm/v/emdash-plugin-cookie-consent)](https://www.npmjs.com/package/emdash-plugin-cookie-consent)\n\nA fully customizable cookie consent banner plugin for [EmDash CMS](https://emdashcms.com) with category-level opt-in, theming, and an admin settings panel.\n\n## Features\n\n- **4 consent categories** — Necessary (always required), Functional, Analytics, Marketing\n- **Granular opt-in** — Accept All, Reject All, or custom selection via inline panel\n- **Cookie persistence** — 365-day expiry with `SameSite=Lax`\n- **Admin settings panel** — Full UI at `/_emdash/admin`\n- **6 built-in themes** — Dark, Light, Midnight, Clean, Warm, Forest, plus custom colors\n- **Mobile responsive** — Collapses to stacked layout on small screens\n- **No external dependencies** — Zero runtime deps, all CSS/JS inlined (~5 KB per page)\n\n## Installation\n\n```bash\nnpm install emdash-plugin-cookie-consent\n```\n\n## Usage\n\nRegister the plugin in `astro.config.mjs`:\n\n```ts\nimport { cookieConsentPlugin } from \"emdash-plugin-cookie-consent\";\n\nexport default defineConfig({\n  integrations: [\n    emdash({\n      plugins: [cookieConsentPlugin()],\n    }),\n  ],\n});\n```\n\nThe banner appears automatically on all pages using `EmDashHead` and `EmDashBodyEnd`.\n\n## How It Works\n\nThe plugin injects three fragments via the `page:fragments` hook:\n\n1. **CSS** (`<style>` in `<head>`) — Banner and toggle styles\n2. **Gate script** (`<script>` in `<head>`) — Reads `cookie_consent` cookie into `window.__ccConsent`\n3. **Banner script** (`<script>` at `<body:end>`) — Shows/hides the banner, handles Accept/Reject/Customize/Save\n\nAll logic runs client-side. No server state required beyond plugin settings.\n\n## Admin Settings\n\nNavigate to `/_emdash/admin` → **Cookie Consent**.\n\n| Field | Default | Description |\n|---|---|---|\n| Enabled | `true` | Show/hide the banner |\n| Consent Message | *(customizable)* | Banner body text |\n| Accept/Reject/Customize Label | *(customizable)* | Button text |\n| Footer Reopen Text | `Cookie Preferences` | Floating reopen button |\n| Privacy Policy URL | *(empty)* | Optional link |\n| Banner Position | `bottom` | `top` or `bottom` |\n| Color Theme | `dark` | Preset or `custom` |\n| Background / Text / Button Color | *(per theme)* | Manual colors in custom mode |\n\nEach category (Necessary, Functional, Analytics, Marketing) has configurable name and description fields.\n\n## Integrating Third-Party Scripts\n\nThis plugin manages **consent preferences** — it does not block or load scripts. Use `window.__ccConsent` to gate your own scripts:\n\n```ts\ninterface ConsentState {\n  necessary: true;       // Always active\n  functional: boolean;\n  analytics: boolean;\n  marketing: boolean;\n}\n```\n\n### Quick example — Google Analytics 4\n\n```html\n<script is:inline>\n  if (window.__ccConsent?.analytics) {\n    // Load gtag.js only when analytics consented\n  }\n</script>\n```\n\n### Category reference\n\n| Service | Category | Notes |\n|---|---|---|\n| Google Analytics 4 | `analytics` | Load gtag.js conditionally |\n| Google Tag Manager | `analytics` / `marketing` | Map consent types |\n| Facebook / Meta Pixel | `marketing` | Load fbevents.js conditionally |\n| YouTube / Vimeo embeds | `functional` | Click-to-load or conditional iframe |\n| Stripe / payment | `necessary` | Always load |\n\nSee the integration examples above for GA4, GTM, Facebook Pixel, and YouTube.\n\n## Development\n\n```bash\ngit clone https://github.com/adrianoamalfi/emdash-plugin-cookie-consent.git\ncd emdash-plugin-cookie-consent\nnpm install\nnpm run typecheck\nnpm test\n```\n\n## Versioning\n\nThis project follows [Semantic Versioning](https://semver.org/). Releases are automated via [semantic-release](https://github.com/semantic-release/semantic-release) — pushing `fix:`, `feat:`, or `BREAKING CHANGE:` commits to `main` triggers a release to npm and GitHub.\n\n## License\n\nMIT © Adriano Amalfi\n","readmeFilename":"README.md"}