fix: build errors
This commit is contained in:
parent
d04bab2d44
commit
e72170a4bc
|
|
@ -4,7 +4,7 @@ import { visit } from "unist-util-visit"
|
|||
|
||||
const CALLOUT_RE = /^(TIP|WARN|SUCCESS|DANGER):(\n|$)/
|
||||
|
||||
export const remarkCallout: Plugin<Array<void>, Root> = () => (tree) => {
|
||||
export const remarkCallout: Plugin<Array<void>, Root> = () => (tree: Root) => {
|
||||
visit(tree, { type: "blockquote" }, (node, index, parent) => {
|
||||
if (node.type !== "blockquote") return
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Root } from "remark-gfm"
|
|||
import { Plugin } from "unified"
|
||||
import { visit } from "unist-util-visit"
|
||||
|
||||
export const remarkMermaid: Plugin<Array<void>, Root> = () => (tree, file) => {
|
||||
export const remarkMermaid: Plugin<Array<void>, Root> = () => (tree: Root) => {
|
||||
visit(tree, (node) => {
|
||||
if (node.type === "code" && node.lang === "mermaid") {
|
||||
// @ts-ignore
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ function format(value: string) {
|
|||
|
||||
export const remarkPangu: Plugin<Array<Options>, Root> =
|
||||
(options = {}) =>
|
||||
(tree, _) => {
|
||||
(tree: Root) => {
|
||||
const settings = Object.assign({}, defaultOptions, options)
|
||||
const subset = (Object.keys(settings) as Array<keyof Options>).filter(
|
||||
(k) => settings[k],
|
||||
|
|
|
|||
|
|
@ -2,51 +2,52 @@ import { Root } from "remark-gfm"
|
|||
import { Plugin } from "unified"
|
||||
import { visit } from "unist-util-visit"
|
||||
|
||||
export const remarkYoutube: Plugin<Array<void>, Root> = () => (tree, file) => {
|
||||
visit(tree, (node) => {
|
||||
if (
|
||||
node.type === "textDirective" ||
|
||||
node.type === "leafDirective" ||
|
||||
node.type === "containerDirective"
|
||||
) {
|
||||
if (node.name !== "youtube") return
|
||||
export const remarkYoutube: Plugin<Array<void>, Root> =
|
||||
() => (tree: Root, file: any) => {
|
||||
visit(tree, (node) => {
|
||||
if (
|
||||
node.type === "textDirective" ||
|
||||
node.type === "leafDirective" ||
|
||||
node.type === "containerDirective"
|
||||
) {
|
||||
if (node.name !== "youtube") return
|
||||
|
||||
const data = node.data || (node.data = {})
|
||||
const attributes = node.attributes || {}
|
||||
const id = attributes.id
|
||||
const data = node.data || (node.data = {})
|
||||
const attributes = node.attributes || {}
|
||||
const id = attributes.id
|
||||
|
||||
if (node.type === "textDirective")
|
||||
file.fail("Text directives for `youtube` not supported", node)
|
||||
if (!id) file.fail("Missing video id", node)
|
||||
if (node.type === "textDirective")
|
||||
file.fail("Text directives for `youtube` not supported", node)
|
||||
if (!id)
|
||||
file.fail("Missing video id", node)(data as any).hName =
|
||||
"div" as string
|
||||
;(data as any).hProperties = {
|
||||
className: ["xlog-post-content-youtube"],
|
||||
style: "position: relative; padding-bottom: 56.25%; height: 0;",
|
||||
}
|
||||
|
||||
data.hName = "div"
|
||||
data.hProperties = {
|
||||
className: ["xlog-post-content-youtube"],
|
||||
style: "position: relative; padding-bottom: 56.25%; height: 0;",
|
||||
}
|
||||
|
||||
node.children = [
|
||||
{
|
||||
type: "leafDirective",
|
||||
data: {
|
||||
hName: "iframe",
|
||||
hProperties: {
|
||||
src: "https://www.youtube.com/embed/" + id,
|
||||
width: 728,
|
||||
height: 409.5,
|
||||
frameBorder: 0,
|
||||
allow:
|
||||
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
||||
allowFullScreen: true,
|
||||
title: "YouTube video player",
|
||||
style:
|
||||
"position: absolute; top: 0; left: 0; width: 100%; height: 100%;",
|
||||
node.children = [
|
||||
{
|
||||
type: "leafDirective",
|
||||
data: {
|
||||
hName: "iframe",
|
||||
hProperties: {
|
||||
src: "https://www.youtube.com/embed/" + id,
|
||||
width: 728,
|
||||
height: 409.5,
|
||||
frameBorder: 0,
|
||||
allow:
|
||||
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
||||
allowFullScreen: true,
|
||||
title: "YouTube video player",
|
||||
style:
|
||||
"position: absolute; top: 0; left: 0; width: 100%; height: 100%;",
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
name: "iframe",
|
||||
},
|
||||
children: [],
|
||||
name: "iframe",
|
||||
},
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue