hexo-theme-butterfly/scripts/tag/gallery.js
Jerry 8014ddb65e feat: 不再支持 butterfly.yml 寫法
improvement: 文章頁標題改為h1(seo)
improvement: 改用hexo 內置的 injector 插入 inject 的代碼
improvement: canonical 改為hexo提供的函數生成
improvement: 優化手機toc 的特效和按鈕出現的時機
remove: 刪除搜索不必要的配置
remove: 移除豆瓣配置,如需配置,請使用 hexo-butterfly-douban
fix: 修復上一個版本導致的搜索按鈕在pjax下無法點擊的bugs close #387
fix: 修復上一個版本更新的toc z-index 過低的bugs
2020-10-15 00:14:38 +08:00

35 lines
788 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" src='${img}'>
<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)