You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.7 KiB
57 lines
2.7 KiB
mixin renderLinkPreview (link, options)
|
|
-
|
|
options = Object.assign({ layout: 'responsive' }, options);
|
|
function proxyUrl (url) {
|
|
return `/image/proxy?url=${encodeURIComponent(url)}`;
|
|
}
|
|
|
|
div(data-link-id= link._id).link-container
|
|
case link.mediaType
|
|
when 'video.other'
|
|
.link-preview
|
|
if !link.oembed
|
|
pre= JSON.stringify(link, null, 2)
|
|
else
|
|
if link.oembed.html
|
|
div!= link.oembed.html
|
|
else
|
|
.uk-margin-small
|
|
a(href= link.url, target="_blank", uk-tooltip={ title: `Watch ${link.title} on ${link.oembed.provider_name}` }).uk-link-reset
|
|
img(src= link.images[0])
|
|
.uk-margin-small
|
|
.uk-text-lead.uk-text-truncate
|
|
a(href= link.url, target="_blank", uk-tooltip={ title: `Watch ${link.title} on ${link.oembed.provider_name}` }).uk-link-reset= link.title
|
|
.uk-text-small author: #[a(href= link.oembed.author_url, target="_blank", uk-tooltip={ title: `Visit ${link.oembed.author_name} on ${link.oembed.provider_name}` })= link.oembed.author_name]
|
|
.markdown-block.link-description.uk-text-break!= marked.parse(link.oembed.description || link.description || 'No description provided', { renderer: fullMarkedRenderer })
|
|
|
|
default
|
|
div(uk-grid).uk-grid-small.link-preview
|
|
if Array.isArray(link.images) && (link.images.length > 0)
|
|
div(data-layout= options.layout).uk-width-auto
|
|
a(href= link.url,
|
|
data-link-id= link._id,
|
|
onclick= "return dtp.app.visitLink(event);",
|
|
).uk-link-reset
|
|
img(src= proxyUrl(link.images[0])).link-thumbnail.uk-border-rounded
|
|
|
|
div(class="uk-width-1-1 uk-width-expand@s")
|
|
.uk-margin-small
|
|
.uk-text-bold.uk-margin-small
|
|
a(ref= link.url,
|
|
data-link-id= link._id,
|
|
onclick= "return dtp.app.visitLink(event);",
|
|
).uk-link-reset= link.title
|
|
|
|
.markdown-block.link-description.uk-text-break!= marked.parse(link.description || 'No description provided', { renderer: fullMarkedRenderer })
|
|
|
|
.uk-flex.uk-flex-middle.uk-text-small
|
|
if Array.isArray(link.favicons) && (link.favicons.length > 0)
|
|
.uk-width-auto
|
|
img(
|
|
src= proxyUrl(link.favicons[0]),
|
|
style="height: 1em; width: auto;",
|
|
onerror=`this.src = '/img/icon/globe-icon.svg';`,
|
|
)
|
|
.uk-width-expand
|
|
.uk-margin-small-left
|
|
a(href=`//${link.domain}`, target="_blank", uk-tooltip={ title: link.mediaType })= link.siteName || link.domain
|