decap-cms-core 3.6.3 → 3.7.0
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/dist/decap-cms-core.js +26 -26
- package/dist/decap-cms-core.js.LICENSE.txt +22 -4
- package/dist/decap-cms-core.js.map +1 -1
- package/dist/esm/actions/config.js +57 -49
- package/dist/esm/actions/editorialWorkflow.js +4 -4
- package/dist/esm/actions/entries.js +8 -14
- package/dist/esm/actions/mediaLibrary.js +6 -11
- package/dist/esm/actions/search.js +2 -2
- package/dist/esm/actions/status.js +2 -8
- package/dist/esm/backend.js +70 -79
- package/dist/esm/bootstrap.js +2 -2
- package/dist/esm/components/App/App.js +28 -34
- package/dist/esm/components/App/Header.js +32 -39
- package/dist/esm/components/Collection/Collection.js +45 -48
- package/dist/esm/components/Collection/CollectionSearch.js +76 -81
- package/dist/esm/components/Collection/CollectionTop.js +1 -2
- package/dist/esm/components/Collection/Entries/Entries.js +2 -4
- package/dist/esm/components/Collection/Entries/EntriesCollection.js +25 -29
- package/dist/esm/components/Collection/Entries/EntriesSearch.js +34 -38
- package/dist/esm/components/Collection/Entries/EntryCard.js +8 -13
- package/dist/esm/components/Collection/Entries/EntryListing.js +72 -76
- package/dist/esm/components/Collection/FilterControl.js +1 -1
- package/dist/esm/components/Collection/GroupControl.js +1 -1
- package/dist/esm/components/Collection/NestedCollection.js +50 -53
- package/dist/esm/components/Collection/Sidebar.js +35 -38
- package/dist/esm/components/Collection/SortControl.js +3 -3
- package/dist/esm/components/Collection/ViewStyleControl.js +1 -2
- package/dist/esm/components/Editor/Editor.js +197 -201
- package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +79 -87
- package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +75 -86
- package/dist/esm/components/Editor/EditorControlPane/Widget.js +226 -228
- package/dist/esm/components/Editor/EditorInterface.js +69 -80
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +1 -2
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +20 -28
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +163 -161
- package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +4 -8
- package/dist/esm/components/Editor/EditorToolbar.js +335 -347
- package/dist/esm/components/Editor/withWorkflow.js +5 -6
- package/dist/esm/components/MediaLibrary/MediaLibrary.js +304 -294
- package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +40 -46
- package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +1 -2
- package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +8 -13
- package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +3 -3
- package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +1 -2
- package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +3 -6
- package/dist/esm/components/UI/DragDrop.js +15 -23
- package/dist/esm/components/UI/ErrorBoundary.js +23 -25
- package/dist/esm/components/UI/Modal.js +10 -12
- package/dist/esm/components/UI/Notifications.js +4 -8
- package/dist/esm/components/UI/SettingsDropdown.js +4 -8
- package/dist/esm/components/Workflow/Workflow.js +19 -20
- package/dist/esm/components/Workflow/WorkflowCard.js +2 -4
- package/dist/esm/components/Workflow/WorkflowList.js +105 -113
- package/dist/esm/constants/configSchema.js +18 -16
- package/dist/esm/formats/formats.js +11 -12
- package/dist/esm/formats/frontmatter.js +17 -21
- package/dist/esm/formats/yaml.js +2 -6
- package/dist/esm/index.js +3 -7
- package/dist/esm/integrations/providers/algolia/implementation.js +12 -14
- package/dist/esm/integrations/providers/assetStore/implementation.js +10 -12
- package/dist/esm/lib/formatters.js +13 -17
- package/dist/esm/lib/i18n.js +35 -33
- package/dist/esm/lib/phrases.js +2 -2
- package/dist/esm/lib/registry.js +35 -35
- package/dist/esm/lib/serializeEntryValues.js +3 -3
- package/dist/esm/lib/stega.js +142 -0
- package/dist/esm/lib/urlHelper.js +16 -18
- package/dist/esm/mediaLibrary.js +3 -4
- package/dist/esm/reducers/collections.js +26 -42
- package/dist/esm/reducers/combinedReducer.js +3 -6
- package/dist/esm/reducers/config.js +3 -7
- package/dist/esm/reducers/editorialWorkflow.js +5 -9
- package/dist/esm/reducers/entries.js +33 -35
- package/dist/esm/reducers/entryDraft.js +2 -2
- package/dist/esm/reducers/integrations.js +8 -14
- package/dist/esm/reducers/mediaLibrary.js +18 -20
- package/dist/esm/reducers/notifications.js +4 -8
- package/dist/esm/types/immutable.js +7 -1
- package/dist/esm/valueObjects/AssetProxy.js +1 -9
- package/dist/esm/valueObjects/EditorComponent.js +18 -25
- package/dist/esm/valueObjects/Entry.js +2 -2
- package/index.d.ts +2 -0
- package/package.json +8 -11
- package/src/actions/__tests__/config.spec.js +3 -3
- package/src/actions/config.ts +3 -1
- package/src/actions/editorialWorkflow.ts +1 -1
- package/src/actions/entries.ts +1 -1
- package/src/actions/search.ts +1 -1
- package/src/backend.ts +8 -1
- package/src/components/App/App.js +5 -0
- package/src/components/App/Header.js +3 -0
- package/src/components/Collection/Collection.js +5 -0
- package/src/components/Collection/CollectionSearch.js +5 -0
- package/src/components/Collection/Entries/EntriesCollection.js +4 -1
- package/src/components/Collection/Entries/EntriesSearch.js +4 -1
- package/src/components/Collection/Entries/EntryListing.js +5 -0
- package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +0 -4
- package/src/components/Collection/NestedCollection.js +6 -1
- package/src/components/Collection/Sidebar.js +5 -0
- package/src/components/Editor/Editor.js +4 -1
- package/src/components/Editor/EditorControlPane/EditorControl.js +7 -1
- package/src/components/Editor/EditorControlPane/Widget.js +5 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +1 -1
- package/src/components/Editor/EditorToolbar.js +3 -0
- package/src/components/Editor/__tests__/Editor.spec.js +3 -4
- package/src/components/Editor/__tests__/__snapshots__/Editor.spec.js.snap +5 -5
- package/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap +708 -393
- package/src/components/MediaLibrary/MediaLibrary.js +5 -1
- package/src/components/MediaLibrary/MediaLibraryModal.js +1 -1
- package/src/components/UI/ErrorBoundary.js +6 -1
- package/src/components/UI/Modal.js +3 -0
- package/src/components/Workflow/Workflow.js +3 -0
- package/src/components/Workflow/WorkflowList.js +5 -0
- package/src/constants/__tests__/configSchema.spec.js +1 -1
- package/src/formats/formats.ts +1 -1
- package/src/integrations/providers/algolia/implementation.js +2 -2
- package/src/integrations/providers/assetStore/implementation.js +2 -1
- package/src/lib/formatters.ts +4 -1
- package/src/lib/i18n.ts +3 -1
- package/src/lib/phrases.js +1 -1
- package/src/lib/serializeEntryValues.js +1 -1
- package/src/lib/stega.ts +145 -0
- package/src/lib/urlHelper.ts +4 -1
- package/src/mediaLibrary.ts +1 -1
- package/src/reducers/collections.ts +2 -1
- package/src/reducers/editorialWorkflow.ts +1 -1
- package/src/reducers/entries.ts +6 -1
- package/src/reducers/entryDraft.js +1 -1
- package/src/types/immutable.ts +10 -0
- package/src/types/redux.ts +2 -0
- package/src/valueObjects/EditorComponent.js +1 -1
- package/src/valueObjects/Entry.ts +1 -1
|
@@ -19,11 +19,6 @@ function _extendableBuiltin(cls) {
|
|
|
19
19
|
}
|
|
20
20
|
return ExtendableBuiltin;
|
|
21
21
|
}
|
|
22
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
26
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
22
|
import AJV from 'ajv';
|
|
28
23
|
import { select, uniqueItemProperties, instanceof as instanceOf, prohibited } from 'ajv-keywords/dist/keywords';
|
|
29
24
|
import ajvErrors from 'ajv-errors';
|
|
@@ -53,9 +48,10 @@ const i18n = {
|
|
|
53
48
|
default_locale: localeType
|
|
54
49
|
}
|
|
55
50
|
};
|
|
56
|
-
const i18nRoot =
|
|
51
|
+
const i18nRoot = {
|
|
52
|
+
...i18n,
|
|
57
53
|
required: ['structure', 'locales']
|
|
58
|
-
}
|
|
54
|
+
};
|
|
59
55
|
const i18nCollection = {
|
|
60
56
|
oneOf: [{
|
|
61
57
|
type: 'boolean'
|
|
@@ -126,7 +122,9 @@ function fieldsConfig() {
|
|
|
126
122
|
select: {
|
|
127
123
|
$data: '0/widget'
|
|
128
124
|
},
|
|
129
|
-
selectCases:
|
|
125
|
+
selectCases: {
|
|
126
|
+
...getWidgetSchemas()
|
|
127
|
+
},
|
|
130
128
|
required: ['name']
|
|
131
129
|
},
|
|
132
130
|
uniqueItemProperties: ['name']
|
|
@@ -554,17 +552,20 @@ export function validateConfig(config) {
|
|
|
554
552
|
const path = e.instancePath || '';
|
|
555
553
|
let newError = e;
|
|
556
554
|
if (path.endsWith('/fields')) {
|
|
557
|
-
newError =
|
|
555
|
+
newError = {
|
|
556
|
+
...e,
|
|
558
557
|
message: 'fields names must be unique'
|
|
559
|
-
}
|
|
558
|
+
};
|
|
560
559
|
} else if (path.endsWith('/files')) {
|
|
561
|
-
newError =
|
|
560
|
+
newError = {
|
|
561
|
+
...e,
|
|
562
562
|
message: 'files names must be unique'
|
|
563
|
-
}
|
|
563
|
+
};
|
|
564
564
|
} else if (path.endsWith('/collections')) {
|
|
565
|
-
newError =
|
|
565
|
+
newError = {
|
|
566
|
+
...e,
|
|
566
567
|
message: 'collections names must be unique'
|
|
567
|
-
}
|
|
568
|
+
};
|
|
568
569
|
}
|
|
569
570
|
return newError;
|
|
570
571
|
}
|
|
@@ -573,9 +574,10 @@ export function validateConfig(config) {
|
|
|
573
574
|
const path = e.instancePath || '';
|
|
574
575
|
let newError = e;
|
|
575
576
|
if (/fields\/\d+\/pattern\/\d+/.test(path)) {
|
|
576
|
-
newError =
|
|
577
|
+
newError = {
|
|
578
|
+
...e,
|
|
577
579
|
message: 'must be a regular expression'
|
|
578
|
-
}
|
|
580
|
+
};
|
|
579
581
|
}
|
|
580
582
|
return newError;
|
|
581
583
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import _get from "lodash/get";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
1
|
import { List } from 'immutable';
|
|
2
|
+
import get from 'lodash/get';
|
|
8
3
|
import yamlFormatter from './yaml';
|
|
9
4
|
import tomlFormatter from './toml';
|
|
10
5
|
import jsonFormatter from './json';
|
|
@@ -22,7 +17,10 @@ export const formatExtensions = {
|
|
|
22
17
|
'yaml-frontmatter': 'md'
|
|
23
18
|
};
|
|
24
19
|
export function getFormatExtensions() {
|
|
25
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
...formatExtensions,
|
|
22
|
+
...getCustomFormatsExtensions()
|
|
23
|
+
};
|
|
26
24
|
}
|
|
27
25
|
export const extensionFormatters = {
|
|
28
26
|
yml: yamlFormatter,
|
|
@@ -34,7 +32,7 @@ export const extensionFormatters = {
|
|
|
34
32
|
html: FrontmatterInfer
|
|
35
33
|
};
|
|
36
34
|
function formatByName(name, customDelimiter) {
|
|
37
|
-
const formatters =
|
|
35
|
+
const formatters = {
|
|
38
36
|
yml: yamlFormatter,
|
|
39
37
|
yaml: yamlFormatter,
|
|
40
38
|
toml: tomlFormatter,
|
|
@@ -42,8 +40,9 @@ function formatByName(name, customDelimiter) {
|
|
|
42
40
|
frontmatter: FrontmatterInfer,
|
|
43
41
|
'json-frontmatter': frontmatterJSON(customDelimiter),
|
|
44
42
|
'toml-frontmatter': frontmatterTOML(customDelimiter),
|
|
45
|
-
'yaml-frontmatter': frontmatterYAML(customDelimiter)
|
|
46
|
-
|
|
43
|
+
'yaml-frontmatter': frontmatterYAML(customDelimiter),
|
|
44
|
+
...getCustomFormatsFormatters()
|
|
45
|
+
};
|
|
47
46
|
if (name in formatters) {
|
|
48
47
|
return formatters[name];
|
|
49
48
|
}
|
|
@@ -68,7 +67,7 @@ export function resolveFormat(collection, entry) {
|
|
|
68
67
|
if (filePath) {
|
|
69
68
|
const fileExtension = filePath.split('.').pop();
|
|
70
69
|
if (fileExtension) {
|
|
71
|
-
return
|
|
70
|
+
return get(extensionFormatters, fileExtension);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -76,7 +75,7 @@ export function resolveFormat(collection, entry) {
|
|
|
76
75
|
// collection config, infer the format from that extension.
|
|
77
76
|
const extension = collection.get('extension');
|
|
78
77
|
if (extension) {
|
|
79
|
-
return
|
|
78
|
+
return get(extensionFormatters, extension);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
// If no format is specified and it cannot be inferred, return the default.
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
const _excluded = ["body"];
|
|
2
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
1
|
import matter from 'gray-matter';
|
|
10
2
|
import tomlFormatter from './toml';
|
|
11
3
|
import yamlFormatter from './yaml';
|
|
@@ -101,25 +93,28 @@ export function getFormatOpts(format, customDelimiter) {
|
|
|
101
93
|
}
|
|
102
94
|
export class FrontmatterFormatter {
|
|
103
95
|
constructor(format, customDelimiter) {
|
|
104
|
-
_defineProperty(this, "format", void 0);
|
|
105
96
|
this.format = getFormatOpts(format, customDelimiter);
|
|
106
97
|
}
|
|
107
98
|
fromFile(content) {
|
|
108
99
|
const format = this.format || inferFrontmatterFormat(content);
|
|
109
|
-
const result = matter(content,
|
|
110
|
-
engines: parsers
|
|
111
|
-
|
|
100
|
+
const result = matter(content, {
|
|
101
|
+
engines: parsers,
|
|
102
|
+
...format
|
|
103
|
+
});
|
|
112
104
|
// in the absent of a body when serializing an entry we use an empty one
|
|
113
105
|
// when calling `toFile`, so we don't want to add it when parsing.
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
return {
|
|
107
|
+
...result.data,
|
|
108
|
+
...(result.content.trim() && {
|
|
109
|
+
body: result.content
|
|
110
|
+
})
|
|
111
|
+
};
|
|
117
112
|
}
|
|
118
113
|
toFile(data, sortedKeys, comments) {
|
|
119
114
|
const {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
body = '',
|
|
116
|
+
...meta
|
|
117
|
+
} = data;
|
|
123
118
|
|
|
124
119
|
// Stringify to YAML if the format was not set
|
|
125
120
|
const format = this.format || getFormatOpts(Languages.YAML);
|
|
@@ -128,13 +123,14 @@ export class FrontmatterFormatter {
|
|
|
128
123
|
// change detection logic
|
|
129
124
|
// https://github.com/jonschlinkert/gray-matter/issues/96
|
|
130
125
|
const trimLastLineBreak = body.slice(-1) !== '\n';
|
|
131
|
-
const file = matter.stringify(body, meta,
|
|
126
|
+
const file = matter.stringify(body, meta, {
|
|
132
127
|
engines: parsers,
|
|
133
128
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
134
129
|
// @ts-ignore `sortedKeys` is not recognized by gray-matter, so it gets passed through to the parser
|
|
135
130
|
sortedKeys,
|
|
136
|
-
comments
|
|
137
|
-
|
|
131
|
+
comments,
|
|
132
|
+
...format
|
|
133
|
+
});
|
|
138
134
|
return trimLastLineBreak && file.slice(-1) === '\n' ? file.slice(0, -1) : file;
|
|
139
135
|
}
|
|
140
136
|
}
|
package/dist/esm/formats/yaml.js
CHANGED
|
@@ -3,14 +3,13 @@ import { sortKeys } from './helpers';
|
|
|
3
3
|
function addComments(items, comments, prefix = '') {
|
|
4
4
|
items.forEach(item => {
|
|
5
5
|
if (item.key !== undefined) {
|
|
6
|
-
var _item$value;
|
|
7
6
|
const itemKey = item.key.toString();
|
|
8
7
|
const key = prefix ? `${prefix}.${itemKey}` : itemKey;
|
|
9
8
|
if (comments[key]) {
|
|
10
9
|
const value = comments[key].split('\\n').join('\n ');
|
|
11
10
|
item.commentBefore = ` ${value}`;
|
|
12
11
|
}
|
|
13
|
-
if (Array.isArray(
|
|
12
|
+
if (Array.isArray(item.value?.items)) {
|
|
14
13
|
addComments(item.value.items, comments, key);
|
|
15
14
|
}
|
|
16
15
|
}
|
|
@@ -44,10 +43,7 @@ export default {
|
|
|
44
43
|
toFile(data, sortedKeys = [], comments = {}) {
|
|
45
44
|
const contents = yaml.createNode(data);
|
|
46
45
|
addComments(contents.items, comments);
|
|
47
|
-
contents.items.sort(sortKeys(sortedKeys, item =>
|
|
48
|
-
var _item$key;
|
|
49
|
-
return (_item$key = item.key) === null || _item$key === void 0 ? void 0 : _item$key.toString();
|
|
50
|
-
}));
|
|
46
|
+
contents.items.sort(sortKeys(sortedKeys, item => item.key?.toString()));
|
|
51
47
|
const doc = new yaml.Document();
|
|
52
48
|
doc.contents = contents;
|
|
53
49
|
return doc.toString();
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
1
|
import bootstrap from './bootstrap';
|
|
7
2
|
import Registry from './lib/registry';
|
|
8
|
-
export const DecapCmsCore =
|
|
3
|
+
export const DecapCmsCore = {
|
|
4
|
+
...Registry,
|
|
9
5
|
init: bootstrap
|
|
10
|
-
}
|
|
6
|
+
};
|
|
11
7
|
export default DecapCmsCore;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
|
+
import flatten from 'lodash/flatten';
|
|
7
2
|
import { unsentRequest } from 'decap-cms-lib-util';
|
|
8
3
|
import { createEntry } from '../../../valueObjects/Entry';
|
|
9
4
|
import { selectEntrySlug } from '../../../reducers/collections';
|
|
@@ -31,11 +26,12 @@ export default class Algolia {
|
|
|
31
26
|
};
|
|
32
27
|
}
|
|
33
28
|
requestHeaders(headers = {}) {
|
|
34
|
-
return
|
|
29
|
+
return {
|
|
35
30
|
'X-Algolia-API-Key': this.apiKey,
|
|
36
31
|
'X-Algolia-Application-Id': this.applicationID,
|
|
37
|
-
'Content-Type': 'application/json'
|
|
38
|
-
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
...headers
|
|
34
|
+
};
|
|
39
35
|
}
|
|
40
36
|
parseJsonResponse(response) {
|
|
41
37
|
return response.json().then(json => {
|
|
@@ -60,9 +56,10 @@ export default class Algolia {
|
|
|
60
56
|
request(path, options = {}) {
|
|
61
57
|
const headers = this.requestHeaders(options.headers || {});
|
|
62
58
|
const url = this.urlFor(path, options);
|
|
63
|
-
return fetch(url,
|
|
59
|
+
return fetch(url, {
|
|
60
|
+
...options,
|
|
64
61
|
headers
|
|
65
|
-
})
|
|
62
|
+
}).then(response => {
|
|
66
63
|
const contentType = response.headers.get('Content-Type');
|
|
67
64
|
if (contentType && contentType.match(/json/)) {
|
|
68
65
|
return this.parseJsonResponse(response);
|
|
@@ -89,7 +86,7 @@ export default class Algolia {
|
|
|
89
86
|
});
|
|
90
87
|
}));
|
|
91
88
|
return {
|
|
92
|
-
entries:
|
|
89
|
+
entries: flatten(entries),
|
|
93
90
|
pagination: page
|
|
94
91
|
};
|
|
95
92
|
});
|
|
@@ -148,9 +145,10 @@ export default class Algolia {
|
|
|
148
145
|
page = page + 1;
|
|
149
146
|
while (page < nbPages) {
|
|
150
147
|
response = await this.request(`${this.searchURL}/indexes/${this.indexPrefix}${collection.get('name')}`, {
|
|
151
|
-
params:
|
|
148
|
+
params: {
|
|
149
|
+
...params,
|
|
152
150
|
page
|
|
153
|
-
}
|
|
151
|
+
}
|
|
154
152
|
});
|
|
155
153
|
hits = [...hits, ...response.hits];
|
|
156
154
|
page = page + 1;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
|
+
import pickBy from 'lodash/pickBy';
|
|
2
|
+
import trimEnd from 'lodash/trimEnd';
|
|
8
3
|
import { unsentRequest } from 'decap-cms-lib-util';
|
|
9
4
|
import { addParams } from '../../../lib/urlHelper';
|
|
10
5
|
const {
|
|
@@ -18,7 +13,7 @@ export default class AssetStore {
|
|
|
18
13
|
}
|
|
19
14
|
this.getToken = getToken;
|
|
20
15
|
this.shouldConfirmUpload = config.get('shouldConfirmUpload', false);
|
|
21
|
-
this.getSignedFormURL =
|
|
16
|
+
this.getSignedFormURL = trimEnd(config.get('getSignedFormURL'), '/');
|
|
22
17
|
}
|
|
23
18
|
parseJsonResponse(response) {
|
|
24
19
|
return response.json().then(json => {
|
|
@@ -41,7 +36,9 @@ export default class AssetStore {
|
|
|
41
36
|
return path;
|
|
42
37
|
}
|
|
43
38
|
requestHeaders(headers = {}) {
|
|
44
|
-
return
|
|
39
|
+
return {
|
|
40
|
+
...headers
|
|
41
|
+
};
|
|
45
42
|
}
|
|
46
43
|
confirmRequest(assetID) {
|
|
47
44
|
this.getToken().then(token => this.request(`${this.getSignedFormURL}/${assetID}`, {
|
|
@@ -58,16 +55,17 @@ export default class AssetStore {
|
|
|
58
55
|
async request(path, options = {}) {
|
|
59
56
|
const headers = this.requestHeaders(options.headers || {});
|
|
60
57
|
const url = this.urlFor(path, options);
|
|
61
|
-
const response = await fetch(url,
|
|
58
|
+
const response = await fetch(url, {
|
|
59
|
+
...options,
|
|
62
60
|
headers
|
|
63
|
-
})
|
|
61
|
+
});
|
|
64
62
|
const contentType = response.headers.get('Content-Type');
|
|
65
63
|
const isJson = contentType && contentType.match(/json/);
|
|
66
64
|
const content = isJson ? await this.parseJsonResponse(response) : response.text();
|
|
67
65
|
return content;
|
|
68
66
|
}
|
|
69
67
|
async retrieve(query, page, privateUpload) {
|
|
70
|
-
const params =
|
|
68
|
+
const params = pickBy({
|
|
71
69
|
search: query,
|
|
72
70
|
page,
|
|
73
71
|
filter: privateUpload ? 'private' : 'public'
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
|
+
import flow from 'lodash/flow';
|
|
2
|
+
import partialRight from 'lodash/partialRight';
|
|
3
|
+
import trimEnd from 'lodash/trimEnd';
|
|
4
|
+
import trimStart from 'lodash/trimStart';
|
|
10
5
|
import { stringTemplate } from 'decap-cms-lib-widgets';
|
|
11
6
|
import { stripIndent } from 'common-tags';
|
|
12
7
|
import { selectIdentifier, selectField, selectInferredField, getFileFromSlug } from '../reducers/collections';
|
|
@@ -36,7 +31,10 @@ export function commitMessageFormatter(type, config, {
|
|
|
36
31
|
authorLogin,
|
|
37
32
|
authorName
|
|
38
33
|
}, isOpenAuthoring) {
|
|
39
|
-
const templates =
|
|
34
|
+
const templates = {
|
|
35
|
+
...commitMessageTemplates,
|
|
36
|
+
...(config.backend.commit_messages || {})
|
|
37
|
+
};
|
|
40
38
|
const commitMessage = templates[type].replace(variableRegex, (_, variable) => {
|
|
41
39
|
switch (variable) {
|
|
42
40
|
case 'slug':
|
|
@@ -84,7 +82,7 @@ export function prepareSlug(slug) {
|
|
|
84
82
|
.replace(/[.]/g, '-');
|
|
85
83
|
}
|
|
86
84
|
export function getProcessSegment(slugConfig, ignoreValues) {
|
|
87
|
-
return value => ignoreValues && ignoreValues.includes(value) ? value :
|
|
85
|
+
return value => ignoreValues && ignoreValues.includes(value) ? value : flow([value => String(value), prepareSlug, partialRight(sanitizeSlug, slugConfig)])(value);
|
|
88
86
|
}
|
|
89
87
|
export function slugFormatter(collection, entryData, slugConfig) {
|
|
90
88
|
const slugTemplate = collection.get('slug') || '{{slug}}';
|
|
@@ -110,16 +108,14 @@ export function previewUrlFormatter(baseUrl, collection, slug, entry, slugConfig
|
|
|
110
108
|
if (!baseUrl) {
|
|
111
109
|
return;
|
|
112
110
|
}
|
|
113
|
-
const basePath =
|
|
111
|
+
const basePath = trimEnd(baseUrl, '/');
|
|
114
112
|
const isFileCollection = collection.get('type') === FILES;
|
|
115
113
|
const file = isFileCollection ? getFileFromSlug(collection, entry.get('slug')) : undefined;
|
|
116
114
|
function getPathTemplate() {
|
|
117
|
-
|
|
118
|
-
return (_file$get = file === null || file === void 0 ? void 0 : file.get('preview_path')) !== null && _file$get !== void 0 ? _file$get : collection.get('preview_path');
|
|
115
|
+
return file?.get('preview_path') ?? collection.get('preview_path');
|
|
119
116
|
}
|
|
120
117
|
function getDateField() {
|
|
121
|
-
|
|
122
|
-
return (_file$get2 = file === null || file === void 0 ? void 0 : file.get('preview_path_date_field')) !== null && _file$get2 !== void 0 ? _file$get2 : collection.get('preview_path_date_field');
|
|
118
|
+
return file?.get('preview_path_date_field') ?? collection.get('preview_path_date_field');
|
|
123
119
|
}
|
|
124
120
|
|
|
125
121
|
/**
|
|
@@ -159,7 +155,7 @@ export function previewUrlFormatter(baseUrl, collection, slug, entry, slugConfig
|
|
|
159
155
|
}
|
|
160
156
|
throw err;
|
|
161
157
|
}
|
|
162
|
-
const previewPath =
|
|
158
|
+
const previewPath = trimStart(compiledPath, ' /');
|
|
163
159
|
return `${basePath}/${previewPath}`;
|
|
164
160
|
}
|
|
165
161
|
export function summaryFormatter(summaryTemplate, entry, collection) {
|
package/dist/esm/lib/i18n.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import _escapeRegExp from "lodash/escapeRegExp";
|
|
2
|
-
import _groupBy from "lodash/groupBy";
|
|
3
|
-
import _set from "lodash/set";
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
1
|
import { Map, List } from 'immutable';
|
|
2
|
+
import set from 'lodash/set';
|
|
3
|
+
import groupBy from 'lodash/groupBy';
|
|
4
|
+
import escapeRegExp from 'lodash/escapeRegExp';
|
|
10
5
|
import { selectEntrySlug } from '../reducers/collections';
|
|
11
6
|
export const I18N = 'i18n';
|
|
12
7
|
export let I18N_STRUCTURE = /*#__PURE__*/function (I18N_STRUCTURE) {
|
|
@@ -72,7 +67,7 @@ export function getFilePath(structure, extension, path, slug, locale) {
|
|
|
72
67
|
case I18N_STRUCTURE.MULTIPLE_FOLDERS:
|
|
73
68
|
return path.replace(`/${slug}`, `/${locale}/${slug}`);
|
|
74
69
|
case I18N_STRUCTURE.MULTIPLE_FILES:
|
|
75
|
-
return path.replace(new RegExp(`${
|
|
70
|
+
return path.replace(new RegExp(`${escapeRegExp(extension)}$`), `${locale}.${extension}`);
|
|
76
71
|
case I18N_STRUCTURE.SINGLE_FILE:
|
|
77
72
|
default:
|
|
78
73
|
return path;
|
|
@@ -132,24 +127,26 @@ export function getI18nFiles(collection, extension, entryDraft, entryToRaw, path
|
|
|
132
127
|
return map.set(locale, entryDraft.getIn(dataPath));
|
|
133
128
|
}, Map({}));
|
|
134
129
|
const draft = entryDraft.set('data', data);
|
|
135
|
-
return [
|
|
130
|
+
return [{
|
|
136
131
|
path: getFilePath(structure, extension, path, slug, locales[0]),
|
|
137
132
|
slug,
|
|
138
|
-
raw: entryToRaw(draft)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
raw: entryToRaw(draft),
|
|
134
|
+
...(newPath && {
|
|
135
|
+
newPath: getFilePath(structure, extension, newPath, slug, locales[0])
|
|
136
|
+
})
|
|
137
|
+
}];
|
|
142
138
|
}
|
|
143
139
|
const dataFiles = locales.map(locale => {
|
|
144
140
|
const dataPath = getDataPath(locale, defaultLocale);
|
|
145
141
|
const draft = entryDraft.set('data', entryDraft.getIn(dataPath));
|
|
146
|
-
return
|
|
142
|
+
return {
|
|
147
143
|
path: getFilePath(structure, extension, path, slug, locale),
|
|
148
144
|
slug,
|
|
149
|
-
raw: draft.get('data') ? entryToRaw(draft) : ''
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
raw: draft.get('data') ? entryToRaw(draft) : '',
|
|
146
|
+
...(newPath && {
|
|
147
|
+
newPath: getFilePath(structure, extension, newPath, slug, locale)
|
|
148
|
+
})
|
|
149
|
+
};
|
|
153
150
|
}).filter(dataFile => dataFile.raw);
|
|
154
151
|
return dataFiles;
|
|
155
152
|
}
|
|
@@ -165,11 +162,12 @@ export function getI18nBackup(collection, entry, entryToRaw) {
|
|
|
165
162
|
return acc;
|
|
166
163
|
}
|
|
167
164
|
const draft = entry.set('data', data);
|
|
168
|
-
return
|
|
165
|
+
return {
|
|
166
|
+
...acc,
|
|
169
167
|
[locale]: {
|
|
170
168
|
raw: entryToRaw(draft)
|
|
171
169
|
}
|
|
172
|
-
}
|
|
170
|
+
};
|
|
173
171
|
}, {});
|
|
174
172
|
return i18nBackup;
|
|
175
173
|
}
|
|
@@ -178,11 +176,12 @@ export function formatI18nBackup(i18nBackup, formatRawData) {
|
|
|
178
176
|
raw
|
|
179
177
|
}]) => {
|
|
180
178
|
const entry = formatRawData(raw);
|
|
181
|
-
return
|
|
179
|
+
return {
|
|
180
|
+
...acc,
|
|
182
181
|
[locale]: {
|
|
183
182
|
data: entry.data
|
|
184
183
|
}
|
|
185
|
-
}
|
|
184
|
+
};
|
|
186
185
|
}, {});
|
|
187
186
|
return i18n;
|
|
188
187
|
}
|
|
@@ -197,16 +196,17 @@ function mergeValues(collection, structure, defaultLocale, values) {
|
|
|
197
196
|
value
|
|
198
197
|
}) => {
|
|
199
198
|
const dataPath = getLocaleDataPath(locale);
|
|
200
|
-
return
|
|
199
|
+
return set(acc, dataPath, value.data);
|
|
201
200
|
}, {});
|
|
202
201
|
const path = normalizeFilePath(structure, defaultEntry.value.path, defaultLocale);
|
|
203
202
|
const slug = selectEntrySlug(collection, path);
|
|
204
|
-
const entryValue =
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
const entryValue = {
|
|
204
|
+
...defaultEntry.value,
|
|
205
|
+
raw: '',
|
|
206
|
+
...i18n,
|
|
207
207
|
path,
|
|
208
208
|
slug
|
|
209
|
-
}
|
|
209
|
+
};
|
|
210
210
|
return entryValue;
|
|
211
211
|
}
|
|
212
212
|
function mergeSingleFileValue(entryValue, defaultLocale, locales) {
|
|
@@ -215,17 +215,19 @@ function mergeSingleFileValue(entryValue, defaultLocale, locales) {
|
|
|
215
215
|
locale: l,
|
|
216
216
|
value: entryValue.data[l]
|
|
217
217
|
})).filter(e => e.value).reduce((acc, e) => {
|
|
218
|
-
return
|
|
218
|
+
return {
|
|
219
|
+
...acc,
|
|
219
220
|
[e.locale]: {
|
|
220
221
|
data: e.value
|
|
221
222
|
}
|
|
222
|
-
}
|
|
223
|
+
};
|
|
223
224
|
}, {});
|
|
224
|
-
return
|
|
225
|
+
return {
|
|
226
|
+
...entryValue,
|
|
225
227
|
data,
|
|
226
228
|
i18n,
|
|
227
229
|
raw: ''
|
|
228
|
-
}
|
|
230
|
+
};
|
|
229
231
|
}
|
|
230
232
|
export async function getI18nEntry(collection, extension, path, slug, getEntryValue) {
|
|
231
233
|
const {
|
|
@@ -259,7 +261,7 @@ export function groupEntries(collection, extension, entries) {
|
|
|
259
261
|
if (structure === I18N_STRUCTURE.SINGLE_FILE) {
|
|
260
262
|
return entries.map(e => mergeSingleFileValue(e, defaultLocale, locales));
|
|
261
263
|
}
|
|
262
|
-
const grouped =
|
|
264
|
+
const grouped = groupBy(entries.map(e => ({
|
|
263
265
|
locale: getLocaleFromPath(structure, extension, e.path),
|
|
264
266
|
value: e
|
|
265
267
|
})), ({
|
package/dist/esm/lib/phrases.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import merge from 'lodash/merge';
|
|
2
2
|
import { getLocale } from './registry';
|
|
3
3
|
export function getPhrases(locale) {
|
|
4
|
-
const phrases =
|
|
4
|
+
const phrases = merge({}, getLocale('en'), getLocale(locale));
|
|
5
5
|
return phrases;
|
|
6
6
|
}
|