chore: update unified types

This commit is contained in:
DIYgod 2023-09-27 00:08:00 +08:00
parent 19d4badc24
commit 82c827a8fb
No known key found for this signature in database
12 changed files with 26 additions and 25 deletions

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

View File

@ -1,4 +1,4 @@
import { Root } from "rehype-raw"
import type { Root } from "hast"
import { Plugin } from "unified"
import { visit } from "unist-util-visit"

View File

@ -1,5 +1,5 @@
import type { Root } from "hast"
import { fromHtml } from "hast-util-from-html"
import { Root } from "rehype-raw"
import { Plugin } from "unified"
import { visit } from "unist-util-visit"

View File

@ -1,4 +1,4 @@
import { Root } from "rehype-raw"
import type { Root } from "hast"
import { Plugin } from "unified"
import { visit } from "unist-util-visit"

View File

@ -1,4 +1,4 @@
import { Root } from "rehype-raw"
import type { Root } from "hast"
import { Plugin } from "unified"
import { visit } from "unist-util-visit"

View File

@ -1,4 +1,4 @@
import { Root } from "rehype-raw"
import type { Root } from "hast"
import { Plugin } from "unified"
import { visit } from "unist-util-visit"

View File

@ -1,4 +1,4 @@
import { Root } from "rehype-raw"
import type { Root } from "hast"
import { Plugin } from "unified"
import { u } from "unist-builder"
import { visit } from "unist-util-visit"

View File

@ -1,4 +1,4 @@
import { Root } from "rehype-raw"
import type { Root } from "hast"
import { Plugin } from "unified"
import { visit } from "unist-util-visit"

View File

@ -1,10 +1,10 @@
import { Root } from "remark-gfm"
import { Plugin } from "unified"
import type { Root } from "mdast"
import type { Plugin } from "unified"
import { visit } from "unist-util-visit"
const CALLOUT_RE = /^(TIP|WARN|SUCCESS|DANGER):(\n|$)/
export const remarkCallout: Plugin<Array<void>, Root> = () => (tree: Root) => {
export const remarkCallout: Plugin<[], Root> = () => (tree: Root) => {
visit(tree, { type: "blockquote" }, (node, index, parent) => {
if (node.type !== "blockquote") return

View File

@ -1,8 +1,8 @@
import { Root } from "remark-gfm"
import { Plugin } from "unified"
import type { Root } from "mdast"
import type { Plugin } from "unified"
import { visit } from "unist-util-visit"
export const remarkMermaid: Plugin<Array<void>, Root> = () => (tree: Root) => {
export const remarkMermaid: Plugin<[], Root> = () => (tree: Root) => {
visit(tree, (node) => {
if (node.type === "code" && node.lang === "mermaid") {
// @ts-ignore

View File

@ -1,5 +1,5 @@
import type { Root } from "mdast"
import pangu from "pangu"
import type { Root } from "remark-gfm"
import type { Plugin } from "unified"
import { visit } from "unist-util-visit"
@ -26,7 +26,7 @@ function format(value: string) {
return pangu.spacing(value)
}
export const remarkPangu: Plugin<Array<Options>, Root> =
export const remarkPangu: Plugin<[], Root> =
(options = {}) =>
(tree: Root) => {
const settings = Object.assign({}, defaultOptions, options)

View File

@ -1,10 +1,10 @@
import { Root } from "remark-gfm"
import { Plugin } from "unified"
import type { Root } from "mdast"
import type { Plugin } from "unified"
import { visit } from "unist-util-visit"
export const remarkYoutube: Plugin<Array<void>, Root> =
export const remarkYoutube: Plugin<[], Root> =
() => (tree: Root, file: any) => {
visit(tree, (node) => {
visit(tree, (node: any) => {
if (
node.type === "textDirective" ||
node.type === "leafDirective" ||