Skip to content

Commit 8d50fa1

Browse files
committed
opt: lazyload
1 parent 2e93d26 commit 8d50fa1

5 files changed

Lines changed: 20 additions & 10 deletions

File tree

scripts/tags/lib/albums.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ module.exports = ctx => function(args) {
3030
for (let item of (links[args.group] || [])) {
3131
if (item?.url) {
3232
el += `<div class="grid-cell album-card">`
33-
el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
34-
el += `<img src="${item.cover || 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;;"/>`
33+
el += `<a class="card-link lazy-box" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
34+
el += `<img class="lazy" data-src="${item.cover || 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;;"/>`
35+
el += `<div class="lazy-icon" style="background-image:url(${ctx.theme.config.default.loading});"></div>`
3536
el += `<div class="image-meta">`
3637
if (item.title) {
3738
el += `<span class="image-caption">${item.title}</span>`

scripts/tags/lib/gallery.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717

1818
var index = 0
1919

20-
function img(src, alt) {
20+
function img(src, alt, loading) {
2121
let img = ''
22-
img += `<img data-fancybox="gallery-${index}" src="${src}"`
22+
img += `<img class="lazy" data-fancybox="gallery-${index}" data-src="${src}"`
2323
if (alt?.length > 0) {
2424
img += ` alt="${alt}"`
2525
}
2626
img += `/>`
27+
img += `<div class="lazy-icon" style="background-image:url(${loading});"></div>`
2728
// cap
2829
img += `<div class="image-meta">`
2930
if (alt?.length > 0) {
@@ -54,7 +55,7 @@ module.exports = ctx => function(args, content) {
5455
if (matches?.length > 2) {
5556
let alt = matches[1]
5657
let src = matches[2]
57-
el += `<div class="${layoutType}-cell">${img(src, alt)}</div>`
58+
el += `<div class="${layoutType}-cell lazy-box">${img(src, alt, ctx.theme.config.default.loading)}</div>`
5859
}
5960
}
6061
el += `</div>`

scripts/tags/lib/posters.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ module.exports = ctx => function(args) {
3030
for (let item of (links[args.group] || [])) {
3131
if (item?.url) {
3232
el += `<div class="grid-cell poster-card">`
33-
el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
34-
el += `<img src="${item.cover || 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;;"/>`
33+
el += `<a class="card-link lazy-box" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
34+
el += `<img class="lazy" data-src="${item.cover || 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;;"/>`
35+
el += `<div class="lazy-icon" style="background-image:url(${ctx.theme.config.default.loading});"></div>`
3536
el += `<div class="image-meta">`
3637
if (item.title) {
3738
el += `<span class="image-caption">${item.title}</span>`

source/css/_components/tag-plugins/gallery.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
height: 100%
110110
border-radius: 8px
111111
&:has(img.loading),&:has(img.error)
112+
background-color: var(--block)
112113
img
113114
background-color: var(--block)
114115
.image-meta

source/css/_plugins/comments/artalk.styl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
.atk-header,.atk-editor-user-wrap
88
border-bottom: 1px dashed var(--block-border)
99
padding: 0.5rem 1rem
10+
margin: 0
1011
.atk-editor-user-wrap:empty
1112
visibility: hidden
1213
padding: 0
1314
>.atk-bottom
1415
padding: 8px
16+
.atk-state-btn
17+
height: 2rem
18+
border-radius: 100px
19+
.atk-cancel
20+
background: none
1521
.atk-plug-btn
1622
border-radius: 32px
1723
height: 2rem
@@ -77,10 +83,10 @@
7783
--at-color-border: var(--block-border)
7884
--at-color-light: var(--link)
7985
--at-color-bg: var(--card)
80-
--at-color-bg-transl: var(--block-border)
86+
--at-color-bg-transl: var(--card)
8187
--at-color-bg-grey: var(--block)
82-
--at-color-bg-grey-transl: orange
83-
--at-color-bg-light: rgba(29, 161, 242, 1)
88+
--at-color-bg-grey-transl: var(--block-border)
89+
--at-color-bg-light: var(--theme)
8490
--at-color-main: var(--theme)
8591
--at-color-red: $c-red
8692
--at-color-green: $c-green

0 commit comments

Comments
 (0)