只需将 twikoo.pug 中对应的代码修改如下 (直接抄自 main.js)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| twikoo.init(Object.assign({ el: '#twikoo-wrap', envId: '!{theme.twikoo.envId}', region: '!{theme.twikoo.region}', onCommentLoaded: function () { if(typeof window.mediumZoom!='undefined'){ const zoomComment = mediumZoom(document.querySelectorAll('.tk-content :not(a)>img')) zoomComment.on('open', e => { const photoBg = document.documentElement.getAttribute('data-theme') === 'dark' ? '#121212' : '#fff' zoomComment.update({ background: photoBg }) }) } if(GLOBAL_CONFIG.lightbox === 'fancybox'){ const addFancybox = function (ele) { const runFancybox = (ele) => { ele.each(function (i, o) { const $this = $(o) const lazyloadSrc = $this.attr('data-lazy-src') || $this.attr('src') const dataCaption = $this.attr('alt') || '' $this.wrap(`<a href="${lazyloadSrc}" data-fancybox="group" data-caption="${dataCaption}" class="fancybox"></a>`) })
$().fancybox({ selector: '[data-fancybox]', loop: true, transitionEffect: 'slide', protect: true, buttons: ['slideShow', 'fullScreen', 'thumbs', 'close'], hash: false }) }
if (typeof $.fancybox === 'undefined') { $('head').append(`<link rel="stylesheet" type="text/css" href="${GLOBAL_CONFIG.source.fancybox.css}">`) $.getScript(`${GLOBAL_CONFIG.source.fancybox.js}`, function () { runFancybox($(ele)) }) } else { runFancybox($(ele)) } } addFancybox(document.querySelectorAll('.tk-content :not(a)>img')) } } }, !{JSON.stringify(theme.twikoo.option)}))
|