ZH
测试版翻译

@core / contracts

1.0.0 ▾
已验证MIT
GitHub

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

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

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

src/lib/contracts/content.ts只读 · 7266529
// Fuente de contenido: lo implementan @core/content y los adaptadores (Payload, Keystatic); lo consumen blog,
// blocks, site y los kits sin saber de dónde viene el contenido.

export type ContentStatus = 'draft' | 'scheduled' | 'published' | 'archived';

export type ContentEntry<D = Record<string, unknown>> = {
  id: string;
  collection: string;
  slug: string;
  locale: string;
  status: ContentStatus;
  data: D;
  publishedAt: Date | null;
  updatedAt: Date;
};

export type ContentReadOptions = {
  /** Idioma pedido; sin entrada en ese idioma, la fuente devuelve la del idioma por defecto. */
  locale?: string;
  /** Incluir borradores (solo con un token de vista previa válido). */
  draft?: boolean;
};

export type ContentListQuery = ContentReadOptions & {
  limit?: number;
  offset?: number;
  /** Campo de orden: `publishedAt`, `updatedAt`, `slug` o un campo de `data`. Prefijo `-` = descendente. */
  orderBy?: string;
  /** Igualdad sobre campos de `data` (p. ej. `{ category: 'news' }`). */
  where?: Record<string, string | number | boolean | null>;
  /** El campo de `data` es una lista que contiene este valor (p. ej. `{ tags: 'news' }`). */
  contains?: Record<string, string>;
};

export interface ContentSource {
  getEntry<D = Record<string, unknown>>(
    collection: string,
    slug: string,
    opts?: ContentReadOptions,
  ): Promise<ContentEntry<D> | null>;
  listEntries<D = Record<string, unknown>>(collection: string, query?: ContentListQuery): Promise<ContentEntry<D>[]>;
}

举报 @core/contracts

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