diff --git a/client/components/new-post/description/index.tsx b/client/components/new-post/description/index.tsx index bf4983f7..e4a05a11 100644 --- a/client/components/new-post/description/index.tsx +++ b/client/components/new-post/description/index.tsx @@ -17,6 +17,7 @@ const Description = ({ onChange, description }: props) => { label="Description" maxLength={256} width="100%" + placeholder="A short description of your post" /> ) diff --git a/client/components/new-post/index.tsx b/client/components/new-post/index.tsx index 8171d17a..8814c12c 100644 --- a/client/components/new-post/index.tsx +++ b/client/components/new-post/index.tsx @@ -2,9 +2,7 @@ import { Button, useToasts, ButtonDropdown, - Toggle, Input, - useClickAway } from "@geist-ui/core" import { useRouter } from "next/router" import { useCallback, useEffect, useMemo, useRef, useState } from "react" @@ -19,7 +17,6 @@ import type { Document as DocumentType } from "@lib/types" import PasswordModal from "./password-modal" -import getPostPath from "@lib/get-post-path" import EditDocumentList from "@components/edit-document-list" import { ChangeEvent } from "react" import DatePicker from "react-datepicker" @@ -99,7 +96,7 @@ const Post = ({ if (res.ok) { const json = await res.json() - router.push(getPostPath(json.visibility, json.id)) + router.push(`/post/${json.id}`) } else { const json = await res.json() setToast({ diff --git a/client/components/post-list/list-item.tsx b/client/components/post-list/list-item.tsx index 3127046d..ccd94275 100644 --- a/client/components/post-list/list-item.tsx +++ b/client/components/post-list/list-item.tsx @@ -1,6 +1,5 @@ import NextLink from "next/link" import VisibilityBadge from "../badges/visibility-badge" -import getPostPath from "@lib/get-post-path" import { Link, Text, @@ -36,6 +35,10 @@ const ListItem = ({ router.push(`/new/from/${post.id}`) } + const viewParentClick = () => { + router.push(`/post/${post.parent?.id}`) + } + return (
  • @@ -44,7 +47,8 @@ const ListItem = ({ {post.title} @@ -57,14 +61,7 @@ const ListItem = ({ diff --git a/client/lib/get-post-path.ts b/client/lib/get-post-path.ts deleted file mode 100644 index 7950e517..00000000 --- a/client/lib/get-post-path.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { PostVisibility } from "./types" - -export default function getPostPath(visibility: PostVisibility, id: string) { - switch (visibility) { - case "private": - // return `/post/private/${id}` - case "protected": - // return `/post/protected/${id}` - case "unlisted": - case "public": - return `/post/${id}` - default: - console.error(`Unknown visibility: ${visibility}`) - return `/post/${id}` - } -} diff --git a/client/pages/post/[id].tsx b/client/pages/post/[id].tsx index 4366f4e4..10531bac 100644 --- a/client/pages/post/[id].tsx +++ b/client/pages/post/[id].tsx @@ -1,4 +1,4 @@ -import type { GetServerSideProps, GetStaticPaths, GetStaticProps } from "next" +import type { GetServerSideProps } from "next" import type { Post } from "@lib/types" import PostPage from "@components/post-page" @@ -69,9 +69,11 @@ export const getServerSideProps: GetServerSideProps = async ({ } } + return { props: { - post: json + post: json, + key: params?.id } } }