Skip to content

Commit

Permalink
Merge pull request #16 from ArturBa/chore/3.0.0-rc
Browse files Browse the repository at this point in the history
update to vanilla cookie consent 3.0.0
  • Loading branch information
cngJo authored Feb 5, 2024
2 parents 518da6b + 2692244 commit 94a0525
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 64 deletions.
103 changes: 53 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
{
"name": "@jop-software/astro-cookieconsent",
"version": "2.0.0",
"description": "vanilla-cookieconsent for astro",
"type": "module",
"license": "GPL-3.0-or-later",
"types": "./dist/main.d.ts",
"keywords": [
"astro-integration",
"astro-component",
"cookieconsent",
"consent",
"tracking",
"gdpr"
],
"contributors": [
{
"name": "Johannes Przymusinski",
"email": "[email protected]",
"url": "https://jop-software.de"
}
],
"exports": {
".": {
"import": "./dist/astro-cookieconsent.es.js",
"require": "./dist/astro-cookieconsent.umd.js"
}
"name": "@jop-software/astro-cookieconsent",
"version": "2.0.0",
"description": "vanilla-cookieconsent for astro",
"type": "module",
"license": "GPL-3.0-or-later",
"types": "./dist/main.d.ts",
"keywords": [
"astro-integration",
"astro-component",
"cookieconsent",
"consent",
"tracking",
"gdpr"
],
"contributors": [
{
"name": "Johannes Przymusinski",
"email": "[email protected]",
"url": "https://jop-software.de"
},
"main": "./dist/astro-cookieconsent.umd.js",
"module": "./dist/astro-cookieconsent.es.js",
"files": [
"dist"
],
"scripts": {
"build": "vite build && tsc --emitDeclarationOnly",
"build:watch": "vite build --watch",
"dev": "vite",
"prettier:check": "prettier --check src",
"prettier:write": "prettier --write src"
},
"devDependencies": {
"astro": "^1.8.0",
"prettier": "^2.7.1",
"typescript": "^4.9.4",
"vite": "^4.0.3"
},
"repository": {
"type": "git",
"url": "https://github.com/jop-software/astro-cookieconsent"
},
"peerDependencies": {
"vanilla-cookieconsent": "^2.9.1"
{
"name": "Artur Bauer"
}
],
"exports": {
".": {
"import": "./dist/astro-cookieconsent.es.js",
"require": "./dist/astro-cookieconsent.umd.js"
}
},
"main": "./dist/astro-cookieconsent.umd.js",
"module": "./dist/astro-cookieconsent.es.js",
"files": [
"dist"
],
"scripts": {
"build": "vite build && tsc --emitDeclarationOnly",
"build:watch": "vite build --watch",
"dev": "vite",
"prettier:check": "prettier --check src",
"prettier:write": "prettier --write src"
},
"devDependencies": {
"astro": "^1.8.0",
"prettier": "^2.7.1",
"typescript": "^4.9.4",
"vite": "^4.0.3"
},
"repository": {
"type": "git",
"url": "https://github.com/jop-software/astro-cookieconsent"
},
"peerDependencies": {
"vanilla-cookieconsent": "^3.0.0"
}
}
21 changes: 7 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
import * as CookieConsent from "vanilla-cookieconsent";
import { type AstroIntegration } from "astro";
import { type CookieConsentConfig } from "vanilla-cookieconsent";

const createPlugin = (config: UserConfig) => {
const createPlugin = (config: CookieConsentConfig): AstroIntegration => {
return {
name: "@jop-software/astro-cookieconsent",
hooks: {
"astro:config:setup": async ({ injectScript }: any) => {
"astro:config:setup": async ({ injectScript }) => {
injectScript(
"page",
"import 'vanilla-cookieconsent';"
"import * as cookieConsent from 'vanilla-cookieconsent';"
);
injectScript(
"page-ssr",
"import 'vanilla-cookieconsent/dist/cookieconsent.css';"
);
injectScript(
"page",
`window.cookieConsentConfiguration = ${JSON.stringify(config)}`
);
injectScript("page", `window.cookieConsent = initCookieConsent();`);
injectScript(
"page",
`window.cookieConsent.run(window.cookieConsentConfiguration);`
);
injectScript("page", `cookieConsent.run(${JSON.stringify(config)});`);
},
},
};
};

export type { CookieConsent };
export type { CookieConsentConfig };

export default createPlugin;

0 comments on commit 94a0525

Please sign in to comment.