@contentstorage/core 0.3.23 → 0.3.25
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/lib/contentManagement.js +10 -23
- package/dist/types.d.ts +10 -0
- package/package.json +1 -1
|
@@ -36,36 +36,23 @@ pathString, fallbackValue) {
|
|
|
36
36
|
console.warn(msg);
|
|
37
37
|
return fallbackValue;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// so we might need a cast here if strict typing is desired for `value`.
|
|
45
|
-
// But the consumer's augmentation makes CustomContentStructure specific.
|
|
46
|
-
const keys = pathString.split('.');
|
|
47
|
-
let current = activeContent;
|
|
48
|
-
for (const key of keys) {
|
|
49
|
-
if (current && typeof current === 'object' && key in current) {
|
|
50
|
-
current = current[key];
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
const msg = `[Contentstorage] getText: Path "${String(pathString)}" not found in loaded content.`;
|
|
54
|
-
console.warn(msg);
|
|
55
|
-
return fallbackValue;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (typeof current === 'string') {
|
|
59
|
-
return current;
|
|
39
|
+
const keys = pathString.split('.');
|
|
40
|
+
let current = activeContent;
|
|
41
|
+
for (const key of keys) {
|
|
42
|
+
if (current && typeof current === 'object' && key in current) {
|
|
43
|
+
current = current[key];
|
|
60
44
|
}
|
|
61
45
|
else {
|
|
62
|
-
const msg = `[Contentstorage] getText:
|
|
46
|
+
const msg = `[Contentstorage] getText: Path "${String(pathString)}" not found in loaded content.`;
|
|
63
47
|
console.warn(msg);
|
|
64
48
|
return fallbackValue;
|
|
65
49
|
}
|
|
66
50
|
}
|
|
51
|
+
if (typeof current === 'string') {
|
|
52
|
+
return current;
|
|
53
|
+
}
|
|
67
54
|
else {
|
|
68
|
-
const msg = `[Contentstorage] getText:
|
|
55
|
+
const msg = `[Contentstorage] getText: Value at path "${String(pathString)}" is not a string (actual type: ${typeof current}).`;
|
|
69
56
|
console.warn(msg);
|
|
70
57
|
return fallbackValue;
|
|
71
58
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -22,3 +22,13 @@ export type LanguageCode = 'SQ' | 'BE' | 'BS' | 'BG' | 'HR' | 'CS' | 'DA' | 'NL'
|
|
|
22
22
|
*/
|
|
23
23
|
export interface ContentStructure {
|
|
24
24
|
}
|
|
25
|
+
declare global {
|
|
26
|
+
namespace JSX {
|
|
27
|
+
interface IntrinsicElements {
|
|
28
|
+
'cs-text': {
|
|
29
|
+
'data-contentstorage-id': string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@contentstorage/core",
|
|
3
3
|
"author": "Kaido Hussar <kaidohus@gmail.com>",
|
|
4
4
|
"homepage": "https://contentstorage.app",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.25",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Fetch content from contentstorage and generate TypeScript types",
|
|
8
8
|
"module": "dist/index.js",
|