fix(notes): render audio link preview
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m4s
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m4s
This commit is contained in:
parent
6321c32adf
commit
7ca3335534
@ -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 />
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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' })
|
||||
|
Loading…
x
Reference in New Issue
Block a user