test/node_modules/@vuepress/plugin-seo/lib/node/utils/getCover.js
2024-08-13 09:27:52 +08:00

19 lines
607 B
JavaScript

import { isLinkAbsolute, isLinkWithProtocol } from '@vuepress/helper';
import { getUrl } from './getUrl.js';
export const getCover = ({ frontmatter }, { options: { base } }, { hostname }) => {
const { banner, cover } = frontmatter;
if (banner) {
if (isLinkAbsolute(banner))
return getUrl(hostname, base, banner);
if (isLinkWithProtocol(banner))
return banner;
}
if (cover) {
if (isLinkAbsolute(cover))
return getUrl(hostname, base, cover);
if (isLinkWithProtocol(cover))
return cover;
}
return null;
};