feat: add auto-load media content setting option

This commit is contained in:
codytseng 2025-09-13 23:05:21 +08:00
parent 6d7ecfe2fd
commit f785d0d8a2
35 changed files with 458 additions and 105 deletions

View file

@ -1,10 +1,12 @@
import { useFetchWebMetadata } from '@/hooks/useFetchWebMetadata'
import { cn } from '@/lib/utils'
import { useContentPolicy } from '@/providers/ContentPolicyProvider'
import { useScreenSize } from '@/providers/ScreenSizeProvider'
import { useMemo } from 'react'
import Image from '../Image'
export default function WebPreview({ url, className }: { url: string; className?: string }) {
const { autoLoadMedia } = useContentPolicy()
const { isSmallScreen } = useScreenSize()
const { title, description, image } = useFetchWebMetadata(url)
@ -16,6 +18,10 @@ export default function WebPreview({ url, className }: { url: string; className?
}
}, [url])
if (!autoLoadMedia) {
return null
}
if (!title) {
return null
}
@ -49,7 +55,7 @@ export default function WebPreview({ url, className }: { url: string; className?
{image && (
<Image
image={{ url: image }}
className="aspect-[4/3] xl:aspect-video object-cover bg-foreground h-44 rounded-none"
className="aspect-[4/3] xl:aspect-video bg-foreground h-44 rounded-none"
hideIfError
/>
)}