fix: filter markdown video href

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-04-25 22:22:34 +08:00
parent 3cc24dd155
commit 52c344d132

View File

@@ -1,11 +1,15 @@
import getColors from 'get-image-colors'
import { marked } from 'marked'
const isVideoExts = ['.mp4', '.webm', '.ogg', '.mov', '.avi', '.flv', '.mkv']
export const pickImagesFromMarkdown = (text: string) => {
const ast = marked.lexer(text)
const images = [] as string[]
function pickImage(node: any) {
if (node.type === 'image') {
if (isVideoExts.some((ext) => node.href.endsWith(ext))) {
return
}
images.push(node.href)
return
}