mirror of
https://github.com/aljazceru/landscape-template.git
synced 2026-01-28 02:34:42 +01:00
refactor: change story&feed routes structure, change default route, add banner to feed page, fix Loadable component props typing
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { Suspense } from "react";
|
||||
import LoadingPage from "src/Components/LoadingPage/LoadingPage";
|
||||
|
||||
export const Loadable = (Component: any, Loading = LoadingPage) => (props: any) => (
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Component {...props} />
|
||||
</Suspense>
|
||||
);
|
||||
export function Loadable<P>(Component: React.LazyExoticComponent<(props: P) => JSX.Element>, Loading = LoadingPage) {
|
||||
return (props: P) => (
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Component {...props as any} />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -42,21 +42,23 @@ type RouteOptions =
|
||||
|
||||
export function createRoute(options: RouteOptions) {
|
||||
|
||||
|
||||
if (options.type === "post")
|
||||
return `/blog/post/${options.postType.toLowerCase()}/${options.id}`
|
||||
+ (options.title ? `/${toSlug(options.title)}` : "");
|
||||
|
||||
if (options.type === "story")
|
||||
return `/blog/post/story/${options.id}`
|
||||
+ (options.title ? `/${toSlug(options.title)}` : "");
|
||||
|
||||
if (options.type === "bounty")
|
||||
if ((options.type === "post" && options.postType.toLowerCase() === 'story')
|
||||
|| options.type === "story") {
|
||||
const onlyId = !options.title;
|
||||
return "/story/"
|
||||
// + (options.username ? `${toSlug(options.username)}-` : "")
|
||||
+ (options.title ? `${toSlug(options.title)}-` : "")
|
||||
+ (!onlyId ? "-" : "")
|
||||
+ `${options.id}`
|
||||
}
|
||||
if ((options.type === "post" && options.postType.toLowerCase() === 'bounty')
|
||||
|| options.type === "bounty")
|
||||
return `/blog/post/bounty/${options.id}`
|
||||
+ (options.title ? `/${toSlug(options.title)}` : "");
|
||||
|
||||
|
||||
if (options.type === "question")
|
||||
if ((options.type === "post" && options.postType.toLowerCase() === 'question')
|
||||
|| options.type === "question")
|
||||
return `/blog/post/question/${options.id}`
|
||||
+ (options.title ? `/${toSlug(options.title)}` : "");
|
||||
|
||||
@@ -82,9 +84,12 @@ export const PAGES_ROUTES = {
|
||||
byCategoryId: "/projects/category/:id"
|
||||
},
|
||||
blog: {
|
||||
feed: "/blog",
|
||||
postById: "/blog/post/:type/:id/*",
|
||||
createPost: "/blog/create-post"
|
||||
feed: "/feed",
|
||||
postById: "/feed/post/:type/:id/*",
|
||||
storyById: "/story/:slug",
|
||||
writeStory: "/story/write",
|
||||
createPost: "/story/create-post",
|
||||
catchStory: '/story'
|
||||
},
|
||||
hackathons: {
|
||||
default: "/hackathons"
|
||||
|
||||
Reference in New Issue
Block a user