Skip to content

Commit e92ae8c

Browse files
authored
Add description field for tag (#8418)
#### What type of PR is this? /kind feature /kind api-change #### What this PR does / why we need it: This PR adds a `description` field to tag metadata, aligning tags with categories. Changes included: - add `description` to `Tag.TagSpec` - update OpenAPI docs so the new field is exposed in the API schema - add description field support in the tag editing modal - update api-client typings for `TagSpec` accordingly This allows users to store and edit a description for article tags in the console. #### Which issue(s) this PR fixes: Fixes #8054 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 为文章标签添加描述字段 ```
1 parent 9033ed1 commit e92ae8c

13 files changed

Lines changed: 68 additions & 23 deletions

File tree

api-docs/openapi/v3_0/aggregated.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20674,12 +20674,12 @@
2067420674
},
2067520675
"visible": {
2067620676
"type": "string",
20677-
"default": "PUBLIC",
2067820677
"enum": [
2067920678
"PUBLIC",
2068020679
"INTERNAL",
2068120680
"PRIVATE"
20682-
]
20681+
],
20682+
"default": "PUBLIC"
2068320683
}
2068420684
}
2068520685
},
@@ -22491,12 +22491,12 @@
2249122491
},
2249222492
"visible": {
2249322493
"type": "string",
22494-
"default": "PUBLIC",
2249522494
"enum": [
2249622495
"PUBLIC",
2249722496
"INTERNAL",
2249822497
"PRIVATE"
22499-
]
22498+
],
22499+
"default": "PUBLIC"
2250022500
}
2250122501
}
2250222502
},
@@ -23010,6 +23010,9 @@
2301023010
"cover": {
2301123011
"type": "string"
2301223012
},
23013+
"description": {
23014+
"type": "string"
23015+
},
2301323016
"displayName": {
2301423017
"minLength": 1,
2301523018
"type": "string"

api-docs/openapi/v3_0/apis_console.api_v1alpha1.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5487,12 +5487,12 @@
54875487
},
54885488
"visible": {
54895489
"type": "string",
5490-
"default": "PUBLIC",
54915490
"enum": [
54925491
"PUBLIC",
54935492
"INTERNAL",
54945493
"PRIVATE"
5495-
]
5494+
],
5495+
"default": "PUBLIC"
54965496
}
54975497
}
54985498
},
@@ -6029,12 +6029,12 @@
60296029
},
60306030
"visible": {
60316031
"type": "string",
6032-
"default": "PUBLIC",
60336032
"enum": [
60346033
"PUBLIC",
60356034
"INTERNAL",
60366035
"PRIVATE"
6037-
]
6036+
],
6037+
"default": "PUBLIC"
60386038
}
60396039
}
60406040
},
@@ -6211,6 +6211,9 @@
62116211
"cover": {
62126212
"type": "string"
62136213
},
6214+
"description": {
6215+
"type": "string"
6216+
},
62146217
"displayName": {
62156218
"minLength": 1,
62166219
"type": "string"

api-docs/openapi/v3_0/apis_extension.api_v1alpha1.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12876,12 +12876,12 @@
1287612876
},
1287712877
"visible": {
1287812878
"type": "string",
12879-
"default": "PUBLIC",
1288012879
"enum": [
1288112880
"PUBLIC",
1288212881
"INTERNAL",
1288312882
"PRIVATE"
12884-
]
12883+
],
12884+
"default": "PUBLIC"
1288512885
}
1288612886
}
1288712887
},
@@ -14256,12 +14256,12 @@
1425614256
},
1425714257
"visible": {
1425814258
"type": "string",
14259-
"default": "PUBLIC",
1426014259
"enum": [
1426114260
"PUBLIC",
1426214261
"INTERNAL",
1426314262
"PRIVATE"
14264-
]
14263+
],
14264+
"default": "PUBLIC"
1426514265
}
1426614266
}
1426714267
},
@@ -14676,6 +14676,9 @@
1467614676
"cover": {
1467714677
"type": "string"
1467814678
},
14679+
"description": {
14680+
"type": "string"
14681+
},
1467914682
"displayName": {
1468014683
"minLength": 1,
1468114684
"type": "string"

api-docs/openapi/v3_0/apis_public.api_v1alpha1.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,12 +2636,12 @@
26362636
},
26372637
"visible": {
26382638
"type": "string",
2639-
"default": "PUBLIC",
26402639
"enum": [
26412640
"PUBLIC",
26422641
"INTERNAL",
26432642
"PRIVATE"
2644-
]
2643+
],
2644+
"default": "PUBLIC"
26452645
}
26462646
}
26472647
},
@@ -3216,12 +3216,12 @@
32163216
},
32173217
"visible": {
32183218
"type": "string",
3219-
"default": "PUBLIC",
32203219
"enum": [
32213220
"PUBLIC",
32223221
"INTERNAL",
32233222
"PRIVATE"
3224-
]
3223+
],
3224+
"default": "PUBLIC"
32253225
}
32263226
}
32273227
},
@@ -3367,6 +3367,9 @@
33673367
"cover": {
33683368
"type": "string"
33693369
},
3370+
"description": {
3371+
"type": "string"
3372+
},
33703373
"displayName": {
33713374
"minLength": 1,
33723375
"type": "string"

api-docs/openapi/v3_0/apis_uc.api_v1alpha1.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,12 +2557,12 @@
25572557
},
25582558
"visible": {
25592559
"type": "string",
2560-
"default": "PUBLIC",
25612560
"enum": [
25622561
"PUBLIC",
25632562
"INTERNAL",
25642563
"PRIVATE"
2565-
]
2564+
],
2565+
"default": "PUBLIC"
25662566
}
25672567
}
25682568
},
@@ -2893,6 +2893,9 @@
28932893
"cover": {
28942894
"type": "string"
28952895
},
2896+
"description": {
2897+
"type": "string"
2898+
},
28962899
"displayName": {
28972900
"minLength": 1,
28982901
"type": "string"

api/src/main/java/run/halo/app/core/extension/content/Tag.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public static class TagSpec {
4444
@Schema(requiredMode = REQUIRED, minLength = 1)
4545
private String slug;
4646

47+
private String description;
48+
4749
/**
4850
* Color regex explanation.
4951
* <pre>

application/src/main/java/run/halo/app/theme/router/factories/TagPostRouteFactory.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import static run.halo.app.extension.index.query.Queries.isNull;
88
import static run.halo.app.theme.router.PageUrlUtils.totalPage;
99

10+
import java.util.HashMap;
1011
import java.util.Map;
1112
import lombok.AllArgsConstructor;
1213
import org.springframework.http.MediaType;
@@ -27,6 +28,7 @@
2728
import run.halo.app.infra.SystemSetting;
2829
import run.halo.app.infra.exception.NotFoundException;
2930
import run.halo.app.infra.utils.PathUtils;
31+
import run.halo.app.theme.Constant;
3032
import run.halo.app.theme.DefaultTemplateEnum;
3133
import run.halo.app.theme.finders.PostFinder;
3234
import run.halo.app.theme.finders.TagFinder;
@@ -80,12 +82,16 @@ private HandlerFunction<ServerResponse> handlerFunction() {
8082
)
8183
)
8284
));
85+
Map<String, Object> model = new HashMap<>();
86+
model.put("name", tagVo.getMetadata().getName());
87+
model.put("posts", postList);
88+
model.put("tag", tagVo);
89+
model.put(
90+
Constant.META_DESCRIPTION_VARIABLE_NAME,
91+
tagVo.getSpec().getDescription()
92+
);
8393
return ServerResponse.ok()
84-
.render(DefaultTemplateEnum.TAG.getValue(),
85-
Map.of("name", tagVo.getMetadata().getName(),
86-
"posts", postList,
87-
"tag", tagVo)
88-
);
94+
.render(DefaultTemplateEnum.TAG.getValue(), model);
8995
});
9096
}
9197

ui/console-src/modules/contents/posts/tags/components/TagEditingModal.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const formState = ref<Tag>({
4141
spec: {
4242
displayName: "",
4343
slug: "",
44+
description: "",
4445
cover: "",
4546
},
4647
apiVersion: "content.halo.run/v1alpha1",
@@ -253,6 +254,18 @@ async function slugUniqueValidation(node: FormKitNode) {
253254
:accepts="['image/*']"
254255
validation="length:0,1024"
255256
></FormKit>
257+
<FormKit
258+
v-model="formState.spec.description"
259+
name="description"
260+
:help="$t('core.post_tag.editing_modal.fields.description.help')"
261+
:label="
262+
$t('core.post_tag.editing_modal.fields.description.label')
263+
"
264+
type="textarea"
265+
auto-height
266+
:max-auto-height="200"
267+
validation="length:0,200"
268+
></FormKit>
256269
</div>
257270
</div>
258271
</div>

ui/packages/api-client/src/models/tag-spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface TagSpec {
2020
*/
2121
'color'?: string;
2222
'cover'?: string;
23+
'description'?: string;
2324
'displayName': string;
2425
'slug': string;
2526
}

ui/src/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@
205205
"core.post_tag.editing_modal.fields.color.help": "Theme adaptation is required to support",
206206
"core.post_tag.editing_modal.fields.cover.label": "Cover",
207207
"core.post_tag.editing_modal.fields.cover.help": "Theme adaptation is required to support",
208+
"core.post_tag.editing_modal.fields.description.label": "Description",
209+
"core.post_tag.editing_modal.fields.description.help": "The description will be automatically added to the page's meta description tag for SEO; other display purposes require theme adaptation",
208210
"core.post_category.title": "Post categories",
209211
"core.post_category.header.title": "{count} Categories",
210212
"core.post_category.empty.title": "There are no categories currently.",

0 commit comments

Comments
 (0)