完善
This commit is contained in:
parent
5266e85f21
commit
f735211a92
@ -5,6 +5,11 @@
|
||||
<div id="primary" class="content-area">
|
||||
<main id="main" class="site-main">
|
||||
<article class="{{ .post|postsFn .calPostClass}}">
|
||||
{{if .post.Thumbnail.Path }}
|
||||
<div class="post-thumbnail">
|
||||
<img width="{{.post.Thumbnail.Width}}" height="{{.post.Thumbnail.Height}}" src="{{.post.Thumbnail.Path}}" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async">
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<header class="entry-header">
|
||||
<h1 class="entry-title">{{.post.PostTitle}}</h1></header><!-- .entry-header -->
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"github.com/fthvgb1/wp-go/internal/theme/wp"
|
||||
"github.com/fthvgb1/wp-go/internal/theme/wp/components"
|
||||
"github.com/fthvgb1/wp-go/internal/theme/wp/components/widget"
|
||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -76,4 +77,11 @@ func configs(h *wp.Handle) {
|
||||
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10))
|
||||
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(wp.IndexRender, 50))
|
||||
h.PushHandleFn(constraints.Detail, wp.NewHandleFn(wp.DetailRender, 50))
|
||||
h.PushHandleFn(constraints.Detail, wp.NewHandleFn(postThumb, 60))
|
||||
}
|
||||
|
||||
func postThumb(h *wp.Handle) {
|
||||
if h.Detail.Post.Thumbnail.Path != "" {
|
||||
h.Detail.Post.Thumbnail = wpconfig.Thumbnail(h.Detail.Post.Thumbnail.OriginAttachmentData, "post-thumbnail", "")
|
||||
}
|
||||
}
|
||||
|
@ -110,12 +110,10 @@ func TermClass(term models.TermsMy) string {
|
||||
termClass = strconv.FormatUint(term.TermTaxonomy.TermId, 10)
|
||||
}
|
||||
switch term.Taxonomy {
|
||||
case "category":
|
||||
return str.Join("category-", termClass)
|
||||
case "post_tag":
|
||||
return str.Join("tag-", termClass)
|
||||
case "post_format":
|
||||
return fmt.Sprintf("format-%s", strings.ReplaceAll(term.Slug, "post-format-", ""))
|
||||
}
|
||||
return fmt.Sprintf("%s-%d", term.Taxonomy, term.TermTaxonomy.TermId)
|
||||
return str.Join(term.Taxonomy, "-", termClass)
|
||||
}
|
||||
|
@ -66,7 +66,6 @@ func (d *DetailHandle) PasswordProject() {
|
||||
if d.password != d.Post.PostPassword {
|
||||
wpposts.PasswdProjectContent(&d.Post)
|
||||
}
|
||||
d.ginH["post"] = d.Post
|
||||
}
|
||||
}
|
||||
func (d *DetailHandle) Comment() {
|
||||
|
@ -82,8 +82,8 @@ func Thumbnail(metadata models.WpAttachmentMetadata, Type, host string, except .
|
||||
FileSize: metadata.FileSize,
|
||||
}
|
||||
}
|
||||
if _, ok := metadata.Sizes[Type]; ok {
|
||||
r.Path = fmt.Sprintf("%s/wp-content/uploads/%s", host, metadata.File)
|
||||
if siz, ok := metadata.Sizes[Type]; ok {
|
||||
r.Path = fmt.Sprintf("%s/wp-content/uploads/%s", host, strings.ReplaceAll(metadata.File, filepath.Base(metadata.File), siz.File))
|
||||
r.Width = metadata.Sizes[Type].Width
|
||||
r.Height = metadata.Sizes[Type].Height
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user