mirror of https://gitee.com/answerdev/answer.git
refactor(pathFactory): Remove the dependency on : it's not very useful and will throw an error if it encounters a null argument.
This commit is contained in:
parent
23764ab543
commit
08d5528e4e
|
@ -38,7 +38,6 @@
|
|||
"react-router-dom": "^6.8.1",
|
||||
"semver": "^7.3.8",
|
||||
"swr": "^1.3.0",
|
||||
"urlcat": "^3.0.0",
|
||||
"zustand": "^4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -67,7 +67,6 @@ specifiers:
|
|||
semver: ^7.3.8
|
||||
swr: ^1.3.0
|
||||
typescript: ^4.8.3
|
||||
urlcat: ^3.0.0
|
||||
yaml-loader: ^0.8.0
|
||||
zustand: ^4.1.1
|
||||
|
||||
|
@ -98,7 +97,6 @@ dependencies:
|
|||
react-router-dom: 6.8.1_biqbaboplfbrettd7655fr4n2y
|
||||
semver: 7.3.8
|
||||
swr: 1.3.0_react@18.2.0
|
||||
urlcat: 3.0.0
|
||||
zustand: 4.1.1_react@18.2.0
|
||||
|
||||
devDependencies:
|
||||
|
@ -10986,12 +10984,6 @@ packages:
|
|||
querystringify: 2.2.0
|
||||
requires-port: 1.0.0
|
||||
|
||||
/urlcat/3.0.0:
|
||||
resolution: {integrity: sha512-SSXrIzInzKdWjBfm5iOrPfO6E5Nt0aFs5PTZCauxJTjJE3qhfePAWz8tjGm7dnWMYIAdPGjio51aakunyZHMXQ==}
|
||||
dependencies:
|
||||
qs: 6.11.0
|
||||
dev: false
|
||||
|
||||
/use-sync-external-store/1.2.0_react@18.2.0:
|
||||
resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==}
|
||||
peerDependencies:
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
import urlcat from 'urlcat';
|
||||
|
||||
import { seoSettingStore } from '@/stores';
|
||||
|
||||
const tagLanding = (slugName: string) => {
|
||||
if (!slugName) {
|
||||
return '/tags';
|
||||
}
|
||||
return urlcat('/tags/:slugName', { slugName });
|
||||
const r = slugName ? `/tags/${slugName}` : '/tags';
|
||||
return r;
|
||||
};
|
||||
|
||||
const tagInfo = (slugName: string) => {
|
||||
if (!slugName) {
|
||||
return '/tags';
|
||||
}
|
||||
return urlcat('/tags/:slugName/info', { slugName });
|
||||
const r = slugName ? `/tags/${slugName}/info` : '/tags';
|
||||
return r;
|
||||
};
|
||||
|
||||
const tagEdit = (tagId: string) => {
|
||||
return urlcat('/tags/:tagId/edit', { tagId });
|
||||
const r = `/tags/${tagId}/edit`;
|
||||
return r;
|
||||
};
|
||||
|
||||
const questionLanding = (questionId: string, slugTitle: string = '') => {
|
||||
const { seo } = seoSettingStore.getState();
|
||||
if (!questionId) {
|
||||
|
@ -24,14 +22,12 @@ const questionLanding = (questionId: string, slugTitle: string = '') => {
|
|||
}
|
||||
// @ts-ignore
|
||||
if (/[13]/.test(seo.permalink) && slugTitle) {
|
||||
return urlcat('/questions/:questionId/:slugPermalink', {
|
||||
questionId,
|
||||
slugPermalink: slugTitle,
|
||||
});
|
||||
return `/questions/${questionId}/${slugTitle}`;
|
||||
}
|
||||
|
||||
return urlcat('/questions/:questionId', { questionId });
|
||||
return `/questions/${questionId}`;
|
||||
};
|
||||
|
||||
const answerLanding = (params: {
|
||||
questionId: string;
|
||||
slugTitle?: string;
|
||||
|
@ -41,9 +37,7 @@ const answerLanding = (params: {
|
|||
params.questionId,
|
||||
params.slugTitle,
|
||||
);
|
||||
return urlcat(`${questionLandingUrl}/:answerId`, {
|
||||
answerId: params.answerId,
|
||||
});
|
||||
return `${questionLandingUrl}/${params.answerId}`;
|
||||
};
|
||||
|
||||
export const pathFactory = {
|
||||
|
|
Loading…
Reference in New Issue