fix(notes): render audio link preview
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m4s

This commit is contained in:
en 2025-02-21 22:17:11 +01:00
parent 6321c32adf
commit 7ca3335534
2 changed files with 13 additions and 1 deletions

View File

@ -6,7 +6,12 @@ import { Fragment } from 'react/jsx-runtime'
import { BlogPreview } from './internal/BlogPreview'
import { ModPreview } from './internal/ModPreview'
import { NoteWrapper } from './internal/NoteWrapper'
import { isValidImageUrl, isValidUrl, isValidVideoUrl } from 'utils'
import {
isValidAudioUrl,
isValidImageUrl,
isValidUrl,
isValidVideoUrl
} from 'utils'
interface NoteRenderProps {
content: string
@ -54,6 +59,8 @@ export const NoteRender = ({ content }: NoteRenderProps) => {
controls
/>
)
} else if (isValidAudioUrl(href)) {
return <audio key={key} src={href} controls />
}
}

View File

@ -65,6 +65,11 @@ export const isValidVideoUrl = (url: string) => {
return regex.test(url)
}
export const isValidAudioUrl = (url: string) => {
const regex = /\.(mp3|wav|ogg|aac)$/
return regex.test(url)
}
export const isReachable = async (url: string) => {
try {
const response = await fetch(url, { method: 'HEAD' })