note-facets.mjs
sha256:fd47ab66017e55331b88ba3a59c34c23e4e05c5aec424251d3a404c5a7998c8e
feat(hub): restore integration tile detail modals; add Herm…
Human
minor
⚠ breaking
16 days ago
| 1 | /** |
| 2 | * Derive Hub filter facets from canister list-note rows (path + frontmatter JSON string). |
| 3 | * Mirrors web/hub/hub.js list normalization enough for dropdowns and Quick chips. |
| 4 | */ |
| 5 | |
| 6 | import { |
| 7 | parseFrontmatterJsonText, |
| 8 | materializeWireFrontmatter as materializeListFrontmatter, |
| 9 | } from '../../lib/parse-frontmatter-json.mjs'; |
| 10 | |
| 11 | export { parseFrontmatterJsonText, materializeListFrontmatter }; |
| 12 | |
| 13 | export function tagsFromFm(fm) { |
| 14 | const raw = fm && fm.tags; |
| 15 | if (Array.isArray(raw)) return raw.map(String).filter(Boolean); |
| 16 | if (typeof raw === 'string' && raw.trim()) { |
| 17 | return raw |
| 18 | .split(/[,\n]/) |
| 19 | .map((s) => s.trim()) |
| 20 | .filter(Boolean); |
| 21 | } |
| 22 | return []; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @param {Array<{ path?: string, frontmatter?: unknown }>} notes |
| 27 | * @returns {{ projects: string[], tags: string[], folders: string[], networks: string[], wallets: string[] }} |
| 28 | */ |
| 29 | export function deriveFacetsFromCanisterNotes(notes) { |
| 30 | const projects = new Set(); |
| 31 | const tags = new Set(); |
| 32 | const folders = new Set(); |
| 33 | const networks = new Set(); |
| 34 | const wallets = new Set(); |
| 35 | for (const n of notes) { |
| 36 | if (!n || typeof n !== 'object') continue; |
| 37 | const path = n.path; |
| 38 | if (path) { |
| 39 | const seg = String(path).split('/')[0]; |
| 40 | if (seg) folders.add(seg); |
| 41 | } |
| 42 | const fm = materializeListFrontmatter(n.frontmatter); |
| 43 | if (fm.project != null && String(fm.project).trim()) projects.add(String(fm.project)); |
| 44 | for (const t of tagsFromFm(fm)) tags.add(String(t)); |
| 45 | // Phase 12 — blockchain facets |
| 46 | if (fm.network != null && String(fm.network).trim()) networks.add(String(fm.network).trim()); |
| 47 | if (fm.wallet_address != null && String(fm.wallet_address).trim()) wallets.add(String(fm.wallet_address).trim()); |
| 48 | } |
| 49 | return { |
| 50 | projects: [...projects].sort((a, b) => a.localeCompare(b)), |
| 51 | tags: [...tags].sort((a, b) => a.localeCompare(b)), |
| 52 | folders: [...folders].sort((a, b) => a.localeCompare(b)), |
| 53 | networks: [...networks].sort((a, b) => a.localeCompare(b)), |
| 54 | wallets: [...wallets].sort((a, b) => a.localeCompare(b)), |
| 55 | }; |
| 56 | } |
File History
3 commits
sha256:fd47ab66017e55331b88ba3a59c34c23e4e05c5aec424251d3a404c5a7998c8e
feat(hub): restore integration tile detail modals; add Herm…
Human
minor
⚠
16 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91
fix: repair endpoint now sets has_active_subscription when …
Human
minor
⚠
16 days ago
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
48 days ago