Skip to content

Commit ae1b344

Browse files
authored
Merge pull request #37 from cdt105/master
Update to match the Kentico Kontent configuration and allow for preview mode
2 parents d487f11 + b9c71b3 commit ae1b344

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ npm i rxjs --save (because this is a peer dependency of the Kentico Kontent Deli
2121
- Add `kentico-kontent-nuxt-module` to `modules` section of `nuxt.config.js`
2222

2323
```js
24-
2524
/*
2625
** Nuxt.js modules
2726
*/
@@ -32,7 +31,9 @@ npm i rxjs --save (because this is a peer dependency of the Kentico Kontent Deli
3231
projectId: 'xxxx-xxx-xxxx-xxxx-xxxxx',
3332
enableAdvancedLogging: false,
3433
previewApiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
35-
enablePreviewMode: true,
34+
globalQueryConfig: {
35+
usePreviewMode: true, // Queries the Delivery Preview API.
36+
},
3637
baseUrl: 'https://custom.uri/api/KenticoKontentProxy',
3738
securedApiKey: 'xxx',
3839
enableSecuredMode: true

lib/module.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ module.exports = function kenticokontent (moduleOptions) {
55
projectId: process.env.KENTICOKONTENT_PROJECTID || '',
66
previewApiKey: process.env.KENTICOKONTENT_PREVIEWAPIKEY || null,
77
enableAdvancedLogging: process.env.KENTICOKONTENT_ENABLEADVANCEDLOGGING || false,
8-
enablePreviewMode: process.env.KENTICOKONTENT_ENABLEPREVIEWMODE || false,
8+
globalQueryConfig: {
9+
usePreviewMode: process.env.KENTICOKONTENT_ENABLEPREVIEWMODE || false
10+
},
911
defaultLanguage: process.env.KENTICOKONTENT_DEFAULTLANGUAGE || null,
1012
retryAttempts: process.env.KENTICOKONTENT_RETRYATTEMPTS || null,
1113
baseUrl: process.env.KENTICOKONTENT_BASEURL || null,

lib/templates/plugin.template.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ import CacheService from '../services/CacheService'
44
export default (ctx, inject) => {
55
// Create new delivery client Instance
66
let settings = JSON.parse('KENTICOOPTIONS')
7+
8+
// Adds customHeaders if not already set
9+
if(!settings.globalQueryConfig.customHeaders)
10+
{
11+
settings.globalQueryConfig.customHeaders = []
12+
}
713

8-
// Add tracking header
9-
settings = Object.assign({}, settings, {
10-
globalQueryConfig: {
11-
customHeaders: [
12-
{ header: 'X-KC-SOURCE', value: 'kentico-kontent-nuxt-module' }
13-
]
14-
}
15-
})
14+
// Adds X-KC-SOURCE to identify this module is in use
15+
settings.globalQueryConfig.customHeaders.push(
16+
{ header: 'X-KC-SOURCE', value: 'kentico-kontent-nuxt-module' }
17+
);
1618

1719
const deliveryClient = new DeliveryClient(settings)
1820

0 commit comments

Comments
 (0)