Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Check local vars before adding doc link

Terry Sutton8682f089a0fc
diff --git a/packages/ui/src/components/Command/DocsSearch.tsx b/packages/ui/src/components/Command/DocsSearch.tsx
index 22e1cf54c0b..fabeb55dc04 100644
--- a/packages/ui/src/components/Command/DocsSearch.tsx
+++ b/packages/ui/src/components/Command/DocsSearch.tsx
@@ -49,6 +49,16 @@ export interface PageResult {
sections: PageSection[]
}
+const getDocsUrl = () => {
+ if (!process.env.NEXT_PUBLIC_SITE_URL || !process.env.NEXT_PUBLIC_LOCAL_SUPABASE) {
+ return 'https://supabase.com/docs'
+ }
+
+ const isLocal =
+ process.env.NEXT_PUBLIC_SITE_URL.includes('localhost') || process.env.NEXT_PUBLIC_LOCAL_SUPABASE
+ return isLocal ? 'http://localhost:3001/docs' : 'https://supabase.com/docs'
+}
+
const DocsSearch = () => {
const [results, setResults] = useState<PageResult[]>()
const [hasSearchError, setHasSearchError] = useState(false)
@@ -276,10 +286,12 @@ const DocsSearch = () => {
export default DocsSearch
export function formatPageUrl(page: PageResult) {
+ const docsUrl = getDocsUrl()
+ console.log('docsUrl:', docsUrl)
switch (page.type) {
case PageType.Markdown:
case PageType.Reference:
- return `/docs/${page.path}`
+ return `${docsUrl}${page.path}`
case PageType.GithubDiscussion:
return page.path
default: