fix: render desc hub model list
This commit is contained in:
parent
c000f75593
commit
ba736d264b
@ -4,6 +4,8 @@ import Image from 'next/image'
|
||||
|
||||
import { ModelSource } from '@janhq/core'
|
||||
|
||||
import rehypeRaw from 'rehype-raw'
|
||||
|
||||
import { DownloadIcon, FileJson } from 'lucide-react'
|
||||
|
||||
import ModelLabel from '@/containers/ModelLabel'
|
||||
@ -36,6 +38,7 @@ const ModelItem: React.FC<Props> = ({ model, onSelectedModel }) => {
|
||||
<Markdown
|
||||
className="md-short-desc line-clamp-3 max-w-full overflow-hidden font-light text-[hsla(var(--text-secondary))]"
|
||||
components={markdownComponents}
|
||||
rehypePlugins={[rehypeRaw]}
|
||||
>
|
||||
{extractDescription(model.metadata?.description) || '-'}
|
||||
</Markdown>
|
||||
|
||||
@ -7,12 +7,19 @@ export const extractDescription = (text?: string) => {
|
||||
const normalizedText = removeYamlFrontMatter(text)
|
||||
const overviewPattern = /(?:##\s*Overview\s*\n)([\s\S]*?)(?=\n\s*##|$)/
|
||||
const matches = normalizedText?.match(overviewPattern)
|
||||
if (matches && matches[1]) {
|
||||
return matches[1].trim()
|
||||
}
|
||||
return normalizedText?.slice(0, 500).trim()
|
||||
}
|
||||
let extractedText =
|
||||
matches && matches[1]
|
||||
? matches[1].trim()
|
||||
: normalizedText?.slice(0, 500).trim()
|
||||
|
||||
// Remove image markdown syntax 
|
||||
extractedText = extractedText?.replace(/!\[.*?\]\(.*?\)/g, '')
|
||||
|
||||
// Remove <img> HTML tags
|
||||
extractedText = extractedText?.replace(/<img[^>]*>/g, '')
|
||||
|
||||
return extractedText
|
||||
}
|
||||
/**
|
||||
* Remove YAML (HF metadata) front matter from content
|
||||
* @param content
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user