@xleddyl/nuxt-cms 0.1.41 → 0.1.43
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/README.md +5 -4
- package/dist/module.json +1 -1
- package/dist/module.mjs +424 -104
- package/dist/runtime/app/composables/cms-entry-disabled.d.ts +23 -0
- package/dist/runtime/app/composables/cms-entry-disabled.js +23 -0
- package/dist/runtime/app/composables/cms-entry.d.ts +23 -0
- package/dist/runtime/app/composables/cms-entry.js +67 -0
- package/dist/runtime/app/layouts/cms-admin.vue +5 -0
- package/dist/runtime/app/pages/admin-collection.vue +44 -1
- package/dist/runtime/app/pages/admin-entry.vue +14 -6
- package/dist/runtime/server/api/collection.get.js +19 -0
- package/dist/runtime/server/api/item.delete.js +4 -1
- package/dist/runtime/server/api/item.get.js +13 -2
- package/dist/runtime/server/api/item.put.js +14 -1
- package/dist/runtime/server/utils/graphql.js +21 -4
- package/dist/runtime/server/utils/registry.d.ts +3 -2
- package/dist/runtime/server/utils/registry.js +14 -3
- package/dist/runtime/server/utils/relations.js +4 -3
- package/dist/runtime/shared/graphql-sdl.js +13 -2
- package/dist/runtime/shared/index.d.ts +43 -6
- package/dist/runtime/shared/index.js +49 -2
- package/package.json +1 -1
|
@@ -129,7 +129,7 @@ export function pickTranslatedMedia(values, locale, defaultLocale) {
|
|
|
129
129
|
return values[locale] || values[defaultLocale] || Object.values(values).find(Boolean) || null;
|
|
130
130
|
}
|
|
131
131
|
export function translatableMediaKeys(entry) {
|
|
132
|
-
return Object.entries(entry
|
|
132
|
+
return Object.entries(entryFieldsFor(entry)).filter(([, field]) => isTranslatableMediaField(field)).map(([key]) => key);
|
|
133
133
|
}
|
|
134
134
|
export function encodeEntryTranslatableMedia(entry, values) {
|
|
135
135
|
const keys = translatableMediaKeys(entry);
|
|
@@ -156,7 +156,7 @@ export function isMultiSelect(field) {
|
|
|
156
156
|
return field.type === "select" && !!field.multiple;
|
|
157
157
|
}
|
|
158
158
|
export function translatableFieldKeys(entry) {
|
|
159
|
-
return Object.entries(entry
|
|
159
|
+
return Object.entries(entryFieldsFor(entry)).filter(([, field]) => isTranslatableField(field)).map(([key]) => key);
|
|
160
160
|
}
|
|
161
161
|
export function translatableBlockFieldKeys(block) {
|
|
162
162
|
return Object.entries(block.fields).filter(([, field]) => isTranslatableField(field)).map(([key]) => key);
|
|
@@ -184,6 +184,53 @@ export function localizeBlocks(field, value, locale, defaultLocale) {
|
|
|
184
184
|
if (!Array.isArray(value)) return value;
|
|
185
185
|
return value.map((item) => localizeBlock(field, item, locale, defaultLocale));
|
|
186
186
|
}
|
|
187
|
+
export const PAGE_PATH_FIELD = "path";
|
|
188
|
+
export function isPageEntry(entry) {
|
|
189
|
+
return entry.kind === "page";
|
|
190
|
+
}
|
|
191
|
+
export function pageSegments(path) {
|
|
192
|
+
return path.split("/").filter(Boolean);
|
|
193
|
+
}
|
|
194
|
+
export function pageKeyFromPath(path) {
|
|
195
|
+
const words = pageSegments(path).flatMap((segment) => segment.split("-"));
|
|
196
|
+
if (!words.length) return "home";
|
|
197
|
+
return words.map((word, index) => index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
198
|
+
}
|
|
199
|
+
export function pageLabelFromPath(path) {
|
|
200
|
+
const last = pageSegments(path).pop();
|
|
201
|
+
if (!last) return "Home";
|
|
202
|
+
return last.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
203
|
+
}
|
|
204
|
+
export function pageParentPath(path) {
|
|
205
|
+
const segments = pageSegments(path);
|
|
206
|
+
if (segments.length < 2) return void 0;
|
|
207
|
+
return `/${segments.slice(0, -1).join("/")}`;
|
|
208
|
+
}
|
|
209
|
+
export function pageRoutes(entry) {
|
|
210
|
+
return entry.pages ?? [];
|
|
211
|
+
}
|
|
212
|
+
export function pageRouteOf(entry, key) {
|
|
213
|
+
return pageRoutes(entry).find((route) => route.key === key);
|
|
214
|
+
}
|
|
215
|
+
export function pageOverrideFields(entry, path) {
|
|
216
|
+
return entry.overrides?.[path] ?? {};
|
|
217
|
+
}
|
|
218
|
+
export function pageFields(entry, path) {
|
|
219
|
+
return { ...entry.fields, ...pageOverrideFields(entry, path) };
|
|
220
|
+
}
|
|
221
|
+
export function pageAllFields(entry) {
|
|
222
|
+
const fields = { ...entry.fields };
|
|
223
|
+
for (const override of Object.values(entry.overrides ?? {})) {
|
|
224
|
+
for (const [key, field] of Object.entries(override)) {
|
|
225
|
+
if (!fields[key]) fields[key] = field;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return fields;
|
|
229
|
+
}
|
|
230
|
+
export function entryFieldsFor(entry, path) {
|
|
231
|
+
if (entry.kind !== "page") return entry.fields;
|
|
232
|
+
return path ? pageFields(entry, path) : pageAllFields(entry);
|
|
233
|
+
}
|
|
187
234
|
export function typeName(name) {
|
|
188
235
|
return name.replace(/(?:^|_)([a-z0-9])/gi, (_, c) => c.toUpperCase());
|
|
189
236
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xleddyl/nuxt-cms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.43",
|
|
4
4
|
"description": "Lightweight CMS that ships with your Nuxt app: runs on the Nitro server, content types defined in code, /cms admin panel, GraphQL API, SQLite or Postgres. No external CMS needed!",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Edoardo Alberti (https://github.com/xleddyl)",
|