Skip to content

Commit 1fd0749

Browse files
committed
fix: delete the slugtitle parameter in shared links to prevent the URL length from exceeding the limit #139
1 parent 72700a7 commit 1fd0749

File tree

6 files changed

+10
-28
lines changed

6 files changed

+10
-28
lines changed

ui/src/components/Operate/index.tsx

+1-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ interface IProps {
2323
qid: string;
2424
aid?: string;
2525
title: string;
26-
slugTitle: string;
2726
hasAnswer?: boolean;
2827
isAccepted: boolean;
2928
callback: (type: string) => void;
@@ -34,7 +33,6 @@ const Index: FC<IProps> = ({
3433
qid,
3534
aid = '',
3635
title,
37-
slugTitle,
3836
isAccepted = false,
3937
hasAnswer = false,
4038
memberActions = [],
@@ -268,13 +266,7 @@ const Index: FC<IProps> = ({
268266

269267
return (
270268
<div className="d-flex align-items-center">
271-
<Share
272-
type={type}
273-
qid={qid}
274-
aid={aid}
275-
title={title}
276-
slugTitle={slugTitle}
277-
/>
269+
<Share type={type} qid={qid} aid={aid} title={title} />
278270
{firstAction?.map((item) => {
279271
if (item.action === 'edit') {
280272
return (

ui/src/components/Share/index.tsx

+4-12
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,25 @@ import { FacebookShareButton, TwitterShareButton } from 'next-share';
66
import copy from 'copy-to-clipboard';
77

88
import { loggedUserInfoStore } from '@/stores';
9-
import { pathFactory } from '@/router/pathFactory';
109

1110
interface IProps {
1211
type: 'answer' | 'question';
1312
qid: any;
1413
aid?: any;
1514
title: string;
16-
slugTitle: string;
15+
// slugTitle: string;
1716
}
1817

19-
const Index: FC<IProps> = ({ type, qid, aid, title, slugTitle = '' }) => {
18+
const Index: FC<IProps> = ({ type, qid, aid, title }) => {
2019
const user = loggedUserInfoStore((state) => state.user);
2120
const [show, setShow] = useState(false);
2221
const [showTip, setShowTip] = useState(false);
2322
const [canSystemShare, setSystemShareState] = useState(false);
2423
const { t } = useTranslation();
2524
let baseUrl =
2625
type === 'question'
27-
? `${window.location.origin}${pathFactory.questionLanding(
28-
qid,
29-
slugTitle,
30-
)}`
31-
: `${window.location.origin}${pathFactory.answerLanding({
32-
questionId: qid,
33-
slugTitle,
34-
answerId: aid,
35-
})}`;
26+
? `${window.location.origin}/questions/${qid}`
27+
: `${window.location.origin}/questions/${qid}/${aid}`;
3628
if (user.id) {
3729
baseUrl = `${baseUrl}?shareUserId=${user.username}`;
3830
}

ui/src/components/UserCard/index.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ const Index: FC<Props> = ({
6363
</>
6464
)}
6565
<div className="small text-secondary d-flex flex-row flex-md-column align-items-center align-items-md-start">
66-
<div className="me-1 me-md-0">
66+
<div className="me-1 me-md-0 d-flex align-items-center">
6767
{data?.status !== 'deleted' ? (
68-
<Link to={`/users/${data?.username}`} className="me-1 text-break">
68+
<Link
69+
to={`/users/${data?.username}`}
70+
className="me-1 text-break name-ellipsis"
71+
style={{ maxWidth: '100px' }}>
6972
{data?.display_name}
7073
</Link>
7174
) : (

ui/src/pages/Questions/Detail/components/Answer/index.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ interface Props {
2323
aid?: string;
2424
canAccept: boolean;
2525
questionTitle: string;
26-
slugTitle: string;
2726
isLogged: boolean;
2827
callback: (type: string) => void;
2928
}
@@ -32,7 +31,6 @@ const Index: FC<Props> = ({
3231
data,
3332
isLogged,
3433
questionTitle = '',
35-
slugTitle,
3634
callback,
3735
canAccept = false,
3836
}) => {
@@ -132,7 +130,6 @@ const Index: FC<Props> = ({
132130
type="answer"
133131
isAccepted={data.accepted === 2}
134132
title={questionTitle}
135-
slugTitle={slugTitle}
136133
callback={callback}
137134
/>
138135
</div>

ui/src/pages/Questions/Detail/components/Question/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ const Index: FC<Props> = ({ data, initPage, hasAnswer, isLogged }) => {
148148
type="question"
149149
memberActions={data?.member_actions}
150150
title={data.title}
151-
slugTitle={data.url_title}
152151
hasAnswer={hasAnswer}
153152
isAccepted={Boolean(data?.accepted_answer_id)}
154153
callback={initPage}

ui/src/pages/Questions/Detail/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ const Index = () => {
234234
key={item?.id}
235235
data={item}
236236
questionTitle={question?.title || ''}
237-
slugTitle={question?.url_title}
238237
canAccept={isAuthor || isAdmin || isModerator}
239238
callback={initPage}
240239
isLogged={isLogged}

0 commit comments

Comments
 (0)