Add slugs for Posts, Boards and OAuths (#321)

This commit is contained in:
Riccardo Graziosi
2024-04-05 18:23:31 +02:00
committed by GitHub
parent e887bca9cf
commit 09fb156a4e
30 changed files with 262 additions and 25 deletions

View File

@@ -107,7 +107,7 @@ class NewPost extends React.Component<Props, State> {
});
const json = await res.json();
this.setState({isLoading: false});
if (res.status === HttpStatus.Created) {
this.setState({
success: I18n.t('board.new_post.submit_success'),
@@ -117,7 +117,7 @@ class NewPost extends React.Component<Props, State> {
});
setTimeout(() => (
window.location.href = `/posts/${json.id}`
window.location.href = `/posts/${json.slug || json.id}`
), 1000);
} else {
this.setState({error: json.error});

View File

@@ -55,6 +55,7 @@ const PostList = ({
<PostListItem
id={post.id}
title={post.title}
slug={post.slug}
description={post.description}
postStatus={postStatuses.find(postStatus => postStatus.id === post.postStatusId)}
likeCount={post.likeCount}

View File

@@ -10,6 +10,7 @@ import IPostStatus from '../../interfaces/IPostStatus';
interface Props {
id: number;
title: string;
slug?: string;
description?: string;
postStatus: IPostStatus;
likeCount: number;
@@ -25,6 +26,7 @@ interface Props {
const PostListItem = ({
id,
title,
slug,
description,
postStatus,
likeCount,
@@ -36,7 +38,7 @@ const PostListItem = ({
isLoggedIn,
authenticityToken,
}: Props) => (
<div onClick={() => window.location.href = `/posts/${id}`} className="postListItem">
<div onClick={() => window.location.href = `/posts/${slug || id}`} className="postListItem">
<LikeButton
postId={id}
likeCount={likeCount}
@@ -46,7 +48,7 @@ const PostListItem = ({
isLoggedIn={isLoggedIn}
authenticityToken={authenticityToken}
/>
<div className="postContainer">
<span className="postTitle">{title}</span>
<ReactMarkdown className="descriptionText" allowedTypes={['text']} unwrapDisallowed>