[feat] tag-plugin: albums

This commit is contained in:
xaoxuu 2024-01-03 00:32:19 +08:00
parent 4c10b83e14
commit 8d02f6af66
15 changed files with 159 additions and 177 deletions

View File

@ -333,7 +333,7 @@ plugins:
# 可以处理评论区的图片(不支持 iframe 类评论系统)例如: # 可以处理评论区的图片(不支持 iframe 类评论系统)例如:
# 使用twikoo评论可以写: .tk-content img:not([class*="emo"]) # 使用twikoo评论可以写: .tk-content img:not([class*="emo"])
# 使用waline评论可以写: #waline_container .vcontent img # 使用waline评论可以写: #waline_container .vcontent img
selector: .swiper-slide img, .gallery img # 多个选择器用英文逗号隔开 selector: .fancybox img # 多个选择器用英文逗号隔开
# swiper # swiper
swiper: swiper:

View File

@ -16,6 +16,7 @@ hexo.extend.tag.register('banner', require('./lib/banner')(hexo), true)
// data // data
hexo.extend.tag.register('users', require('./lib/friends')(hexo)) hexo.extend.tag.register('users', require('./lib/friends')(hexo))
hexo.extend.tag.register('friends', require('./lib/friends')(hexo)) hexo.extend.tag.register('friends', require('./lib/friends')(hexo))
hexo.extend.tag.register('albums', require('./lib/albums')(hexo))
hexo.extend.tag.register('sites', require('./lib/sites')(hexo)) hexo.extend.tag.register('sites', require('./lib/sites')(hexo))
hexo.extend.tag.register('ghcard', require('./lib/ghcard')(hexo)) hexo.extend.tag.register('ghcard', require('./lib/ghcard')(hexo))
hexo.extend.tag.register('toc', require('./lib/toc')(hexo)) hexo.extend.tag.register('toc', require('./lib/toc')(hexo))

View File

@ -0,0 +1,47 @@
/**
* albums.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
* 格式与官方标签插件一致使用空格分隔中括号内的是可选参数中括号不需要写出来
*
* {% albums [group] [repo:owner/repo] [api:http] [size:s/m/l/xl/mix] %}
*/
'use strict'
module.exports = ctx => function(args) {
var args = ctx.args.map(args, ['repo', 'api', 'size'], ['group'])
if (args.size == null) {
args.size = 's'
}
var api
if (args.api) {
api = args.api
} else if (args.repo) {
api = 'https://api.vlts.cc/output_data/v2/' + args.repo
}
var el = ''
el += `<div class="tag-plugin albums-wrap">`
if (api) {
el += `<div class="stellar-friends-api" api="${api}"><div class="tag-plugin gallery grid-box" layout="grid" ratio="square" ${ctx.args.joinTags(args, ['size']).join(' ')}></div></div>`
} else if (args.group) {
const links = ctx.theme.config.links || {}
el += `<div class="tag-plugin gallery grid-box" layout="grid" ratio="square" ${ctx.args.joinTags(args, ['size']).join(' ')}>`
for (let item of (links[args.group] || [])) {
if (item?.url) {
el += `<div class="grid-cell album-card">`
el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
el += `<img src="${item.icon || item.avatar || ctx.theme.config.default.cover}" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;${ctx.theme.config.default.cover}&quot;;"/>`
el += `<div class="image-meta">`
if (item.title) {
el += `<span class="image-caption">${item.title}</span>`
}
el += `</div>`
el += `</a>`
el += `</div>`
}
}
el += `</div>`
}
el += `</div>`
return el
}

View File

