From bf941a2efd098573405cddbf2ae8601ac758f083 Mon Sep 17 00:00:00 2001 From: Orest Bida Date: Tue, 29 Aug 2023 22:35:22 +0200 Subject: [PATCH] Docs: update code blocks/examples --- docs/essential/getting-started.md | 35 +++++++++++------------ docs/reference/configuration-reference.md | 9 +++--- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/docs/essential/getting-started.md b/docs/essential/getting-started.md index 1fb57931..6ab06626 100644 --- a/docs/essential/getting-started.md +++ b/docs/essential/getting-started.md @@ -8,12 +8,23 @@ You can download/import the plugin using one of the following methods:
1. Install via [NPM](https://www.npmjs.com/package/vanilla-cookieconsent). - ```shell + + ::: code-group + + ```sh [npm] npm i vanilla-cookieconsent@next - yarn add vanilla-cookieconsent@next + ``` + + ```sh [pnpm] pnpm add vanilla-cookieconsent@next ``` + ```sh [yarn] + yarn add vanilla-cookieconsent@next + ``` + + ::: + Special thanks to [Till Sanders](https://github.com/tillsanders) for bringing the plugin on npm! 2. Use the CDN hosted version. @@ -36,16 +47,12 @@ Here are some of the most common setups to help you get up and running. ### HTML Import `cookieconsent.css` and `cookieconsent.js` files respectively in the head and body section. Create a new file — `cookieconsent-init.js` — and import it in the body section. -```html{9,13-14} +```html{5,9-10} - - - - - + @@ -175,15 +182,7 @@ The most basic configuration requires the definition of the following 2 fields: * **Basic example config.**
```javascript - { - - onConsent: function () { - // consent was given - }, - - onChange: function () { - // user changed his/her preferences - }, + CookieConsent.run({ categories: { necessary: { @@ -252,7 +251,7 @@ The most basic configuration requires the definition of the following 2 fields: } } } - } + }); ``` You should now see the consent modal pop up! diff --git a/docs/reference/configuration-reference.md b/docs/reference/configuration-reference.md index 9fccefaf..35babedb 100644 --- a/docs/reference/configuration-reference.md +++ b/docs/reference/configuration-reference.md @@ -189,11 +189,10 @@ Number of days before the cookie expires. ```javascript cc.run({ cookie: { - expiresAfterDays: (acceptType) => { - if(acceptType === 'all') - return 365.25; - - return 182; + expiresAfterDays: acceptType => { + return acceptType === 'all' + ? 365.25 + : 182; } } })