linkcard
This commit is contained in:
parent
d3c4f4eb83
commit
8045326a85
|
@ -31,8 +31,9 @@ function renderer(el, obj) {
|
||||||
if (obj.icon && obj.icon.length > 0) {
|
if (obj.icon && obj.icon.length > 0) {
|
||||||
el.querySelector('.img').style = 'background-image: url("' + obj.icon + '");';
|
el.querySelector('.img').style = 'background-image: url("' + obj.icon + '");';
|
||||||
}
|
}
|
||||||
if (obj.desc && obj.desc.length > 0) {
|
let desc = el.querySelector('.desc');
|
||||||
el.querySelector('.desc').innerHTML = obj.desc;
|
if (desc && obj.desc && obj.desc.length > 0) {
|
||||||
|
desc.innerHTML = obj.desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +54,12 @@ function getInfo(el, html, link) {
|
||||||
title = title.textContent
|
title = title.textContent
|
||||||
|
|
||||||
// Get the src of the first img tag in the body tag
|
// Get the src of the first img tag in the body tag
|
||||||
// icon = doc.querySelector('body img')
|
let tmp = doc.querySelector('head link[rel="apple-touch-icon"]')
|
||||||
// icon = icon && icon.getAttribute('src')
|
if (!tmp) {
|
||||||
|
tmp = doc.querySelector('head link[rel="icon"]')
|
||||||
|
}
|
||||||
|
icon = tmp && tmp.getAttribute('href')
|
||||||
|
|
||||||
if (/^data:image/.test(icon)) icon = ''
|
if (/^data:image/.test(icon)) icon = ''
|
||||||
|
|
||||||
// If there is no src then get the site icon
|
// If there is no src then get the site icon
|
||||||
|
|
Loading…
Reference in New Issue