@ -9,10 +9,6 @@
module.exports = ctx => function(args) { module.exports = ctx => function(args) {
args = ctx.args.map(args, ['repo', 'api'], ['group']) args = ctx.args.map(args, ['repo', 'api'], ['group'])
var links = ctx.theme.config.links
if (links == undefined) {
links = {}
}
var api var api
if (args.api) { if (args.api) {
api = args.api api = args.api
@ -22,29 +18,22 @@ module.exports = ctx => function(args) {
var el = '<div class="tag-plugin users-wrap">' var el = '<div class="tag-plugin users-wrap">'
if (api) { if (api) {
el += '<div class="stellar-friends-api"' el += `<div class="stellar-friends-api" ${ctx.args.joinTags(args, ['size']).join(' ')} api="${api}"><div class="grid-box"></div></div>`
el += ' api="' + api + '"'
el += '>'
el += '<div class="group-body"></div>'
el += '</div>'
} else if (args.group) { } else if (args.group) {
function cell(item) { const links = ctx.theme.config.links || {}
if (item.url && item.title) { el += '<div class="grid-box">'
var cell = '<div class="user-card">' for (let item of (links[args.group] || [])) {
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">' if (item?.url && item?.title) {
cell += '<img src="' + (item.icon || item.avatar || ctx.theme.config.default.avatar) + '" onerror="javascript:this.removeAttribute(&quotdata-src&quot)this.src=&quot' + ctx.theme.config.default.avatar + '&quot"/>' el += `<div class="grid-cell user-card">`
cell += '<div class="name"><span>' + item.title + '</span></div>' el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
cell += '</a></div>' el += `<img src="${item.icon || item.avatar || ctx.theme.config.default.avatar}" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;${ctx.theme.config.default.avatar}&quot;;"/>`
return cell el += `<div class="name">`
} else { el += `<span>${item.title}</span>`
return '' el += `</div>`
el += `</a>`
el += `</div>`
} }
} }
el += '<div class="group-body">'
const items = links[args.group] || []
items.forEach((item, i) => {
el += cell(item)
})
el += '</div>' el += '</div>'
} }

View File

@ -33,9 +33,6 @@ function img(src, alt) {
module.exports = ctx => function(args, content) { module.exports = ctx => function(args, content) {
args = ctx.args.map(args, ['layout', 'size', 'ratio']) args = ctx.args.map(args, ['layout', 'size', 'ratio'])
if (args.layout == null) {
args.layout = ctx.theme.config.tag_plugins.gallery.layout
}
if (args.size == null) { if (args.size == null) {
args.size = ctx.theme.config.tag_plugins.gallery.size args.size = ctx.theme.config.tag_plugins.gallery.size
} }
@ -43,14 +40,18 @@ module.exports = ctx => function(args, content) {
args.ratio = ctx.theme.config.tag_plugins.gallery.ratio args.ratio = ctx.theme.config.tag_plugins.gallery.ratio
} }
var el = '' var el = ''
el += `<div class="tag-plugin gallery" ${ctx.args.joinTags(args, ['layout', 'size', 'ratio']).join(' ')}>` var layoutType = 'grid'
if (args.layout == 'flow') {
layoutType = 'flow'
}
el += `<div class="tag-plugin gallery fancybox ${layoutType}-box" ${ctx.args.joinTags(args, ['size', 'ratio']).join(' ')}>`
const img_mds = content.split('\n').filter(item => item.trim().length > 0) const img_mds = content.split('\n').filter(item => item.trim().length > 0)
for (let md of img_mds) { for (let md of img_mds) {
const matches = md.match(/\!\[(.*?)\]\((.*?)\)/i) const matches = md.match(/\!\[(.*?)\]\((.*?)\)/i)
if (matches?.length > 2) { if (matches?.length > 2) {
let alt = matches[1] let alt = matches[1]
let src = matches[2] let src = matches[2]
el += `<div class="cell">${img(src, alt)}</div>` el += `<div class="${layoutType}-cell">${img(src, alt)}</div>`
} }
} }
el += `</div>` el += `</div>`

View File

@ -9,10 +9,6 @@
module.exports = ctx => function(args) { module.exports = ctx => function(args) {
args = ctx.args.map(args, ['repo', 'api'], ['group']) args = ctx.args.map(args, ['repo', 'api'], ['group'])
var links = ctx.theme.config.links
if (links == undefined) {
links = {}
}
var api var api
if (args.api) { if (args.api) {
api = args.api api = args.api
@ -25,30 +21,25 @@ module.exports = ctx => function(args) {
el += '<div class="stellar-sites-api"' el += '<div class="stellar-sites-api"'
el += ' api="' + api + '"' el += ' api="' + api + '"'
el += '>' el += '>'
el += '<div class="group-body"></div>' el += '<div class="grid-box"></div>'
el += '</div>' el += '</div>'
} else if (args.group) { } else if (args.group) {
function cell(item) { const links = ctx.theme.config.links || {}
if (item.url && item.title) { el += '<div class="grid-box">'
var cell = '<div class="site-card">' for (let item of (links[args.group] || [])) {
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">' if (item?.url && item?.title) {
cell += '<img src="' + (item.cover || item.screenshot || ('https://api.vlts.cc/screenshot?url=' + item.url + '&width=1280&height=720')) + '" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;' + ctx.theme.config.default.cover + '&quot;;"/>' el += `<div class="grid-cell site-card">`
cell += '<div class="info">' el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
cell += '<img src="' + (item.icon || item.avatar || ctx.theme.config.default.link) + '" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;' + ctx.theme.config.default.link + '&quot;;"/>' el += `<img src="${item.cover || item.screenshot || ('https://api.vlts.cc/screenshot?url=' + item.url + '&width=1280&height=720')}" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;${ctx.theme.config.default.cover}&quot;;"/>`
cell += '<span class="title">' + item.title + '</span>' el += `<div class="info">`
cell += '<span class="desc">' + (item.description || item.url) + '</span>' el += `<img src="${item.icon || item.avatar || ctx.theme.config.default.link}" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;${item.icon || item.avatar || ctx.theme.config.default.link}&quot;;"/>`
cell += '</div>' el += `<span class="title">${item.title}</span>`
cell += '</a></div>' el += `<span class="desc">${item.description || item.url}</span>`
return cell el += `</div>`
} else { el += `</a>`
return '' el += `</div>`
} }
} }
el += '<div class="group-body">'
const items = links[args.group] || []
items.forEach((item, i) => {
el += cell(item)
})
el += '</div>' el += '</div>'
} }

View File

@ -22,7 +22,7 @@ module.exports = ctx => function(args, content) {
}) })
} }
} }
el += '<div class="tag-plugin swiper" id="swiper-api"' el += '<div class="tag-plugin swiper fancybox" id="swiper-api"'
el += ' ' + ctx.args.joinTags(args, ['width', 'effect']).join(' ') el += ' ' + ctx.args.joinTags(args, ['width', 'effect']).join(' ')
el += '>' el += '>'
el += '<div class="swiper-wrapper">' el += '<div class="swiper-wrapper">'

View File

@ -37,12 +37,12 @@
background: none background: none
line-height: 1.5 line-height: 1.5
font-size: $fs-15 font-size: $fs-15
&:hover
color: white
background: rgba(black, 0.5)
&.active &.active
color: white color: white
background: rgba(white, 0.25) background: rgba(white, 0.25)
&:hover
color: white
background: rgba(black, 0.5) !important
.back .back
background: none background: none
padding: 0 padding: 0

View File

@ -1,42 +1,9 @@
.users-wrap .users-wrap .grid-box
overflow: hidden display: grid
.group-header grid-template-columns: repeat(auto-fill, minmax(80px, 1fr))
margin: 0 0 1rem
p
margin: 0
font-size: $fs-14
&:first-child
font-size: 1.25rem
font-weight: 500
.group-body
width: 100%
display: flex
flex-wrap: wrap
align-items: stretch
&+.group-header
margin-top: 2rem
.stellar-friends-api
display: block
.users-wrap .user-card .users-wrap .user-card
flex-shrink: 1
display: flex
align-items: stretch
width: 12.5%
@media screen and (max-width: 980px)
width: 14.28%
@media screen and (max-width: 900px)
width: 16.66%
@media screen and (max-width: 820px)
width: 20%
@media screen and (max-width: $device-mobile-max)
width: 16.66%
@media screen and (max-width: $device-mobile)
width: 25%
.card-link .card-link
margin: 0
width: 100%
color: var(--text-p1) color: var(--text-p1)
font-size: 10px font-size: 10px
font-weight: 500 font-weight: 500
@ -50,6 +17,9 @@
overflow: hidden overflow: hidden
position: relative position: relative
padding: 1rem 0.5rem padding: 1rem 0.5rem
.name
max-width: 100%
txt-ellipsis()
img img
object-fit: cover object-fit: cover
display: block display: block

View File

@ -1,5 +1,5 @@
.tag-plugin.gallery .tag-plugin.gallery
.cell .grid-cell,.flow-cell
display: block display: block
overflow hidden overflow hidden
z-index 0 z-index 0
@ -30,66 +30,80 @@
display: block display: block
font-size: $fs-13 font-size: $fs-13
color: transparent color: transparent
pointer-events: none
line-height: 1.2 line-height: 1.2
margin: 0.5rem margin: 0.5rem
trans1(color) trans1(color)
text-align: left
&:empty &:empty
display: none display: none
.tag-plugin.gallery[layout='grid'] .cell .tag-plugin.gallery .grid-cell
trans1(transform, 0.5s) img
trans1(transform, 0.5s)
&:hover &:hover
img img
transform: scale(1.1) transform: scale(1.1)
// //
.tag-plugin.gallery[layout='grid'] .tag-plugin.gallery.grid-box
display: grid display: grid
&[size='xs']
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr))
grid-gap: 2px
.grid-cell,img
border-radius: 2px
.image-caption
font-size: $fs-12
&[size='s'] &[size='s']
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) grid-template-columns: repeat(auto-fill, minmax(100px, 1fr))
grid-gap: 2px grid-gap: 2px
.cell,img .grid-cell,img
border-radius: 2px border-radius: 2px
&[size='m'] &[size='m']
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
grid-gap: 4px grid-gap: 4px
.cell,img .grid-cell,img
border-radius: 4px border-radius: 4px
&[size='l'] &[size='l']
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))
grid-gap: 8px grid-gap: 8px
.cell,img .grid-cell,img
border-radius: 8px border-radius: 8px
&[size='xl'] // 2 &[size='xl'] // 2
grid-template-columns: repeat(2, 1fr) grid-template-columns: repeat(2, 1fr)
grid-gap: 16px grid-gap: 16px
.cell,img .grid-cell,img
border-radius: 16px border-radius: 16px
&[size='mix'] // 1+2 &[size='mix'] // 1+2
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
grid-gap: 4px grid-gap: 4px
.cell,img .grid-cell,img
border-radius: 4px border-radius: 4px
.cell .grid-cell
&:nth-child(3n+1) &:nth-child(3n+1)
grid-column: auto / span 2 grid-column: auto / span 2
grid-row: auto / span 2 grid-row: auto / span 2
&[ratio='square'] &[ratio='square']
.cell .grid-cell
aspect-ratio: 1 aspect-ratio: 1
.cell .grid-cell
background: var(--block) background: var(--block)
img img
width: 100% width: 100%
height: 100% height: 100%
// //
.tag-plugin.gallery[layout='flow'] .tag-plugin.gallery.flow-box
column-count: 3 column-count: 3
column-gap: 8px column-gap: 8px
.cell .flow-cell
border-radius: 8px border-radius: 8px
padding-bottom: 8px padding-bottom: 8px
img
width: 100%
height: 100%
.image-meta .image-meta
border-radius: 8px border-radius: 8px
margin-bottom: 8px margin-bottom: 8px

