@bond-london/gatsby-plugin-cookie-scripts
v2.0.1
Published
Gatsby plugin to load scripts when a cookie is accepted
Downloads
3
Maintainers
Readme
@bond-london/gatsby-plugin-cookie-scripts
Manage cookies and tracking scripts
Features
- Optionally installs tracking scripts when cookies are accepted
- Can track page changes (ie route updates)
How to use
Install package
yarn add @bond-london/gatsby-plugin-cookie-scripts
Configure the plugin
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/locales`,
name: `locale`,
},
},
{
resolve: `@bond-london/gatsby-plugin-cms-i18next`,
options: {
localeJsonSourceName: `locale`, // name given to `gatsby-source-filesystem` plugin.
defaultLanguage: `en`,
// if you are using Helmet, you must include siteUrl, and make sure you add http:https
siteUrl: `https://example.com/`,
// you can pass any i18next options
i18nextOptions: {
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
keySeparator: false,
nsSeparator: false,
},
pages: [
{
matchPath: "/:lang?/blog/:uid",
getLanguageFromPath: true,
excludeLanguages: ["es"],
},
{
matchPath: "/preview",
languages: ["en"],
},
],
},
},
];
License
MIT © Bond London