feat: монорепо миграция, Discover/SearxNG улучшения
- Миграция на монорепозиторий (apps/frontend, apps/chat-service, etc.) - Discover: проверка SearxNG, понятное empty state при ненастроенном поиске - searxng.ts: валидация URL, проверка JSON-ответа, авто-добавление http:// - docker/searxng-config: настройки для JSON API SearxNG Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
22
apps/posts-mcs/src/lib/content.ts
Normal file
22
apps/posts-mcs/src/lib/content.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { ContentBlock } from '../db/schema.js';
|
||||
|
||||
/** Извлекает поисковый текст из блоков контента */
|
||||
export function blocksToSearchText(blocks: ContentBlock[] | null): string {
|
||||
if (!blocks || !Array.isArray(blocks)) return '';
|
||||
return blocks
|
||||
.map((b) => {
|
||||
if (b.type === 'text' && b.data?.html) return stripHtml(String(b.data.html));
|
||||
if (b.type === 'heading' && b.data?.text) return b.data.text;
|
||||
if (b.type === 'image' && b.data?.caption) return b.data.caption;
|
||||
if (b.type === 'video' && b.data?.caption) return b.data.caption;
|
||||
if (b.type === 'audio' && b.data?.caption) return b.data.caption;
|
||||
if (b.type === 'table' && b.data?.html) return stripHtml(String(b.data.html));
|
||||
return '';
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
function stripHtml(html: string): string {
|
||||
return html.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
Reference in New Issue
Block a user