31 lines
882 B
TypeScript
31 lines
882 B
TypeScript
import type { Article } from '@/types/nostr'
|
|
|
|
/**
|
|
* Extract presentation data from article content
|
|
* Content format: "${presentation}\n\n---\n\nDescription du contenu :\n${contentDescription}"
|
|
*/
|
|
export function extractPresentationData(presentation: Article): {
|
|
presentation: string
|
|
contentDescription: string
|
|
} {
|
|
const content = presentation.content
|
|
const separator = '\n\n---\n\nDescription du contenu :\n'
|
|
const separatorIndex = content.indexOf(separator)
|
|
|
|
if (separatorIndex === -1) {
|
|
// Fallback: return content as presentation if separator not found
|
|
return {
|
|
presentation: content,
|
|
contentDescription: '',
|
|
}
|
|
}
|
|
|
|
const presentationText = content.substring(0, separatorIndex)
|
|
const contentDescription = content.substring(separatorIndex + separator.length)
|
|
|
|
return {
|
|
presentation: presentationText,
|
|
contentDescription,
|
|
}
|
|
}
|