Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat: add /tags/:tagName/questions route

shuaid738ec2121f3
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index 6803f196..8066f186 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -852,6 +852,7 @@ ui:
http_50X: HTTP Error 500
http_403: HTTP Error 403
logout: Log Out
+ posts: Posts
notifications:
title: Notifications
inbox: Inbox
diff --git a/ui/src/pages/Tags/Detail/index.tsx b/ui/src/pages/Tags/Detail/index.tsx
index 8bfd5ee8..dc475667 100644
--- a/ui/src/pages/Tags/Detail/index.tsx
+++ b/ui/src/pages/Tags/Detail/index.tsx
@@ -24,6 +24,7 @@ import {
Link,
useNavigate,
useSearchParams,
+ useMatch,
} from 'react-router-dom';
import { useTranslation } from 'react-i18next';
@@ -65,6 +66,8 @@ const Index: FC = () => {
tagInfo?.tag_id,
tagInfo?.status,
);
+ const matchQuestions = useMatch('/tags/:tagName/questions');
+ const matchPosts = useMatch('/tags/:tagName');
const toggleFollow = () => {
if (!guard.tryNormalLogged(true)) {
return;
@@ -100,9 +103,16 @@ const Index: FC = () => {
}, [tagResp, followResp]);
let pageTitle = '';
if (tagInfo?.display_name) {
- pageTitle = `'${tagInfo.display_name}' ${t('questions', {
- keyPrefix: 'page_title',
- })}`;
+ if (matchQuestions) {
+ pageTitle = `'${tagInfo.display_name}' ${t('questions', {
+ keyPrefix: 'page_title',
+ })}`;
+ }
+ if (matchPosts) {
+ pageTitle = `'${tagInfo.display_name}' ${t('posts', {
+ keyPrefix: 'page_title',
+ })}`;
+ }
}
const keywords: string[] = [];
if (tagInfo?.slug_name) {
diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.ts
index 3e324815..09ea4838 100644
--- a/ui/src/router/routes.ts
+++ b/ui/src/router/routes.ts
@@ -140,6 +140,10 @@ const routes: RouteNode[] = [
path: 'tags/:tagName',
page: 'pages/Tags/Detail',
},
+ {
+ path: 'tags/:tagName/questions',
+ page: 'pages/Tags/Detail',
+ },
{
path: 'tags/:tagName/info',
page: 'pages/Tags/Info',