gscan 4.13.1 → 4.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/package-json.js +22 -2
- package/package.json +1 -1
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy of Ghost defaults for https://github.com/TryGhost/Ghost/blob/e25f1df0ae551c447da0d319bae06eadf9665444/core/frontend/services/theme-engine/config/defaults.json
|
|
3
|
+
*/
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
posts_per_page: 5,
|
|
6
|
+
card_assets: {
|
|
7
|
+
exclude: ['bookmark', 'gallery']
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* Extracts the package.json JSON content. Note that this function never throws,
|
|
3
13
|
* even when there is a JSON parsing error.
|
|
14
|
+
* This function uses the default `config` property to match Ghost implementation.
|
|
4
15
|
* @param {Object} theme The theme to extract package.json from.
|
|
5
16
|
* @returns {Object} The content of the package.json file, or `null` if
|
|
6
17
|
* something happened (no file, JSON parsing error...).
|
|
@@ -9,12 +20,21 @@ function getJSON(theme) {
|
|
|
9
20
|
let packageJSON = theme.files.find(item => item.file === 'package.json');
|
|
10
21
|
if (packageJSON && packageJSON.content) {
|
|
11
22
|
try {
|
|
12
|
-
|
|
23
|
+
const json = JSON.parse(packageJSON.content);
|
|
24
|
+
|
|
25
|
+
// Use the default .config and allow it to be overwritten
|
|
26
|
+
const content = Object.assign({}, json, {
|
|
27
|
+
config: Object.assign({}, defaultConfig, json.config)
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return content;
|
|
13
31
|
} catch (e) {
|
|
14
32
|
// Do nothing here
|
|
15
33
|
}
|
|
16
34
|
}
|
|
17
|
-
return
|
|
35
|
+
return {
|
|
36
|
+
config: defaultConfig
|
|
37
|
+
};
|
|
18
38
|
}
|
|
19
39
|
|
|
20
40
|
module.exports = getJSON;
|