@xleddyl/nuxt-cms 0.1.43 → 0.1.44

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
3
  "configKey": "cms",
4
- "version": "0.1.43",
4
+ "version": "0.1.44",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -154,16 +154,22 @@ function validateConfig(config, i18n) {
154
154
  for (const [path, override] of Object.entries(entry.overrides ?? {})) {
155
155
  const oat = `${at}, override '${path}'`;
156
156
  if (known.size && !known.has(path)) errors.push(`${oat}: '${path}' is not a page path`);
157
- for (const key of Object.keys(override)) {
158
- if (Object.hasOwn(entry.fields ?? {}, key))
157
+ for (const [key, field] of Object.entries(override)) {
158
+ const shared = Object.hasOwn(entry.fields ?? {}, key);
159
+ if (field && shared)
159
160
  errors.push(`${oat}: field '${key}' is already declared for every page`);
161
+ if (!field && !shared)
162
+ errors.push(
163
+ `${oat}: field '${key}' is not declared for every page, nothing to remove`
164
+ );
160
165
  if (key === PAGE_PATH_FIELD)
161
166
  errors.push(`${oat}: '${PAGE_PATH_FIELD}' is a reserved field name on pages`);
162
167
  }
163
168
  }
164
169
  const declared = /* @__PURE__ */ new Map();
165
- for (const [path, override] of Object.entries(entry.overrides ?? {})) {
170
+ for (const override of Object.values(entry.overrides ?? {})) {
166
171
  for (const [key, field] of Object.entries(override)) {
172
+ if (!field) continue;
167
173
  const seen = declared.get(key);
168
174
  if (seen && seen !== field.type) {
169
175
  errors.push(
@@ -106,7 +106,7 @@ export interface CmsEntry {
106
106
  exclude?: string[];
107
107
  order?: string[];
108
108
  labels?: Record<string, string>;
109
- overrides?: Record<string, Record<string, FieldConfig>>;
109
+ overrides?: Record<string, Record<string, FieldConfig | null>>;
110
110
  pages?: CmsPageRoute[];
111
111
  table?: CmsTable;
112
112
  }
@@ -119,7 +119,7 @@ export declare function pageLabelFromPath(path: string): string;
119
119
  export declare function pageParentPath(path: string): string | undefined;
120
120
  export declare function pageRoutes(entry: CmsEntry): CmsPageRoute[];
121
121
  export declare function pageRouteOf(entry: CmsEntry, key: string): CmsPageRoute | undefined;
122
- export declare function pageOverrideFields(entry: CmsEntry, path: string): Record<string, FieldConfig>;
122
+ export declare function pageOverrideFields(entry: CmsEntry, path: string): Record<string, FieldConfig | null>;
123
123
  export declare function pageFields(entry: CmsEntry, path: string): Record<string, FieldConfig>;
124
124
  export declare function pageAllFields(entry: CmsEntry): Record<string, FieldConfig>;
125
125
  type EntryLike = Pick<CmsEntry, 'fields'> & Partial<Pick<CmsEntry, 'kind' | 'overrides'>>;
@@ -213,7 +213,7 @@ export interface CmsPageInput extends CmsEntryInputBase {
213
213
  exclude?: string[];
214
214
  order?: string[];
215
215
  labels?: Record<string, string>;
216
- overrides?: Record<string, Record<string, CmsFieldInput>>;
216
+ overrides?: Record<string, Record<string, CmsFieldInput | null>>;
217
217
  }
218
218
  export type CmsEntryInput = CmsCollectionInput | CmsSingleInput | CmsPageInput;
219
219
  export type CmsConfigInput = Record<string, CmsEntryInput>;
@@ -216,13 +216,18 @@ export function pageOverrideFields(entry, path) {
216
216
  return entry.overrides?.[path] ?? {};
217
217
  }
218
218
  export function pageFields(entry, path) {
219
- return { ...entry.fields, ...pageOverrideFields(entry, path) };
219
+ const fields = { ...entry.fields };
220
+ for (const [key, field] of Object.entries(pageOverrideFields(entry, path))) {
221
+ if (field) fields[key] = field;
222
+ else delete fields[key];
223
+ }
224
+ return fields;
220
225
  }
221
226
  export function pageAllFields(entry) {
222
227
  const fields = { ...entry.fields };
223
228
  for (const override of Object.values(entry.overrides ?? {})) {
224
229
  for (const [key, field] of Object.entries(override)) {
225
- if (!fields[key]) fields[key] = field;
230
+ if (field && !fields[key]) fields[key] = field;
226
231
  }
227
232
  }
228
233
  return fields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
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)",