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