mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add slugs for Posts, Boards and OAuths (#321)
This commit is contained in:
committed by
GitHub
parent
e887bca9cf
commit
09fb156a4e
@@ -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});
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user