ZH
测试版翻译

@core / contracts

1.0.0 ▾
已验证MIT
GitHub

GenPM 模块共享类型:内容、站点地图、搜索、后台资源、支付和追踪事件

代码10 个文件上下文约 532 个 token扫描通过

应用 .genpmignore 后将被注入的确切目录树。固定于

src/lib/contracts/search.ts只读 · 7266529
// Fuente de documentos para el buscador del sitio: la implementan content, blog, catalog…; la consume @core/search.

export type SearchDocument = {
  /** Único dentro de `type`. */
  id: string;
  /** Tipo de resultado: `page`, `post`, `product`. */
  type: string;
  url: string;
  title: string;
  /** Texto plano (sin HTML ni Markdown). */
  body: string;
  locale?: string;
  updatedAt?: Date;
};

export type SearchChange = { op: 'upsert'; doc: SearchDocument } | { op: 'delete'; type: string; id: string };

export type SearchSource = {
  type: string;
  /** Todos los documentos publicados (reindexado completo). */
  documents(): AsyncIterable<SearchDocument>;
  /** Avisos incrementales (publicar, despublicar). Devuelve la función para darse de baja. */
  subscribe?(listener: (change: SearchChange) => void | Promise<void>): () => void;
};

export const defineSearchSource = (source: SearchSource): SearchSource => source;

举报 @core/contracts

使用 GitHub 登录后才能举报包。