Skip to content

Commit

Permalink
fix: new tags showing null post count on theme
Browse files Browse the repository at this point in the history
  • Loading branch information
guqing committed Nov 19, 2024
1 parent 06f3c28 commit ecbb2df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ public Result reconcile(Request request) {
String newPattern = tagPermalinkPolicy.pattern();
annotations.put(Constant.PERMALINK_PATTERN_ANNO, newPattern);

String permalink = tagPermalinkPolicy.permalink(tag);
var status = tag.getStatusOrDefault();
String permalink = tagPermalinkPolicy.permalink(tag);
status.setPermalink(permalink);

if (status.getPostCount() == null) {
status.setPostCount(0);
}
if (status.getVisiblePostCount() == null) {
status.setVisiblePostCount(0);
}

// Update the observed version.
status.setObservedVersion(tag.getMetadata().getVersion() + 1);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package run.halo.app.theme.finders.vo;

import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;

import lombok.Builder;
import lombok.Value;
import run.halo.app.core.extension.content.Tag;
Expand Down Expand Up @@ -33,7 +35,7 @@ public static TagVo from(Tag tag) {
.metadata(tag.getMetadata())
.spec(spec)
.status(status)
.postCount(tag.getStatusOrDefault().getVisiblePostCount())
.postCount(defaultIfNull(status.getVisiblePostCount(), 0))
.build();
}
}

0 comments on commit ecbb2df

Please sign in to comment.