mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-08 12:07:06 +08:00
fix: 修復 pagination UI 顯示異常的 bug
fix: 修復 footer_img 配置不生效的 bug improvement: 優化 背景url 的判斷 feat: 背景圖片配置不再需要添加 url()
This commit is contained in:
@@ -87,7 +87,18 @@ hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) {
|
||||
return loop(menu) || defaultTitle
|
||||
})
|
||||
|
||||
hexo.extend.helper.register('isImgOrUrl', function (path) {
|
||||
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/i
|
||||
return path.includes('//') || imgTestReg.test(path)
|
||||
hexo.extend.helper.register('getBgPath', function (path) {
|
||||
if (!path) return ''
|
||||
|
||||
const absoluteUrlPattern = /^(?:[a-z][a-z\d+.-]*:)?\/\//i
|
||||
const relativeUrlPattern = /^(\.\/|\.\.\/|\/|[^/]+\/).*$/
|
||||
const colorPattern = /^(#|rgb|rgba|hsl|hsla|linear-gradient|radial-gradient)/i
|
||||
|
||||
if (colorPattern.test(path)) {
|
||||
return `background-color: ${path};`
|
||||
} else if (absoluteUrlPattern.test(path) || relativeUrlPattern.test(path)) {
|
||||
return `background-image: url(${path});`
|
||||
} else {
|
||||
return `background: ${path};`
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user