Merge pull request #1769 from Void4m0n/add-post-pagination-cover-dev

Allow to set specific post pagination cover
This commit is contained in:
Jerry Wong
2025-12-10 19:19:34 +08:00
committed by GitHub
2 changed files with 6 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ if page.total !== 1
a.pagination-related(class=className href=url_for(direction.path) title=direction.title)
if direction.cover_type === 'img'
img.cover(src=url_for(direction.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt=`cover of ${key === 'prev' ? 'previous' : 'next'} post`)
img.cover(src=url_for(direction.pagination_cover || direction.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt=`cover of ${key === 'prev' ? 'previous' : 'next'} post`)
else
.cover(style=`background: ${direction.cover || 'var(--default-bg-color)'}`)
@@ -35,4 +35,4 @@ if page.total !== 1
.pagination
if globalPageType === 'home'
- options.format = 'page/%d/#content-inner'
!=paginator(options)
!=paginator(options)

View File

@@ -34,7 +34,7 @@ hexo.extend.generator.register('post', locals => {
const handleImg = data => {
const imgTestReg = /\.(png|jpe?g|gif|svg|webp|avif)(\?.*)?$/i
let { cover: coverVal, top_img: topImg } = data
let { cover: coverVal, top_img: topImg, pagination_cover: paginationCover } = data
// Add path to top_img and cover if post_asset_folder is enabled
if (hexo.config.post_asset_folder) {
@@ -44,6 +44,9 @@ hexo.extend.generator.register('post', locals => {
if (coverVal && coverVal.indexOf('/') === -1 && imgTestReg.test(coverVal)) {
data.cover = `${data.path}${coverVal}`
}
if (paginationCover && paginationCover.indexOf('/') === -1 && imgTestReg.test(paginationCover)) {
data.pagination_cover = `${data.path}${paginationCover}`
}
}
if (coverVal === false) return data