fix: 修復 pagination UI 顯示異常的 bug

fix: 修復 footer_img 配置不生效的 bug
improvement: 優化 背景url 的判斷
feat: 背景圖片配置不再需要添加 url()
This commit is contained in:
Jerry
2024-08-05 16:04:05 +08:00
parent 06f543ed96
commit 48212b9610
7 changed files with 43 additions and 43 deletions

View File

@@ -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};`
}
})