新增内容判断引擎文章发布接口
This commit is contained in:
@@ -33,7 +33,7 @@ export default function InsightDetail() {
|
||||
<h1>{item.title}</h1>
|
||||
<p>{item.summary}</p>
|
||||
<p style={{ fontSize: 12, color: 'rgba(255,255,255,0.6)', marginTop: 8 }}>
|
||||
{item.readingMinutes} 分钟 · {item.author} · {item.category}
|
||||
{item.category} · {new Date(item.createdAt).toLocaleDateString('zh-CN')} · {item.author} · {item.readingMinutes} 分钟阅读
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function Insights() {
|
||||
<h3 style={{ marginTop: 6 }}>{i.title}</h3>
|
||||
<p>{i.summary}</p>
|
||||
<div style={{ fontSize: 12, color: '#94a3b8', marginTop: 8 }}>
|
||||
{i.readingMinutes} 分钟 · {i.author} · 权重 {i.sortWeight}
|
||||
{i.category} · {new Date(i.createdAt).toLocaleDateString('zh-CN')} · {i.author}
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
|
||||
+10
-4
@@ -117,21 +117,27 @@ function normalizeCases(raw:any[]): Case[]{
|
||||
}
|
||||
function normalizeInsights(raw:any[]): Insight[]{
|
||||
if(!raw) return FALLBACK_INSIGHTS
|
||||
return raw.map(r=>({
|
||||
return raw.map(r=>{
|
||||
const body = String(r.body_plain || r.content_html || '')
|
||||
const paragraphs = body.replace(/\r\n?/g, '\n').split('\n').map((value:string)=>value.trim()).filter(Boolean)
|
||||
const characterCount = body.replace(/\s/g, '').length
|
||||
return ({
|
||||
id: r.id,
|
||||
slug: r.slug,
|
||||
title: r.title,
|
||||
summary: r.subtitle || '',
|
||||
category: (r.category as any)||'other',
|
||||
author: r.author_name || '阿美巴',
|
||||
readingMinutes: Math.max(1, Math.ceil(characterCount / 400)),
|
||||
status: (r.status as any)||'published',
|
||||
sortWeight: r.recommend_weight||0,
|
||||
cmsManaged: true,
|
||||
cmsId: r.id,
|
||||
createdAt: r.created_at||new Date().toISOString(),
|
||||
createdAt: r.publish_time||r.created_at||new Date().toISOString(),
|
||||
updatedAt: r.updated_at||new Date().toISOString(),
|
||||
coverImage: r.cover_url,
|
||||
contentBlocks: r.content_html ? [{id:'b1', type:'paragraph' as const, text: r.content_html}] : [],
|
||||
}))
|
||||
contentBlocks: paragraphs.map((paragraph:string,index:number)=>({id:`p${index+1}`, type:'paragraph' as const, text:paragraph})),
|
||||
})})
|
||||
}
|
||||
function normalizeMethods(raw:any[]): MethodCapability[]{
|
||||
if(!raw) return FALLBACK_METHODS
|
||||
|
||||
Reference in New Issue
Block a user