|
1 | 1 | <script lang="ts"> |
2 | 2 | import { curation, slugify, toDashed } from './curation.svelte'; |
3 | 3 |
|
| 4 | + // Mirrors content-ingest's DOMAIN_FOLDERS (services/content-ingest/src/ |
| 5 | + // corpus.ts) so the "writes to" preview below matches the actual folder |
| 6 | + // the backend will create. Irregular plurals only; fallback +s. |
| 7 | + const DOMAIN_FOLDERS: Record<string, string> = { |
| 8 | + strategy: 'strategies', |
| 9 | + topic: 'topics', |
| 10 | + thesis: 'theses', |
| 11 | + category: 'categories', |
| 12 | + 'market-segment': 'market-segments', |
| 13 | + }; |
| 14 | + function domainFolder(t: string): string { |
| 15 | + return DOMAIN_FOLDERS[t] ?? `${t}s`; |
| 16 | + } |
| 17 | +
|
4 | 18 | let title = $state(''); |
5 | 19 | let slug = $state(''); |
6 | 20 | let slugEdited = $state(false); |
| 21 | + let type = $state(curation.domainType); |
7 | 22 | let tagInput = $state(''); |
8 | 23 | let pendingTags = $state<string[]>([]); |
9 | 24 | let tagSuggest = $derived(curation.suggestTags(tagInput)); |
|
24 | 39 | function removeTag(t: string): void { |
25 | 40 | pendingTags = pendingTags.filter((x) => x !== t); |
26 | 41 | } |
27 | | - function create(): void { |
28 | | - void curation.createStrategy({ title, slug, tags: pendingTags }); |
| 42 | + async function create(): Promise<void> { |
| 43 | + await curation.createStrategy({ title, slug, tags: pendingTags, type }); |
| 44 | + // Read domainType back AFTER the await — createStrategy only updates it |
| 45 | + // (via setDomainType) once the server confirms a type change, so |
| 46 | + // resetting eagerly here would just re-read the pre-create value. |
29 | 47 | title = ''; |
30 | 48 | slug = ''; |
31 | 49 | slugEdited = false; |
| 50 | + type = curation.domainType; |
32 | 51 | pendingTags = []; |
33 | 52 | tagInput = ''; |
34 | 53 | } |
35 | 54 | </script> |
36 | 55 |
|
37 | 56 | <section class="sc-card"> |
38 | | - <h2>Strategies</h2> |
39 | | - <p class="sc-muted">Pick a strategy to gather sources for, or create a new one.</p> |
| 57 | + <h2>Corpora</h2> |
| 58 | + <p class="sc-muted">Pick a corpus to gather sources for, or create a new one.</p> |
40 | 59 |
|
41 | 60 | {#if curation.strategies.length === 0} |
42 | | - <p class="sc-muted sc-mini">No strategies yet.</p> |
| 61 | + <p class="sc-muted sc-mini">No corpora yet.</p> |
43 | 62 | {:else} |
44 | 63 | <ul class="sc-strat-list"> |
45 | 64 | {#each curation.strategies as s (s.slug)} |
|
55 | 74 | </section> |
56 | 75 |
|
57 | 76 | <section class="sc-card"> |
58 | | - <h2>New strategy</h2> |
| 77 | + <h2>New corpus</h2> |
59 | 78 |
|
60 | 79 | <div class="sc-field"> |
61 | 80 | <span class="sc-label">Title</span> |
62 | | - <input value={title} oninput={(e) => onTitle(e.currentTarget.value)} placeholder="full strategy name…" /> |
| 81 | + <input value={title} oninput={(e) => onTitle(e.currentTarget.value)} placeholder="full corpus name…" /> |
| 82 | + </div> |
| 83 | + |
| 84 | + <div class="sc-field"> |
| 85 | + <span class="sc-label">Type <span class="sc-muted sc-mini">— any value; 'strategy' and 'thesis' are the two in use today</span></span> |
| 86 | + <input class="sc-mono" bind:value={type} placeholder="strategy" /> |
63 | 87 | </div> |
64 | 88 |
|
65 | 89 | <div class="sc-field"> |
66 | 90 | <span class="sc-label">Slug <span class="sc-muted sc-mini">— auto from title, editable, lowercase-kebab</span></span> |
67 | | - <input class="sc-mono" value={slug} oninput={(e) => onSlug(e.currentTarget.value)} placeholder="strategy-slug" /> |
| 91 | + <input class="sc-mono" value={slug} oninput={(e) => onSlug(e.currentTarget.value)} placeholder="corpus-slug" /> |
68 | 92 | </div> |
69 | 93 |
|
70 | 94 | <div class="sc-field"> |
|
88 | 112 | </div> |
89 | 113 | </div> |
90 | 114 |
|
91 | | - <button class="sc-primary" onclick={create} disabled={!title.trim() || !slug.trim()}> |
92 | | - + Create strategy → folder + index.md |
| 115 | + <button class="sc-primary" onclick={create} disabled={!title.trim() || !slug.trim() || !type.trim()}> |
| 116 | + + Create corpus → folder + index.md |
93 | 117 | </button> |
94 | | - {#if slug.trim()} |
| 118 | + {#if slug.trim() && type.trim()} |
95 | 119 | <p class="sc-muted sc-mini"> |
96 | | - Writes <code class="sc-mono">strategies/{slug}/index.md</code> |
| 120 | + Writes <code class="sc-mono">{domainFolder(type.trim())}/{slug}/index.md</code> |
97 | 121 | </p> |
98 | 122 | {/if} |
99 | 123 | </section> |
0 commit comments