ZH
测试版翻译

@core / blog

1.0.1 ▾
已验证MIT
GitHub

基于 @core/content 的博客:文章、作者、分类、标签、系列、相关文章、归档和 RSS/Atom/JSON 订阅

代码7 个文件上下文约 554 个 token扫描通过

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

src/lib/blog/sources.ts只读 · 8aaf3ee
// Fuentes de sitemap y buscador del blog, y recursos del panel.
import { contentAdminResource, contentSearchSource, contentSitemapSource } from '../content/index.ts';
import { type Doc, toPlainText } from '../rich-text/index.ts';
import { BLOG_COLLECTIONS } from './collections.ts';

type PathFn = (p: { slug: string; locale: string }) => string;
const defaultPath: PathFn = ({ slug }) => `/blog/${slug}`;

export const blogSitemapSource = (path: PathFn = defaultPath) => contentSitemapSource('posts', path);

/** Documentos de búsqueda con el cuerpo en texto plano. Los posts `membersOnly` solo indexan título y extracto. */
export const blogSearchSource = (path: PathFn = defaultPath) =>
  contentSearchSource('posts', {
    type: 'post',
    path,
    title: (d) => String(d.title ?? ''),
    text: (d) => (d.membersOnly ? String(d.excerpt ?? '') : `${d.excerpt ?? ''}\n${toPlainText(d.body as Doc)}`),
  });

/** Recursos del panel: posts (con enlaces "Ver" y "Vista previa"), autores, categorías, etiquetas y series. */
export const blogAdminResources = (path: PathFn = defaultPath) =>
  BLOG_COLLECTIONS.map((c) => ({ ...contentAdminResource(c, c === 'posts' ? { path } : {}), group: 'Blog' }));

举报 @core/blog

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