版本: v1.0 最后更新: 2026-04-03 受众: 开发者 阅读时间: 15 分钟
本文档详细说明了 PostWaver 中的数据流转过程,包括内容扫描、转换、发布等关键流程。
Markdown 文件
↓
Scanner (core)
↓
生成 Frontmatter
↓
解析内容
↓
提取元数据
↓
存储到数据库 (database)
↓
返回文章对象
详细步骤:
content/posts/ 目录.md 文件代码位置: packages/core/src/scanner.ts
Markdown 内容
↓
Parser (core)
↓
AST (抽象语法树)
↓
Transformer (transformer)
↓
平台特定格式
↓
注入链接/标题 (core)
↓
最终输出
详细步骤:
代码位置: packages/transformer/src/
文章 ID
↓
查询数据库 (database)
↓
标签匹配 (linker)
↓
时间排序
↓
计算前后篇 (linker)
↓
语义分析 (可选,Python)
↓
返回相关文章
详细步骤:
代码位置: packages/linker/src/
选择文章
↓
选择平台
↓
转换内容 (transformer)
↓
上传图片 (adapter,可选)
↓
发布到平台 (adapter)
↓
保存发布记录 (database)
↓
返回结果
详细步骤:
代码位置: packages/engine/src/
文章列表
↓
转换为 Hexo 格式
↓
注入模板 (core)
↓
写入 Hexo 目录
↓
生成静态文件 (Hexo)
↓
Git 提交
↓
推送到远程
详细步骤:
blog/ 目录hexo generate代码位置: scripts/sync-to-hexo.ts
interface Post {
id: string
title: string
slug: string
content: string
excerpt: string
status: PostStatus
publishedAt: Date | null
tags: string[]
categories: string[]
frontmatter: Record<string, any>
images: string[]
createdAt: Date
updatedAt: Date
}
interface PublishRecord {
id: string
postId: string
platform: Platform
platformPostId: string
platformUrl: string
status: PublishStatus
publishedAt: Date
createdAt: Date
}
// 1. 创建文章
const post = await createPost({
title: 'Hello World',
content: '# Hello World\n\nThis is a test.',
tags: ['test']
})
// 2. 扫描和索引
await scanContent('content/posts')
// 3. 转换为平台格式
const transformed = await transformToJuejin(post.content)
// 4. 发布到平台
const result = await publishToPlatform(post.id, 'juejin')
// 5. 保存发布记录
await savePublishRecord({
postId: post.id,
platform: 'juejin',
platformUrl: result.url
})
// 1. 获取文章
const post = await getPostById('post-id')
// 2. 获取相关文章
const related = await getRelatedPosts(post.id, {
limit: 5,
method: 'tags' // or 'semantic'
})
// 3. 注入到内容
const contentWithLinks = await injectRelatedLinks(post.content, related)
# 设置环境变量
export DEBUG=postwaver:*
# 运行命令
pnpm scan
# 打开 Prisma Studio
pnpm db:studio
# 查看文章状态
pnpm post:status
# 测试扫描
pnpm scan
# 测试转换
pnpm transform:juejin
# 测试发布(预览)
pnpm preview:juejin
最后更新: 2026-04-03 维护者: PostWaver Team 反馈: GitHub Issues