mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-20 07:21:34 +02:00
/ route for force graph, /links for links
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { SignedInClient } from "@/components/custom/clerk/signed-in-client"
|
import { SignedInClient } from "@/components/custom/clerk/signed-in-client"
|
||||||
import { Sidebar } from "@/components/custom/sidebar/sidebar"
|
import { Sidebar } from "@/components/custom/sidebar/sidebar"
|
||||||
import { PublicHomeRoute } from "@/components/routes/public/PublicHomeRoute"
|
|
||||||
import { JazzClerkAuth, JazzProvider } from "@/lib/providers/jazz-provider"
|
import { JazzClerkAuth, JazzProvider } from "@/lib/providers/jazz-provider"
|
||||||
import { currentUser } from "@clerk/nextjs/server"
|
import { currentUser } from "@clerk/nextjs/server"
|
||||||
import { CommandPalette } from "@/components/custom/command-palette/command-palette"
|
import { CommandPalette } from "@/components/custom/command-palette/command-palette"
|
||||||
@@ -9,7 +8,7 @@ export default async function PageLayout({ children }: { children: React.ReactNo
|
|||||||
const user = await currentUser()
|
const user = await currentUser()
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return <PublicHomeRoute />
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { LinkRoute } from "@/components/routes/link/LinkRoute"
|
import { LinkRoute } from "@/components/routes/link/LinkRoute"
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function LinksPage() {
|
||||||
return <LinkRoute />
|
return <LinkRoute />
|
||||||
}
|
}
|
||||||
7
web/app/(public)/layout.tsx
Normal file
7
web/app/(public)/layout.tsx
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export default function PublicLayout({
|
||||||
|
children
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode
|
||||||
|
}>) {
|
||||||
|
return <main className="h-full">{children}</main>
|
||||||
|
}
|
||||||
5
web/app/page.tsx
Normal file
5
web/app/page.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { PublicHomeRoute } from "@/components/routes/public/PublicHomeRoute"
|
||||||
|
|
||||||
|
export default function HomePage() {
|
||||||
|
return <PublicHomeRoute />
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ export const LinkSection: React.FC<{ pathname: string }> = ({ pathname }) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const linkCount = me?.root.personalLinks?.length || 0
|
const linkCount = me?.root.personalLinks?.length || 0
|
||||||
const isActive = pathname === "/"
|
const isActive = pathname === "/links"
|
||||||
|
|
||||||
if (!me) return null
|
if (!me) return null
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ const LinkSectionHeader: React.FC<LinkSectionHeaderProps> = ({ linkCount, isActi
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
href="/"
|
href="/links"
|
||||||
className={cn(
|
className={cn(
|
||||||
"size-6 flex-1 items-center justify-start rounded-md px-2 py-1",
|
"size-6 flex-1 items-center justify-start rounded-md px-2 py-1",
|
||||||
"focus-visible:outline-none focus-visible:ring-0",
|
"focus-visible:outline-none focus-visible:ring-0",
|
||||||
@@ -78,7 +78,7 @@ interface ListItemProps {
|
|||||||
const ListItem: React.FC<ListItemProps> = ({ label, href, count, isActive }) => {
|
const ListItem: React.FC<ListItemProps> = ({ label, href, count, isActive }) => {
|
||||||
return (
|
return (
|
||||||
<div className="group/reorder-page relative">
|
<div className="group/reorder-page relative">
|
||||||
<div className="group/topic-link relative flex min-w-0 flex-1">
|
{/* <div className="group/topic-link relative flex min-w-0 flex-1">
|
||||||
<Link
|
<Link
|
||||||
href={href}
|
href={href}
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -94,7 +94,7 @@ const ListItem: React.FC<ListItemProps> = ({ label, href, count, isActive }) =>
|
|||||||
{count > 0 && (
|
{count > 0 && (
|
||||||
<span className="absolute right-2 top-1/2 z-[1] -translate-y-1/2 rounded p-1 text-sm">{count}</span>
|
<span className="absolute right-2 top-1/2 z-[1] -translate-y-1/2 rounded p-1 text-sm">{count}</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ const LogoAndSearch: React.FC = React.memo(() => {
|
|||||||
return (
|
return (
|
||||||
<div className="px-3">
|
<div className="px-3">
|
||||||
<div className="mt-2 flex h-10 max-w-full items-center">
|
<div className="mt-2 flex h-10 max-w-full items-center">
|
||||||
<Link href="/explore" className="px-2">
|
<Link href="/" className="px-2">
|
||||||
<Logo className="size-7" />
|
<Logo className="size-7" />
|
||||||
</Link>
|
</Link>
|
||||||
<div className="flex min-w-2 grow flex-row" />
|
<div className="flex min-w-2 grow flex-row" />
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import dynamic from "next/dynamic"
|
|||||||
import { motion } from "framer-motion"
|
import { motion } from "framer-motion"
|
||||||
import { Autocomplete } from "./Autocomplete"
|
import { Autocomplete } from "./Autocomplete"
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
|
import { useAccount } from "@/lib/providers/jazz-provider"
|
||||||
|
|
||||||
let graph_data_promise = import("./graph-data.json").then(a => a.default)
|
let graph_data_promise = import("./graph-data.json").then(a => a.default)
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ export function PublicHomeRoute() {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const raw_graph_data = React.use(graph_data_promise) as GraphNode[]
|
const raw_graph_data = React.use(graph_data_promise) as GraphNode[]
|
||||||
const [filterQuery, setFilterQuery] = React.useState<string>("")
|
const [filterQuery, setFilterQuery] = React.useState<string>("")
|
||||||
|
const { me } = useAccount()
|
||||||
|
|
||||||
const handleTopicSelect = (topicName: string) => {
|
const handleTopicSelect = (topicName: string) => {
|
||||||
router.push(`/${topicName}`)
|
router.push(`/${topicName}`)
|
||||||
@@ -30,35 +32,37 @@ export function PublicHomeRoute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative h-full w-screen">
|
<>
|
||||||
<ForceGraphClient
|
<div className="relative h-full w-screen">
|
||||||
raw_nodes={raw_graph_data}
|
<ForceGraphClient
|
||||||
onNodeClick={val => handleTopicSelect(val)}
|
raw_nodes={raw_graph_data}
|
||||||
filter_query={filterQuery}
|
onNodeClick={val => handleTopicSelect(val)}
|
||||||
/>
|
filter_query={filterQuery}
|
||||||
|
|
||||||
<motion.div
|
|
||||||
className="absolute left-1/2 top-1/2 w-full max-w-md -translate-x-1/2 -translate-y-1/2 transform max-sm:px-5"
|
|
||||||
initial={{ opacity: 0, y: 20 }}
|
|
||||||
animate={{ opacity: 1, y: 0 }}
|
|
||||||
transition={{ duration: 0.5 }}
|
|
||||||
style={{ x: "-50%", y: "-50%" }}
|
|
||||||
>
|
|
||||||
<motion.h1
|
|
||||||
className="mb-2 text-center text-3xl font-bold uppercase sm:mb-4 md:text-5xl"
|
|
||||||
initial={{ opacity: 0, y: -20 }}
|
|
||||||
animate={{ opacity: 1, y: 0 }}
|
|
||||||
transition={{ duration: 0.5, delay: 0.2 }}
|
|
||||||
>
|
|
||||||
I want to learn
|
|
||||||
</motion.h1>
|
|
||||||
<Autocomplete
|
|
||||||
topics={raw_graph_data}
|
|
||||||
onSelect={topic => handleTopicSelect(topic.name)}
|
|
||||||
onInputChange={handleInputChange}
|
|
||||||
/>
|
/>
|
||||||
</motion.div>
|
|
||||||
</div>
|
<motion.div
|
||||||
|
className="absolute left-1/2 top-1/2 w-full max-w-md -translate-x-1/2 -translate-y-1/2 transform max-sm:px-5"
|
||||||
|
initial={{ opacity: 0, y: 20 }}
|
||||||
|
animate={{ opacity: 1, y: 0 }}
|
||||||
|
transition={{ duration: 0.5 }}
|
||||||
|
style={{ x: "-50%", y: "-50%" }}
|
||||||
|
>
|
||||||
|
<motion.h1
|
||||||
|
className="mb-2 text-center text-3xl font-bold uppercase sm:mb-4 md:text-5xl"
|
||||||
|
initial={{ opacity: 0, y: -20 }}
|
||||||
|
animate={{ opacity: 1, y: 0 }}
|
||||||
|
transition={{ duration: 0.5, delay: 0.2 }}
|
||||||
|
>
|
||||||
|
I want to learn
|
||||||
|
</motion.h1>
|
||||||
|
<Autocomplete
|
||||||
|
topics={raw_graph_data}
|
||||||
|
onSelect={topic => handleTopicSelect(topic.name)}
|
||||||
|
onInputChange={handleInputChange}
|
||||||
|
/>
|
||||||
|
</motion.div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server"
|
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server"
|
||||||
|
|
||||||
const isPublicRoute = createRouteMatcher(["/sign-in(.*)", "/sign-up(.*)", "/"])
|
const publicRoutes = ["/", "/sign-in(.*)", "/sign-up(.*)"]
|
||||||
|
const isPublicRoute = createRouteMatcher(publicRoutes)
|
||||||
|
|
||||||
export default clerkMiddleware((auth, request) => {
|
export default clerkMiddleware((auth, request) => {
|
||||||
if (!isPublicRoute(request)) {
|
if (!isPublicRoute(request)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user