chore: update unified types

This commit is contained in:
DIYgod
2023-09-27 00:08:00 +08:00
parent 19d4badc24
commit 82c827a8fb
12 changed files with 26 additions and 25 deletions
+7 -6
View File
@@ -2,7 +2,6 @@
import dynamic from "next/dynamic"
import { type DPlayerProps } from "rc-dplayer"
import { ReactElement } from "rehype-react/lib"
import { toGateway } from "~/lib/ipfs-parser"
@@ -14,12 +13,14 @@ const DPlayer = function DPlayer({
...props
}: {
src?: string
children?: ReactElement[]
children?: JSX.Element[] | JSX.Element
} & DPlayerProps) {
const sources = children?.filter(
(child) =>
child && typeof child.type === "string" && child.type === "source",
)
const sources = Array.isArray(children)
? children?.filter(
(child) =>
child && typeof child.type === "string" && child.type === "source",
)
: []
if (!src) {
src = (sources?.[0]?.props as DPlayerProps)?.src as string