View File

@ -1,46 +1,19 @@
.sites-wrap .sites-wrap .grid-box
.group-header
margin: 1rem 0
p
margin: 0
font-size: $fs-14
&:first-child
font-size: 1.25rem
font-weight: 500
.group-body
width: 100%
&+.group-header
margin-top: 2rem
.stellar-sites-api
display: block
.sites-wrap .group-body
display: grid display: grid
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
grid-gap: 1rem 1rem grid-gap: 1rem 1rem
grid-template-columns: repeat(auto-fill, "calc((100% - 3 * %s) / 4)" % 1rem) .grid-cell
@media screen and (max-width: $device-laptop) aspect-ratio: 1.5
grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 1rem)
@media screen and (max-width: 900px)
grid-template-columns: repeat(auto-fill, "calc((100% - 1 * %s) / 2)" % 1rem)
@media screen and (max-width: $device-mobile-max)
grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 1rem)
@media screen and (max-width: $device-mobile)
grid-template-columns: repeat(auto-fill, "calc((100% - 1 * %s) / 2)" % 1rem)
.sites-wrap .group-body .site-card .card-link .sites-wrap .site-card .card-link
width: 100% width: 100%
display: flex display: flex
flex-direction: column flex-direction: column
>img >img
width: 100%
height 100px
@media screen and (max-width: $device-laptop)
height: 120px
@media screen and (max-width: 900px)
height: 150px
@media screen and (max-width: $device-tablet)
height: 120px
object-fit: cover object-fit: cover
aspect-ratio: 1.5
width: 100%
height: 100%
box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.2) box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.2)
.info .info
margin-top: 0.5rem margin-top: 0.5rem
@ -71,7 +44,7 @@
display: -webkit-box display: -webkit-box
-webkit-box-orient: vertical -webkit-box-orient: vertical
overflow: hidden overflow: hidden
-webkit-line-clamp: 2 -webkit-line-clamp: 1
// transform // transform
.sites-wrap .site-card .card-link .sites-wrap .site-card .card-link

