@kirchdev/duxt 0.1.1-dev.14-636388d → 0.1.1-dev.15-83cfebe

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://www.schemastore.org/package.json",
3
3
  "name": "@kirchdev/duxt",
4
- "version": "0.1.1-dev.14-636388d",
4
+ "version": "0.1.1-dev.15-83cfebe",
5
5
  "description": "Nuxt documentation layer on Content v3 — multi-repo, versioned docs from one compact source list.",
6
6
  "keywords": [
7
7
  "content-v3",
@@ -22,6 +22,7 @@ import type {
22
22
  DuxtSourcesOptions
23
23
  } from './sources-resolve';
24
24
  import {
25
+ assertCollectionIdentities,
25
26
  expandSources,
26
27
  identifier,
27
28
  resolveSources,
@@ -539,6 +540,7 @@ export function resolveGeneratedSections(
539
540
  }
540
541
  });
541
542
 
543
+ assertCollectionIdentities([...resolved, ...generated]);
542
544
  return generated;
543
545
  }
544
546
 
@@ -631,6 +631,7 @@ export function resolveSources(
631
631
  });
632
632
  }
633
633
 
634
+ assertCollectionIdentities(resolved);
634
635
  return resolved;
635
636
  }
636
637
 
@@ -906,3 +907,41 @@ function isInsidePrefix(path: string, prefix: string): boolean {
906
907
 
907
908
  return path === prefix || path.startsWith(`${prefix}/`);
908
909
  }
910
+
911
+ /** Validate names before any collection map can overwrite a declaration. */
912
+ export function assertCollectionIdentities(
913
+ entries: DuxtResolvedSource[]
914
+ ): void {
915
+ const taken = new Map<string, string>();
916
+ const claim = (name: string, declaration: string) => {
917
+ const previous = taken.get(name);
918
+ if (previous !== undefined) {
919
+ throw new Error(
920
+ `duxt: collection "${name}" is claimed by both ${previous} and ${declaration}. ` +
921
+ 'Give one declaration a distinct `slug` or `label`.'
922
+ );
923
+ }
924
+ taken.set(name, declaration);
925
+ };
926
+
927
+ for (const entry of entries) {
928
+ const kind = entry.generated
929
+ ? `generated section "${entry.generated.label}"`
930
+ : 'documentation';
931
+ claim(
932
+ entry.collection,
933
+ `${kind} "${entry.path}" at "${entry.prefix || '/'}"` +
934
+ (entry.locale ? ` (locale "${entry.locale}")` : '')
935
+ );
936
+ }
937
+
938
+ // Shared partials are one declaration per language, even across sources.
939
+ const locales = new Set(
940
+ entries
941
+ .filter((entry) => !entry.generated)
942
+ .map((entry) => (entry.isDefaultLocale ? undefined : entry.locale))
943
+ );
944
+ for (const locale of locales) {
945
+ claim(partialsCollection(locale), `partials for "${locale ?? 'default'}"`);
946
+ }
947
+ }