fuc-new/doc/node_modules/@vuepress/plugin-seo/lib/node/utils/getImages.js
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

13 lines
486 B
JavaScript

import { isLinkAbsolute, isLinkWithProtocol } from '@vuepress/helper';
import { getUrl } from './getUrl.js';
const IMAGE_REG_EXP = /!\[.*?\]\((.*?)\)/gu;
export const getImages = ({ content }, { options: { base } }, hostname) => Array.from(content.matchAll(IMAGE_REG_EXP))
.map(([, link]) => {
if (isLinkAbsolute(link))
return getUrl(hostname, base, link);
if (isLinkWithProtocol(link))
return link;
return null;
})
.filter((item) => item !== null);