View File

@ -1,9 +1,6 @@
img[fancybox='true'] img[fancybox='true']
cursor: zoom-in cursor: zoom-in
.swiper-slide .fancybox
cursor: zoom-in
.tag-plugin.gallery
img img
cursor: zoom-in cursor: zoom-in

View File

@ -14,9 +14,9 @@ if hexo-config('plugins.lazyload.transition') == 'blur'
&.loaded,&.error &.loaded,&.error
filter none filter none
-webkit-filter none -webkit-filter none
.group-body .site-card .card-link>img .site-card .card-link>img
trans-site filter trans-site filter
.group-body .user-card .card-link>img .user-card .card-link>img
trans-user filter trans-user filter
else else
img.lazy img.lazy
@ -25,7 +25,7 @@ else
opacity: 0 opacity: 0
&.loaded,&.error &.loaded,&.error
opacity: 1 opacity: 1
.group-body .site-card .card-link>img .site-card .card-link>img
trans-site opacity trans-site opacity
.group-body .user-card .card-link>img .user-card .card-link>img
trans-user opacity trans-user opacity

View File

@ -47,17 +47,17 @@ const friendsjs = {
$(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>'); $(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>');
friendsjs.requestAPI(cfg.api, function(data) { friendsjs.requestAPI(cfg.api, function(data) {
$(el).find('.loading-wrap').remove(); $(el).find('.loading-wrap').remove();
const arr = data.content || data; for (let item of (data.content || data)) {
arr.forEach((item, i) => { var cell = `<div class="grid-cell user-card">`;
var user = '<div class="user-card">'; cell += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.html_url || item.url}">`;;
user += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer"'; cell += `<img src="${item.avatar_url || item.avatar || item.icon || cfg.avatar}" onerror="javascript:this.removeAttribute(\'data-src\');this.src=\'${cfg.avatar}\';"/>`;
user += ' href="' + (item.html_url || item.url) + '">'; cell += `<div class="name image-meta">`;
user += '<img src="' + (item.avatar_url || item.avatar || item.icon || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';">'; cell += `<span class="image-caption">${item.title || item.login}</span>`;
user += '<div class="name"><span>' + (item.title || item.login) + '</span></div>'; cell += `</div>`;
user += '</a>'; cell += `</a>`;
user += '</div>'; cell += `</div>`;
$(el).find('.group-body').append(user); $(el).find('.grid-box').append(cell);
}); }
}, function() { }, function() {
$(el).find('.loading-wrap svg').remove(); $(el).find('.loading-wrap svg').remove();
$(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>'); $(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>');

View File

@ -47,20 +47,19 @@ const sitesjs = {
$(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>'); $(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>');
sitesjs.requestAPI(cfg.api, function(data) { sitesjs.requestAPI(cfg.api, function(data) {
$(el).find('.loading-wrap').remove(); $(el).find('.loading-wrap').remove();
const arr = data.content; for (let item of data.content) {
arr.forEach((item, i) => { var cell = `<div class="grid-cell site-card">`;
var cell = '<div class="site-card">'; cell += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`;
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">'; cell += `<img src="${item.cover || item.screenshot}" onerror="javascript:this.removeAttribute(\'data-src\');this.src=\'${cfg.screenshot}\';"/>`;
cell += '<img src="' + (item.cover || item.screenshot || ('https://api.vlts.cc/screenshot?url=' + item.url + '&width=1280&height=720')) + '" onerror="javascript:this.src=\'' + cfg.screenshot + '\';"/>'; cell += `<div class="info">`;
cell += '<div class="info">'; cell += `<img src="${item.icon || item.avatar || cfg.avatar}" onerror="javascript:this.removeAttribute(\'data-src\');this.src=\'${cfg.avatar}\';"/>`;
cell += '<img src="' + (item.icon || item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';"/>'; cell += `<span class="title">${item.title}</span>`;
cell += '<span class="title">' + item.title + '</span>'; cell += `<span class="desc">${item.description || item.url}</span>`;
cell += '<span class="desc">' + (item.description || item.url) + '</span>'; cell += `</div>`;
cell += '</div>'; cell += `</a>`;
cell += '</a>'; cell += `</div>`;
cell += '</div>'; $(el).find('.grid-box').append(cell);
$(el).find('.group-body').append(cell); }
});
}, function() { }, function() {
$(el).find('.loading-wrap svg').remove(); $(el).find('.loading-wrap svg').remove();
$(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>'); $(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>');