Skip to content

Commit

Permalink
Docs: update code blocks/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
orestbida committed Aug 29, 2023
1 parent 26bf431 commit bf941a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
35 changes: 17 additions & 18 deletions docs/essential/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@ You can download/import the plugin using one of the following methods:
<br>

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.
Expand All @@ -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}
<html>
<head>
<!-- head content -->
<!-- Typical CSS loading -->
<!-- <link rel="stylesheet" href="path-to-cookieconsent.css"> -->
<!-- Deferred CSS loading (recommended) -->
<link rel="stylesheet" href="path-to-cookieconsent.css" media="print" onload="this.media='all'">
<link rel="stylesheet" href="path-to-cookieconsent.css">
</head>
<body>
<!-- body content -->
Expand Down Expand Up @@ -175,15 +182,7 @@ The most basic configuration requires the definition of the following 2 fields:
* **Basic example config.** <br>
```javascript
{
onConsent: function () {
// consent was given
},
onChange: function () {
// user changed his/her preferences
},
CookieConsent.run({
categories: {
necessary: {
Expand Down Expand Up @@ -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!
Expand Down
9 changes: 4 additions & 5 deletions docs/reference/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
})
Expand Down

0 comments on commit bf941a2

Please sign in to comment.