支持模板渲染 / 修复 bug

This commit is contained in:
dragon
2025-04-15 16:31:19 +08:00
parent b505b6a5fb
commit bd37e64c1c
10 changed files with 226 additions and 38 deletions

View File

@@ -6,6 +6,8 @@ import (
"regexp"
"strings"
"code.d7z.net/d7z-project/gitea-pages/pkg/renders"
"code.d7z.net/d7z-project/gitea-pages/pkg/utils"
"github.com/pkg/errors"
@@ -43,6 +45,17 @@ func (m *PageDomainContent) CacheKey() string {
return fmt.Sprintf("%s/%s/%s/%s", m.Owner, m.Repo, m.CommitID, m.Path)
}
func (m *PageDomainContent) TryRender(path ...string) renders.Render {
for _, s := range path {
for _, compiler := range m.rendersL {
if compiler.regex.Match(s) {
return compiler.Render
}
}
}
return nil
}
func (p *PageDomain) ParseDomainMeta(domain, path, branch string) (*PageDomainContent, error) {
if branch == "" {
branch = p.defaultBranch
@@ -93,6 +106,8 @@ func (p *PageDomain) ReturnMeta(owner string, repo string, branch string, path [
}
}
return rel, nil
} else {
zap.L().Debug("查询错误", zap.Error(err))
}
return nil, os.ErrNotExist
return nil, errors.Wrapf(os.ErrNotExist, strings.Join(path, "/"))
}