{"id":49875740,"url":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent","last_synced_at":"2026-05-19T16:01:09.929Z","repository":{"id":357625140,"uuid":"1237815752","full_name":"adrianoamalfi/emdash-plugin-cookie-consent","owner":"adrianoamalfi","description":"A fully customizable cookie consent banner plugin for EmDash CMS with category-level opt-in, theming, and an admin settings panel.","archived":false,"fork":false,"pushed_at":"2026-05-14T21:53:54.000Z","size":338,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-17T14:48:09.120Z","etag":null,"topics":["astro","cms","cookie-consent","emdash","emdash-plugin","gdpr","privacy","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adrianoamalfi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"adrianoamalfi"}},"created_at":"2026-05-13T14:34:01.000Z","updated_at":"2026-05-14T14:04:37.000Z","dependencies_parsed_at":"2026-05-16T13:03:00.308Z","dependency_job_id":null,"html_url":"https://github.com/adrianoamalfi/emdash-plugin-cookie-consent","commit_stats":null,"previous_names":["adrianoamalfi/emdash-plugin-cookie-consent"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/adrianoamalfi/emdash-plugin-cookie-consent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianoamalfi%2Femdash-plugin-cookie-consent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianoamalfi%2Femdash-plugin-cookie-consent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianoamalfi%2Femdash-plugin-cookie-consent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianoamalfi%2Femdash-plugin-cookie-consent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adrianoamalfi","download_url":"https://codeload.github.com/adrianoamalfi/emdash-plugin-cookie-consent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianoamalfi%2Femdash-plugin-cookie-consent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33223667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T15:49:41.270Z","status":"ssl_error","status_checked_at":"2026-05-19T15:49:22.917Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astro","cms","cookie-consent","emdash","emdash-plugin","gdpr","privacy","typescript"],"created_at":"2026-05-15T12:14:46.965Z","updated_at":"2026-05-19T16:01:09.862Z","avatar_url":"https://github.com/adrianoamalfi.png","language":"TypeScript","funding_links":["https://github.com/sponsors/adrianoamalfi"],"categories":[],"sub_categories":[],"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## Prerequisites\n\n- EmDash CMS `^0.12.0`\n- Your base layout must include `\u003cEmDashHead /\u003e` and `\u003cEmDashBodyEnd /\u003e` — the plugin injects CSS and scripts via these hooks. Without them the banner won't render.\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\";\nimport emdash from \"emdash/astro\";\nimport { defineConfig } from \"astro/config\";\n\nexport default defineConfig({\n  integrations: [\n    emdash({\n      plugins: [cookieConsentPlugin()],\n      // database and storage remain unchanged\n    }),\n  ],\n});\n```\n\nThe banner appears automatically on all public pages — no per-page code required.\n\n## How It Works\n\nThe plugin injects three fragments via the `page:fragments` hook:\n\n1. **CSS** (`\u003cstyle\u003e` in `\u003chead\u003e`) — Banner and toggle styles\n2. **Gate script** (`\u003cscript\u003e` in `\u003chead\u003e`) — Reads `cookie_consent` cookie into `window.__ccConsent`\n3. **Banner script** (`\u003cscript\u003e` at `\u003cbody:end\u003e`) — 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\u003cscript is:inline\u003e\n  if (window.__ccConsent?.analytics) {\n    // Load gtag.js only when analytics consented\n  }\n\u003c/script\u003e\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianoamalfi%2Femdash-plugin-cookie-consent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrianoamalfi%2Femdash-plugin-cookie-consent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianoamalfi%2Femdash-plugin-cookie-consent/lists"}