UNPKG

histoire

Version:

A fast story book powered by Vite

18 lines (17 loc) • 999 B
import { convertTitleToSentence } from '../../search.js'; /** Reuses completed docs inventory and standalone title normalization without loaders. */ export function projectEmbedSearch(snapshot) { const titles = []; const docs = []; for (const story of snapshot.stories) { titles.push({ target: { storyId: story.id, variantId: null }, kind: story.docsOnly ? 'docs' : 'story', title: story.title, text: convertTitleToSentence(story.title) }); if (!story.docsOnly) { for (const variant of story.variants) titles.push({ target: { storyId: story.id, variantId: variant.id }, kind: 'variant', title: variant.title, text: convertTitleToSentence(`${story.title} ${variant.title}`) }); } const content = snapshot.contents.get(story.filePath)?.docs; if (content) docs.push({ target: { storyId: story.id, variantId: null }, kind: 'docs', title: story.title, text: content.text }); } return { titles, docs }; }