feat: 随机背景

This commit is contained in:
着火的冰块nya
2025-11-16 10:34:08 +08:00
Unverified
parent 439014bbb6
commit eb263085cf
2 changed files with 8 additions and 1 deletions

View File

@@ -89,6 +89,12 @@ hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) {
hexo.extend.helper.register('getBgPath', function (path) {
if (!path) return ''
// Random background
if (Array.isArray(path)) {
const i = Math.floor(Math.random() * path.length)
path = path[i]
}
const absoluteUrlPattern = /^(?:[a-z][a-z\d+.-]*:)?\/\//i
const relativeUrlPattern = /^(\.\/|\.\.\/|\/|[^/]+\/).*$/
const colorPattern = /^(#|rgb|rgba|hsl|hsla)/i