Skip to content

Commit

Permalink
fix: incorrect hash tag link (#140)
Browse files Browse the repository at this point in the history
### What this PR does?
修复标签链接不正确的问题

Fixes #139 

```release-note
修复标签相对链接不正确的问题
```
  • Loading branch information
guqing authored Dec 10, 2024
1 parent 50d8826 commit 22d08c4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ enum Target {
```json
{
"name": "string", // 标签名称
"permalink": "string", // 标签链接
"momentCount": 0 // 标签所属的 moment 数量
}
```
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "com.github.node-gradle.node" version "5.0.0"
id "io.freefair.lombok" version "8.0.0-rc2"
id "run.halo.plugin.devtools" version "0.1.1"
id "run.halo.plugin.devtools" version "0.4.1"
id 'java'
}

Expand Down Expand Up @@ -46,7 +46,7 @@ build {
}

halo {
version = '2.17.0'
version = '2.20'
debug = true;
}

Expand Down
2 changes: 1 addition & 1 deletion console/src/extensions/tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const TagsExtension = Mark.create<TagOptions>({
default: null,
renderHTML(attributes) {
return {
href: `?tag=${encodeURI(attributes.tagText)}`,
href: `/moments?tag=${encodeURI(attributes.tagText)}`,
"data-pjax": "",
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import static run.halo.app.extension.index.query.QueryFactory.equal;

import jakarta.annotation.Nonnull;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.web.util.UriUtils;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import run.halo.app.core.extension.Counter;
Expand Down Expand Up @@ -109,6 +111,8 @@ public Flux<MomentTagVo> listAllTags() {
.map(count -> MomentTagVo.builder()
.name(groupedFlux.key())
.momentCount(count.intValue())
.permalink("/moments?tag=" + UriUtils.encode(groupedFlux.key(),
StandardCharsets.UTF_8))
.build()
)
);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/run/halo/moments/vo/MomentTagVo.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package run.halo.moments.vo;

import lombok.Builder;
import lombok.ToString;
import lombok.Value;
import org.springframework.web.util.UriUtils;
import java.nio.charset.StandardCharsets;

@Value
@Builder
public class MomentTagVo {

String name;

String permalink;

Integer momentCount;
}

0 comments on commit 22d08c4

Please sign in to comment.