preview.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use client'
  2. import React from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import { XMarkIcon } from '@heroicons/react/20/solid'
  5. import s from '../file-preview/index.module.css'
  6. import cn from '@/utils/classnames'
  7. import type { CrawlResultItem } from '@/models/datasets'
  8. type IProps = {
  9. payload: CrawlResultItem
  10. hidePreview: () => void
  11. }
  12. const WebsitePreview = ({
  13. payload,
  14. hidePreview,
  15. }: IProps) => {
  16. const { t } = useTranslation()
  17. return (
  18. <div className={cn(s.filePreview)}>
  19. <div className={cn(s.previewHeader)}>
  20. <div className={cn(s.title)}>
  21. <span>{t('datasetCreation.stepOne.pagePreview')}</span>
  22. <div className='flex items-center justify-center w-6 h-6 cursor-pointer' onClick={hidePreview}>
  23. <XMarkIcon className='h-4 w-4'></XMarkIcon>
  24. </div>
  25. </div>
  26. <div className='leading-5 text-sm font-medium text-gray-900 break-words'>
  27. {payload.title}
  28. </div>
  29. <div className='truncate leading-[18px] text-xs font-normal text-gray-500' title={payload.source_url}>{payload.source_url}</div>
  30. </div>
  31. <div className={cn(s.previewContent)}>
  32. <div className={cn(s.fileContent)}>{payload.markdown}</div>
  33. </div>
  34. </div>
  35. )
  36. }
  37. export default WebsitePreview