Skip to content

Commit 4c0bd82

Browse files
Merge branch 'release/0.6.7'
2 parents 3b0ac19 + ddb49f6 commit 4c0bd82

File tree

5 files changed

+51
-7
lines changed

5 files changed

+51
-7
lines changed

example/app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ app.get('/', (req, res) => {
5858
const vueOptions = {
5959
head: {
6060
title: 'Page Title',
61-
61+
meta: [
62+
{
63+
property: 'og:title2',
64+
content: 'Page Title2'
65+
}
66+
]
6267
}
6368
}
6469
res.renderVue('main/main.vue', data, vueOptions)

package-lock.json

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "express-vue-renderer",
3-
"version": "0.6.6",
3+
"version": "0.6.7",
44
"description": "Rendering Engine for turning Vue files into Javascript Objects",
55
"homepage": "https://github.com/express-vue/express-vue-renderer",
66
"author": {
@@ -69,6 +69,7 @@
6969
"babel-preset-es2015": "^6.24.1",
7070
"camel-case": "^3.0.0",
7171
"clean-css": "^4.1.7",
72+
"dedupe": "^2.1.0",
7273
"deepmerge": "^1.5.1",
7374
"html-minifier": "^3.5.3",
7475
"lru-cache": "^4.1.1",

src/models/defaults.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
const LRU = require('lru-cache');
33
const path = require('path');
44
const deepmerge = require('deepmerge');
5+
const dedupe = require('dedupe');
56
const Layout = require('./layout');
67
const options = {
78
max: 500,
89
maxAge: 1000 * 60 * 60
910
};
1011
const lruCache = LRU(options);
1112

13+
function concatMerge(destinationArray, sourceArray) {
14+
let finalArray = destinationArray.concat(sourceArray);
15+
//Dedupes dupes... obviously... but theres a problem here
16+
return dedupe(finalArray);
17+
}
18+
1219
class Defaults {
1320
rootPath: string;
1421
component: string;
@@ -41,10 +48,10 @@ class Defaults {
4148
}
4249
}
4350
mergeVueObject(newVueObject: Object): void {
44-
this.vue = deepmerge(this.vue, newVueObject);
51+
this.vue = deepmerge(this.vue, newVueObject, { arrayMerge: concatMerge });
4552
}
4653
mergeDataObject(newDataObject: Object): void {
47-
this.data = deepmerge(this.data, newDataObject);
54+
this.data = deepmerge(this.data, newDataObject, { arrayMerge: concatMerge });
4855
}
4956
}
5057

tests/models/models.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ const options = {
2929
foo: true
3030
},
3131
vue: {
32-
title: 'bar'
32+
head: {
33+
title: 'bar',
34+
meta: [
35+
{foo: true}
36+
]
37+
}
38+
3339
}
3440
};
3541

@@ -70,5 +76,17 @@ test('Defaults data', t => {
7076
})
7177

7278
test('Defaults vue', t => {
73-
t.is(defaultObject.vue.title, 'bar');
79+
t.is(defaultObject.vue.head.title, 'bar');
80+
})
81+
82+
test('Merges VueObject', t => {
83+
const testVueObject = {
84+
head: {
85+
meta: [
86+
{bar: false}
87+
]
88+
}
89+
}
90+
defaultObject.mergeVueObject(testVueObject);
91+
t.deepEqual(defaultObject.vue.head.meta, [{foo: true}, {bar: false}]);
7492
})

0 commit comments

Comments
 (0)