mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-20 22:14:11 +00:00
- Promote integrations from ?view=integrations to real /integrations and nested /integrations/[card] routes; the page body is shared via AppExperience and useViewMode is path-aware. - Legacy ?view= URLs (and /settings/integrations) redirect to the new routes for back-compat; middleware/ensure-workspace allow the public routes. - Add ?connect=<plugin|provider> deeplink that opens a card's connect modal instantly with a loading state (e.g. Hermes API key).
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import type { ViewParamValue } from "@/lib/search-params"
|
|
|
|
// Integration-family views that live under the real /integrations route.
|
|
export const INTEGRATION_VIEWS = [
|
|
"integrations",
|
|
"mcp",
|
|
"plugins",
|
|
"chrome",
|
|
"connections",
|
|
"shortcuts",
|
|
"raycast",
|
|
"import",
|
|
] as const
|
|
|
|
export type IntegrationView = (typeof INTEGRATION_VIEWS)[number]
|
|
|
|
// Sub-view cards — each is a nested route segment under /integrations.
|
|
export const INTEGRATION_CARDS = INTEGRATION_VIEWS.filter(
|
|
(v) => v !== "integrations",
|
|
) as Exclude<IntegrationView, "integrations">[]
|
|
|
|
export function isIntegrationView(view: string): view is IntegrationView {
|
|
return (INTEGRATION_VIEWS as readonly string[]).includes(view)
|
|
}
|
|
|
|
export function isIntegrationCard(slug: string): slug is IntegrationView {
|
|
return (INTEGRATION_CARDS as readonly string[]).includes(slug)
|
|
}
|
|
|
|
export function integrationViewToPath(view: IntegrationView): string {
|
|
return view === "integrations" ? "/integrations" : `/integrations/${view}`
|
|
}
|
|
|
|
export function pathToIntegrationView(pathname: string): ViewParamValue | null {
|
|
const trimmed = pathname.replace(/\/$/, "")
|
|
if (trimmed === "/integrations") return "integrations"
|
|
const slug = trimmed.match(/^\/integrations\/([^/]+)$/)?.[1]
|
|
if (slug && isIntegrationCard(slug)) return slug
|
|
return null
|
|
}
|