支持模板渲染 / 修复 bug
This commit is contained in:
@@ -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, "/"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user