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 { BlogPreview } from './internal/BlogPreview'
import { ModPreview } from './internal/ModPreview' import { ModPreview } from './internal/ModPreview'
import { NoteWrapper } from './internal/NoteWrapper' import { NoteWrapper } from './internal/NoteWrapper'
import { isValidImageUrl, isValidUrl, isValidVideoUrl } from 'utils' import {
isValidAudioUrl,
isValidImageUrl,
isValidUrl,
isValidVideoUrl
} from 'utils'
interface NoteRenderProps { interface NoteRenderProps {
content: string content: string
@ -54,6 +59,8 @@ export const NoteRender = ({ content }: NoteRenderProps) => {
controls 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) 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) => { export const isReachable = async (url: string) => {
try { try {
const response = await fetch(url, { method: 'HEAD' }) const response = await fetch(url, { method: 'HEAD' })