hexo-theme-butterfly/scripts/tag/gallery.js
Jerry 7210f5b431 breaking changes: toc 配置更改,頁面支持 toc 顯示 close #636
feat: 代碼框設置高度限制,展開後按鈕不會消失,可點擊再次摺疊 close #637
feat: 增加 no-lightbox class 偵測,可配置 fancybox 和 medium-zoom 不應用於圖片 #636
fix: 修復開啟 lazyload 時, fancybox 的縮略圖顯示 lazyload 加載圖片的 bug
2021-08-18 00:07:31 +08:00

35 lines
826 B
JavaScript

/**
* Butterfly
* galleryGroup and allery
*/
'use strict'
const urlFor = require('hexo-util').url_for.bind(hexo)
function gallery (args, content) {
return `<div class="justified-gallery">${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')}
</div>`
}
function galleryGroup (args) {
const name = args[0]
const desrc = args[1]
const url = urlFor(args[2])
const img = urlFor(args[3])
return `
<figure class="gallery-group">
<img class="gallery-group-img no-lightbox" src='${img}' alt="Group Image Gallery">
<figcaption>
<div class="gallery-group-name">${name}</div>
<p>${desrc}</p>
<a href='${url}'></a>
</figcaption>
</figure>
`
}
hexo.extend.tag.register('gallery', gallery, { ends: true })
hexo.extend.tag.register('galleryGroup', galleryGroup)