diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30468b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,101 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..7543271 --- /dev/null +++ b/.npmignore @@ -0,0 +1,12 @@ +logs +*.log +node_modules +*.un~ +yarn.lock +package-lock.json +flow-typed +coverage +decls +examples +.gitattributes +*.code-workspace diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2bd4304 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Pittica S.r.l.s. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c7d735 --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# pittica/gatsby-plugin-cookiehub + +![License](https://img.shields.io/github/license/pittica/gatsby-plugin-cookiehub) +![Version](https://img.shields.io/github/package-json/v/pittica/gatsby-plugin-cookiehub) +![Release](https://img.shields.io/github/v/release/pittica/gatsby-plugin-cookiehub) +![GitHub package.json dependency version (dev dep on branch)](https://img.shields.io/github/package-json/dependency-version/pittica/gatsby-plugin-cookiehub/dev/gatsby) +![GitHub package.json dependency version (dev dep on branch)](https://img.shields.io/github/package-json/dependency-version/pittica/gatsby-plugin-cookiehub/dev/react) +[![npm](https://img.shields.io/npm/v/@pittica/gatsby-plugin-cookiehub)](https://www.npmjs.com/package/@pittica/gatsby-plugin-cookiehub) + +## Description + +[CookieHub](https://www.cookiehub.com/) plugin for [GatsbyJS](https://www.gatsbyjs.org/). + +## Install + +[![npm](https://img.shields.io/npm/v/@pittica/gatsby-plugin-cookiehub)](https://www.npmjs.com/package/@pittica/gatsby-plugin-cookiehub) + +```shell +npm install @pittica/gatsby-plugin-cookiehub +``` + +## Usage + +The plugin provides integration for [CookieHub](https://www.cookiehub.com/) site. + +## Configuration + +Edit your **gatsby-config.js**. + +```javascript +module.exports = { + plugins: [ + { + resolve: `@pittica/gatsby-plugin-cookiehub`, + options: { + code: CODE, + debug: false, + cookie: 'pittica-cookiehub', + } + }, + ], +} +``` +### Options + +* #### key + Description: CookieHub domain code. + + Required: **YES**. + + Type: **String**. +* #### debug + Description: A value indicating whether run CookieHub in debug/development mode. + + Required: **NO**. + + Type: **Boolean**. +* #### cookie + Description: The prefix of the cookie name. + + Required: **NO**. + + Type: **String**. + + +## Copyright + +(c) 2021, Pittaca S.r.l.s. diff --git a/gatsby-node.js b/gatsby-node.js new file mode 100644 index 0000000..12a8469 --- /dev/null +++ b/gatsby-node.js @@ -0,0 +1,9 @@ +exports.pluginOptionsSchema = ({ Joi }) => { + return Joi.object({ + code: Joi.string().required().description(`CookieHub domain code.`), + debug: Joi.boolean() + .description(`A value indicating whether run CookieHub in debug/development mode.`) + .default(false), + cookie: Joi.string().description(`The prefix of the cookie name.`).default('pittica-cookiehub') + }); +}; diff --git a/gatsby-plugin-cookiehub.code-workspace b/gatsby-plugin-cookiehub.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/gatsby-plugin-cookiehub.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/gatsby-ssr.js b/gatsby-ssr.js new file mode 100644 index 0000000..80063fb --- /dev/null +++ b/gatsby-ssr.js @@ -0,0 +1,22 @@ +export const onRenderBody = ({ setHeadComponents }, { cookie, code, debug }) => { + return setHeadComponents([ +