Skip to content

Commit 60a3d62

Browse files
Merge pull request #68 from express-vue/feature/deepmerge
fixes array join on deepmerge
2 parents 6e79f38 + 33b68e5 commit 60a3d62

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)