-
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.
- Loading branch information
0 parents
commit f749d4e
Showing
7 changed files
with
792 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/node_modules | ||
/package-lock.json | ||
/pnpm-lock.yaml | ||
/dist | ||
|
||
/.idea | ||
/.vscode |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Astro Cookie Consent | ||
|
||
Astro wrapper for [vanilla-cookieconsent](https://github.com/orestbida/cookieconsent) |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@jop-software/astro-cookieconsent", | ||
"version": "1.0.0", | ||
"description": "vanilla-cookieconsent for astro", | ||
"type": "module", | ||
"license": "GPL-3.0-or-later", | ||
"types": "./dist/index.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" | ||
} | ||
}, | ||
"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" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as CookieConsent from "vanilla-cookieconsent"; | ||
|
||
const createPlugin = (config: UserConfig) => { | ||
return { | ||
name: "@jop-software/astro-cookie-consent", | ||
hooks: { | ||
"astro:config:setup": async ({ injectScript }: any) => { | ||
injectScript("page", "import 'vanilla-cookieconsent'; import 'vanilla-cookieconsent/dist/cookieconsent.css';"); | ||
injectScript("page", `window.cookieConentConfiguration = ${JSON.stringify(config)}`); | ||
injectScript("page", `window.cookieConent = initCookieConsent();`) | ||
injectScript("page", `window.cookieConent.run(window.cookieConentConfiguration);`) | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
export type { CookieConsent }; | ||
|
||
export default createPlugin; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"module": "ES2022", | ||
"outDir": "./dist", | ||
"target": "ES2021", | ||
"typeRoots": [ | ||
"./node_modules/vanilla-cookieconsent/types" | ||
] | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// vite.config.js | ||
import { resolve } from 'path' | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
build: { | ||
lib: { | ||
// Could also be a dictionary or array of multiple entry points | ||
entry: resolve(__dirname, 'src/main.ts'), | ||
name: 'AstroCookieconsent', | ||
// the proper extensions will be added | ||
fileName: (format) => `astro-cookieconsent.${format}.js`, | ||
|
||
}, | ||
}, | ||
}) |