import axios from 'axios'; import { IJodit } from 'jodit/src/types'; const getMetaTags = async ( jodit: IJodit, url: string ): Promise> => { const { data } = await axios.get(jodit.o.metaTagApi, { params: { url } }); return data; }; const joditLinkPreviewTemplate = ({ title = '', description = '', image, url = '', domain = '' }: { title?: string; description?: string; image?: string; url?: string; domain?: string; }): string => { return ` ${ image ? `` : '' } ${title} ${description} ${domain} `; }; const getJoditLinkPreviewByUrl = async ( jodit: IJodit, url: string ): Promise => { const metaTags = await getMetaTags(jodit, url); const domain = new URL(url).hostname; return joditLinkPreviewTemplate({ ...metaTags, domain, url }); }; export default getJoditLinkPreviewByUrl;