@glossarist/concept-browser 0.7.105 → 0.7.107

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.
@@ -106,15 +106,15 @@ const engConcept = computed((): LocalizedConcept | null => {
106
106
  const primaryTerm = computed(() => getPreferredTerm(engConcept.value, conceptId.value));
107
107
  const renderedPrimaryTerm = computed(() => renderContent(primaryTerm.value));
108
108
 
109
- const managedStatus = computed(() => props.concept.status);
109
+ const managedStatus = computed(() => props.concept?.status);
110
110
 
111
- const conceptRefDomains = computed(() => props.concept.domains);
111
+ const conceptRefDomains = computed(() => props.concept?.domains ?? []);
112
112
 
113
- const conceptDates = computed(() => props.concept.dates);
113
+ const conceptDates = computed(() => props.concept?.dates ?? []);
114
114
 
115
- const conceptSources = computed(() => props.concept.sources);
115
+ const conceptSources = computed(() => props.concept?.sources ?? []);
116
116
 
117
- const conceptTags = computed(() => props.concept.tags ?? []);
117
+ const conceptTags = computed(() => props.concept?.tags ?? []);
118
118
 
119
119
  const factory = getFactory();
120
120
  const { ensureBibLoaded, bibResolver, nonVerbalRefResolver } = useRenderOptions(() => props.registerId);
@@ -216,39 +216,46 @@ function goAdjacent(id: string) {
216
216
 
217
217
  const conceptDomains = computed(() => {
218
218
  const domainMap = new Map<string, { slug: string; label: string; langs: string[]; conceptId?: string }>();
219
-
220
- for (const ref of conceptRefDomains.value) {
221
- const id = ref.conceptId ?? '';
222
- const label = id || ref.urn || '';
223
- if (label) {
224
- const slug = slugify(label);
225
- domainMap.set(slug, { slug, label, langs: [], conceptId: id });
219
+ try {
220
+ for (const ref of conceptRefDomains.value) {
221
+ const id = ref.conceptId ?? '';
222
+ const label = id || ref.urn || '';
223
+ if (label) {
224
+ const slug = slugify(label);
225
+ domainMap.set(slug, { slug, label, langs: [], conceptId: id });
226
+ }
226
227
  }
227
- }
228
228
 
229
- for (const lang of props.concept.languages) {
230
- const lc = props.concept.localization(lang);
231
- const domain = lc?.domain;
232
- if (domain) {
233
- const slug = slugify(domain);
234
- const existing = domainMap.get(slug);
235
- if (existing) {
236
- if (!existing.langs.includes(lang)) existing.langs.push(lang);
237
- } else {
238
- domainMap.set(slug, { slug, label: domain, langs: [lang] });
229
+ for (const lang of props.concept?.languages ?? []) {
230
+ const lc = props.concept?.localization(lang);
231
+ const domain = lc?.domain;
232
+ if (domain) {
233
+ const slug = slugify(domain);
234
+ const existing = domainMap.get(slug);
235
+ if (existing) {
236
+ if (!existing.langs.includes(lang)) existing.langs.push(lang);
237
+ } else {
238
+ domainMap.set(slug, { slug, label: domain, langs: [lang] });
239
+ }
239
240
  }
240
241
  }
242
+ } catch {
243
+ /* swallow — empty domains rather than crash at hydration */
241
244
  }
242
245
  return [...domainMap.values()].sort((a, b) => b.langs.length - a.langs.length);
243
246
  });
244
247
 
245
248
  const nonVerbalReps = computed(() => {
246
249
  const reps: typeof import('glossarist').NonVerbRep.prototype[] = [];
247
- for (const lang of props.concept.languages) {
248
- const lc = props.concept.localization(lang);
249
- if (lc?.nonVerbalRep?.length) {
250
- reps.push(...lc.nonVerbalRep);
250
+ try {
251
+ for (const lang of props.concept?.languages ?? []) {
252
+ const lc = props.concept?.localization(lang);
253
+ if (lc?.nonVerbalRep?.length) {
254
+ reps.push(...lc.nonVerbalRep);
255
+ }
251
256
  }
257
+ } catch {
258
+ /* swallow — empty reps rather than crash at hydration */
252
259
  }
253
260
  return reps;
254
261
  });
@@ -501,20 +508,20 @@ const nonVerbalReps = computed(() => {
501
508
  </div>
502
509
 
503
510
  <!-- Non-verbal reps (concept-level) -->
504
- <NonVerbalRepDisplay v-if="nonVerbalReps.length" :reps="nonVerbalReps" :locale="languages[0] ?? 'eng'" :register-id="registerId" :dataset-locales="languages" />
511
+ <NonVerbalRepDisplay v-if="nonVerbalReps?.length" :reps="nonVerbalReps" :locale="languages[0] ?? 'eng'" :register-id="registerId" :dataset-locales="languages" />
505
512
 
506
513
  <!-- Structural entity refs (concept-level figures/tables/formulas) -->
507
- <NonVerbalList v-if="structuralEntityRefs.length" :refs="structuralEntityRefs" />
514
+ <NonVerbalList v-if="structuralEntityRefs?.length" :refs="structuralEntityRefs" />
508
515
  </div>
509
516
 
510
517
  <!-- Right sidebar -->
511
518
  <div class="w-full lg:w-64 flex-shrink-0 space-y-4 mt-6 lg:mt-0">
512
519
  <!-- Relations -->
513
- <div v-if="outgoingEdges.length || incomingEdges.length" class="card p-5">
520
+ <div v-if="outgoingEdges?.length || incomingEdges?.length" class="card p-5">
514
521
  <div class="section-label">{{ t('concept.relations') }}</div>
515
522
 
516
523
  <!-- Outgoing -->
517
- <div v-if="outgoingEdges.length" class="mt-3">
524
+ <div v-if="outgoingEdges?.length" class="mt-3">
518
525
  <div class="text-xs text-ink-300 mb-1.5">{{ t('concept.outgoing') }} ({{ outgoingEdges.length }})</div>
519
526
  <div class="space-y-0.5 max-h-56 overflow-y-auto pr-1 -mr-1">
520
527
  <button
@@ -537,7 +544,7 @@ const nonVerbalReps = computed(() => {
537
544
  </div>
538
545
 
539
546
  <!-- Incoming -->
540
- <div v-if="incomingEdges.length" class="mt-3 pt-3 border-t border-ink-100/60">
547
+ <div v-if="incomingEdges?.length" class="mt-3 pt-3 border-t border-ink-100/60">
541
548
  <div class="text-xs text-ink-300 mb-1.5">{{ t('concept.incoming') }} ({{ incomingEdges.length }})</div>
542
549
  <div class="space-y-0.5 max-h-40 overflow-y-auto pr-1 -mr-1">
543
550
  <button
@@ -573,7 +580,7 @@ const nonVerbalReps = computed(() => {
573
580
 
574
581
  <!-- Partitive relations — one-to-many decompositions (ISO 704) -->
575
582
  <PartitiveRelationList
576
- v-if="conceptPartitiveRelations.length"
583
+ v-if="conceptPartitiveRelations?.length"
577
584
  :relations="conceptPartitiveRelations"
578
585
  :manifest="manifest"
579
586
  :register-id="registerId"
@@ -581,7 +588,7 @@ const nonVerbalReps = computed(() => {
581
588
 
582
589
  <!-- Generic relations — genus/species decompositions (ISO 704) -->
583
590
  <GenericRelationList
584
- v-if="conceptGenericRelations.length"
591
+ v-if="conceptGenericRelations?.length"
585
592
  :relations="conceptGenericRelations"
586
593
  :manifest="manifest"
587
594
  :register-id="registerId"
@@ -608,7 +615,7 @@ const nonVerbalReps = computed(() => {
608
615
  />
609
616
 
610
617
  <!-- Domains -->
611
- <div v-if="conceptDomains.length" class="card p-5">
618
+ <div v-if="conceptDomains?.length" class="card p-5">
612
619
  <div class="section-label">{{ t('concept.domains') }}</div>
613
620
  <div class="space-y-1 mt-3">
614
621
  <button
@@ -628,7 +635,7 @@ const nonVerbalReps = computed(() => {
628
635
  </div>
629
636
 
630
637
  <!-- Tags -->
631
- <div v-if="conceptTags.length" class="card p-5">
638
+ <div v-if="conceptTags?.length" class="card p-5">
632
639
  <div class="section-label">{{ t('concept.tags') }}</div>
633
640
  <div class="flex flex-wrap gap-1.5 mt-3">
634
641
  <span v-for="tag in conceptTags" :key="tag" class="badge badge-gray text-[10px]">{{ tag }}</span>
@@ -636,7 +643,7 @@ const nonVerbalReps = computed(() => {
636
643
  </div>
637
644
 
638
645
  <!-- Managed concept dates -->
639
- <div v-if="conceptDates.length" class="card p-5">
646
+ <div v-if="conceptDates?.length" class="card p-5">
640
647
  <div class="section-label">{{ t('concept.lifecycleDates') }}</div>
641
648
  <dl class="mt-3 space-y-1.5 text-xs">
642
649
  <div v-for="(d, i) in conceptDates" :key="i" class="flex gap-2">
@@ -647,7 +654,7 @@ const nonVerbalReps = computed(() => {
647
654
  </div>
648
655
 
649
656
  <!-- Managed concept sources -->
650
- <div v-if="conceptSources.length" class="card p-5">
657
+ <div v-if="conceptSources?.length" class="card p-5">
651
658
  <div class="section-label">{{ t('concept.conceptSources') }}</div>
652
659
  <div class="space-y-2 mt-3">
653
660
  <div v-for="(src, i) in conceptSources" :key="i" class="text-xs">
@@ -138,33 +138,37 @@ export function useConceptEdges(
138
138
  // Concept-level related concepts (managed concept cross-references)
139
139
  const conceptRelated = computed(() => {
140
140
  if (!concept.value) return [];
141
- const direct = concept.value.relatedConcepts?.filter((rc: any) => !INVERSE_RELATIONSHIPS[rc.type]) ?? [];
142
- const derived = incomingEdges.value
143
- .filter(e => INVERSE_RELATIONSHIPS[e.type])
144
- .map(e => {
145
- const parsed = factory.resolve(e.source, registerId.value);
146
- const sourceUrn = parsed.type === 'internal'
147
- ? store.manifests.get(parsed.registerId)?.datasetUri
148
- : null;
149
- const conceptId = e.source.match(/\/concept\/([^/]+)$/)?.[1];
150
- return {
151
- type: INVERSE_RELATIONSHIPS[e.type],
152
- ref: sourceUrn && conceptId ? { source: sourceUrn, id: conceptId } : null,
153
- content: '',
154
- };
141
+ try {
142
+ const direct = concept.value.relatedConcepts?.filter((rc: any) => !INVERSE_RELATIONSHIPS[rc.type]) ?? [];
143
+ const derived = incomingEdges.value
144
+ .filter(e => INVERSE_RELATIONSHIPS[e.type])
145
+ .map(e => {
146
+ const parsed = factory.resolve(e.source, registerId.value);
147
+ const sourceUrn = parsed.type === 'internal'
148
+ ? store.manifests.get(parsed.registerId)?.datasetUri
149
+ : null;
150
+ const conceptId = e.source.match(/\/concept\/([^/]+)$/)?.[1];
151
+ return {
152
+ type: INVERSE_RELATIONSHIPS[e.type],
153
+ ref: sourceUrn && conceptId ? { source: sourceUrn, id: conceptId } : null,
154
+ content: '',
155
+ };
156
+ });
157
+ return [...direct, ...derived].filter(edge => {
158
+ if (edge.type === 'broader_partitive' || edge.type === 'narrower_partitive') {
159
+ const refUri = resolveRefUri(edge.ref as { source: string | null; id: string | null } | null);
160
+ if (!refUri) return true;
161
+ const rels = conceptPartitiveRelations.value;
162
+ return !rels.some(rel =>
163
+ rel.comprehensive === refUri
164
+ || rel.partitives.some(m => m.uri === refUri),
165
+ );
166
+ }
167
+ return true;
155
168
  });
156
- return [...direct, ...derived].filter(edge => {
157
- if (edge.type === 'broader_partitive' || edge.type === 'narrower_partitive') {
158
- const refUri = resolveRefUri(edge.ref as { source: string | null; id: string | null } | null);
159
- if (!refUri) return true;
160
- const rels = conceptPartitiveRelations.value;
161
- return !rels.some(rel =>
162
- rel.comprehensive === refUri
163
- || rel.partitives.some(m => m.uri === refUri),
164
- );
165
- }
166
- return true;
167
- });
169
+ } catch {
170
+ return [];
171
+ }
168
172
  });
169
173
 
170
174
  // Concept-level n-ary hyperedge relations (ISO 704 one-to-many
@@ -174,25 +178,29 @@ export function useConceptEdges(
174
178
  //
175
179
  // glossarist 0.4.33+ exposes a unified `.relations` array; type
176
180
  // discrimination is via instanceof.
181
+ //
182
+ // Defensive: wrap in try/catch so a malformed concept (missing
183
+ // .relations, bad .comprehensive, etc.) never crashes the detail
184
+ // view at hydration. Regression: issue #171.
177
185
  function projectHyperedge(rel: any): PartitiveRelationWire | GenericRelationWire | null {
178
186
  const source = conceptUriValue.value;
179
187
  if (!source) return null;
180
- const comprehensive = resolveConceptRefUri(rel.comprehensive);
188
+ const comprehensive = resolveConceptRefUri(rel?.comprehensive);
181
189
  if (!comprehensive) return null;
182
190
  const isGeneric = rel instanceof GenericHyperedge;
183
- const members: any[] = (rel.members ?? rel.partitives ?? [])
191
+ const members: any[] = (rel?.members ?? rel?.partitives ?? [])
184
192
  .map((m: any): any | null => {
185
- const uri = resolveConceptRefUri(m.ref);
193
+ const uri = resolveConceptRefUri(m?.ref);
186
194
  if (!uri || uri === source) return null;
187
195
  const base: any = {
188
196
  uri,
189
- presence: readPresence(m),
190
- count: readCount(m),
197
+ presence: m?.presence,
198
+ count: m?.count,
191
199
  };
192
200
  if (isGeneric) {
193
- base.delimitingCharacteristic = m.delimitingCharacteristic;
201
+ base.delimitingCharacteristic = m?.delimitingCharacteristic;
194
202
  } else {
195
- base.isDelimiting = readIsDelimiting(m);
203
+ base.isDelimiting = m?.is_delimiting === true;
196
204
  }
197
205
  return base;
198
206
  })
@@ -203,26 +211,34 @@ export function useConceptEdges(
203
211
  comprehensive,
204
212
  members,
205
213
  partitives: members,
206
- completeness: rel.completeness,
207
- criterion: rel.criterion ?? undefined,
214
+ completeness: rel?.completeness,
215
+ criterion: rel?.criterion ?? undefined,
208
216
  register: registerId.value,
209
217
  };
210
218
  }
211
219
 
212
220
  const conceptPartitiveRelations = computed<PartitiveRelationWire[]>(() => {
213
221
  if (!concept.value) return [];
214
- return ((concept.value.relations as any[]) ?? [])
215
- .filter(r => r instanceof PartitiveHyperedge)
216
- .map(projectHyperedge)
217
- .filter((r): r is PartitiveRelationWire => r !== null);
222
+ try {
223
+ return ((concept.value.relations as any[]) ?? [])
224
+ .filter(r => r instanceof PartitiveHyperedge)
225
+ .map(projectHyperedge)
226
+ .filter((r): r is PartitiveRelationWire => r !== null);
227
+ } catch {
228
+ return [];
229
+ }
218
230
  });
219
231
 
220
232
  const conceptGenericRelations = computed<GenericRelationWire[]>(() => {
221
233
  if (!concept.value) return [];
222
- return ((concept.value.relations as any[]) ?? [])
223
- .filter(r => r instanceof GenericHyperedge)
224
- .map(projectHyperedge)
225
- .filter((r): r is GenericRelationWire => r !== null);
234
+ try {
235
+ return ((concept.value.relations as any[]) ?? [])
236
+ .filter(r => r instanceof GenericHyperedge)
237
+ .map(projectHyperedge)
238
+ .filter((r): r is GenericRelationWire => r !== null);
239
+ } catch {
240
+ return [];
241
+ }
226
242
  });
227
243
 
228
244
  function resolveConceptRefUri(ref: ConceptRef | null): string | null {
@@ -18,6 +18,22 @@ export interface LogoConfig {
18
18
  localDark?: string;
19
19
  }
20
20
 
21
+ export interface FaviconConfig {
22
+ /** Path prefix for all favicon URLs. Defaults to '/', set to a sub-path
23
+ * when deploying under BASE_PATH != '/'. */
24
+ base_path?: string;
25
+ /** Skip emitting the default <link rel="icon"> and <link rel="apple-touch-icon">
26
+ * tags. Use when the consumer provides their own RFG-compatible markup via
27
+ * `links_html`. Default: false (emit default tags). */
28
+ skip_default_links?: boolean;
29
+ /** Raw HTML string (one or more <link> tags) to emit in <head> instead of
30
+ * the default favicon block. RealFaviconGenerator output goes here. */
31
+ links_html?: string;
32
+ /** Consumer-side directory (relative to cwd) holding canonical favicon files.
33
+ * The CLI's favicon step copies these into public/, overriding defaults. */
34
+ source_dir?: string;
35
+ }
36
+
21
37
  export interface SiteBranding {
22
38
  primaryColor?: string;
23
39
  darkColor?: string;
@@ -27,7 +43,7 @@ export interface SiteBranding {
27
43
  };
28
44
  logo?: LogoConfig;
29
45
  footerLogo?: LogoConfig;
30
- favicon?: string;
46
+ favicon?: string | FaviconConfig;
31
47
  ownerName?: string;
32
48
  ownerUrl?: string;
33
49
  }
@@ -36,28 +36,53 @@ const fontHeader = brandingFonts?.header?.family
36
36
  const fontBody = brandingFonts?.body?.family
37
37
  ? `'${brandingFonts.body.family}', system-ui, sans-serif`
38
38
  : `'DM Sans', system-ui, sans-serif`;
39
+
40
+ // Favicon configuration (issue #173).
41
+ //
42
+ // Consumers provide their own favicon set in one of two ways:
43
+ //
44
+ // 1. Drop canonical files at `branding.favicon.source_dir` (relative
45
+ // to the consumer's cwd). The CLI's existing favicon step already
46
+ // copies these into public/ overriding the defaults — this layout
47
+ // just needs to emit the right <link> tags.
48
+ //
49
+ // 2. Set `branding.favicon.skip_default_links: true` and inject
50
+ // custom <link> tags via the `branding.favicon.links_html`
51
+ // string (e.g. RealFaviconGenerator output). The layout emits
52
+ // that verbatim and skips the default tag block.
53
+ //
54
+ // When neither is set, today's default behavior is preserved.
55
+ const faviconCfg = siteConfig?.branding?.favicon ?? {};
56
+ const skipDefaultFaviconLinks = faviconCfg.skip_default_links === true;
57
+ const customFaviconLinks: string = faviconCfg.links_html ?? '';
58
+ const faviconBase = faviconCfg.base_path ?? '/';
39
59
  ---
40
60
 
41
61
  <!DOCTYPE html>
42
62
  <html lang="en">
43
63
  <head>
44
64
  <meta charset="utf-8" />
45
- <link rel="icon" type="image/x-icon" href="/favicon.ico" />
46
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
47
- <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
48
- <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
49
- <link rel="icon" type="image/png" sizes="48x48" href="/favicon-48x48.png" />
50
- <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png" />
51
- <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png" />
52
- <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png" />
53
- <link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png" />
54
- <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png" />
55
- <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png" />
56
- <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png" />
57
- <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png" />
58
- <link rel="apple-touch-icon" sizes="167x167" href="/apple-touch-icon-167x167.png" />
59
- <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png" />
60
- <link rel="apple-touch-icon" sizes="1024x1024" href="/apple-touch-icon-1024x1024.png" />
65
+ {!skipDefaultFaviconLinks && (
66
+ <>
67
+ <link rel="icon" type="image/x-icon" href={`${faviconBase}favicon.ico`} />
68
+ <link rel="icon" type="image/svg+xml" href={`${faviconBase}favicon.svg`} />
69
+ <link rel="icon" type="image/png" sizes="16x16" href={`${faviconBase}favicon-16x16.png`} />
70
+ <link rel="icon" type="image/png" sizes="32x32" href={`${faviconBase}favicon-32x32.png`} />
71
+ <link rel="icon" type="image/png" sizes="48x48" href={`${faviconBase}favicon-48x48.png`} />
72
+ <link rel="apple-touch-icon" sizes="57x57" href={`${faviconBase}apple-touch-icon-57x57.png`} />
73
+ <link rel="apple-touch-icon" sizes="60x60" href={`${faviconBase}apple-touch-icon-60x60.png`} />
74
+ <link rel="apple-touch-icon" sizes="72x72" href={`${faviconBase}apple-touch-icon-72x72.png`} />
75
+ <link rel="apple-touch-icon" sizes="76x76" href={`${faviconBase}apple-touch-icon-76x76.png`} />
76
+ <link rel="apple-touch-icon" sizes="114x114" href={`${faviconBase}apple-touch-icon-114x114.png`} />
77
+ <link rel="apple-touch-icon" sizes="120x120" href={`${faviconBase}apple-touch-icon-120x120.png`} />
78
+ <link rel="apple-touch-icon" sizes="144x144" href={`${faviconBase}apple-touch-icon-144x144.png`} />
79
+ <link rel="apple-touch-icon" sizes="152x152" href={`${faviconBase}apple-touch-icon-152x152.png`} />
80
+ <link rel="apple-touch-icon" sizes="167x167" href={`${faviconBase}apple-touch-icon-167x167.png`} />
81
+ <link rel="apple-touch-icon" sizes="180x180" href={`${faviconBase}apple-touch-icon-180x180.png`} />
82
+ <link rel="apple-touch-icon" sizes="1024x1024" href={`${faviconBase}apple-touch-icon-1024x1024.png`} />
83
+ </>
84
+ )}
85
+ {customFaviconLinks && <Fragment set:html={customFaviconLinks} />}
61
86
  <meta name="apple-mobile-web-app-capable" content="yes" />
62
87
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
63
88
  <meta name="apple-mobile-web-app-title" content={siteConfig.title} />
@@ -11,6 +11,12 @@ export async function getStaticPaths() {
11
11
  { params: { path: 'about' } },
12
12
  { params: { path: 'contributors' } },
13
13
  { params: { path: 'news' } },
14
+ /* /learn and sub-routes — page-types.ts auto-synthesizes the nav entry.
15
+ Without these static paths the nav link 404s on prefetch (issue #174). */
16
+ { params: { path: 'learn' } },
17
+ { params: { path: 'learn/relationships' } },
18
+ { params: { path: 'learn/designations' } },
19
+ { params: { path: 'learn/statuses' } },
14
20
  ];
15
21
  for (const ds of datasets) {
16
22
  paths.push({ params: { path: `dataset/${ds.data.id}/about` } });