-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ArturBa/chore/3.0.0-rc
update to vanilla cookie consent 3.0.0
- Loading branch information
Showing
2 changed files
with
60 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |