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 { 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 />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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' })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user