Skip to content

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

Add comments

Joshen Lima36815908703
diff --git a/apps/temp-docs/components/Navigation/DocSearch.tsx b/apps/temp-docs/components/DocSearch.tsx
similarity index 95%
rename from apps/temp-docs/components/Navigation/DocSearch.tsx
rename to apps/temp-docs/components/DocSearch.tsx
index 041d95a3131..52fc0956ecd 100644
--- a/apps/temp-docs/components/Navigation/DocSearch.tsx
+++ b/apps/temp-docs/components/DocSearch.tsx
@@ -7,7 +7,10 @@ import { DocSearchModal } from '@docsearch/react'
import clsx from 'clsx'
import { useActionKey } from '~/hooks/useActionKey'
-const INDEX_NAME = 'dev_docs'
+// [Joshen] We're currently using this over Algolia search for the time being
+// Refer to the comment in Navigation/AlgoliaSearch for more information about this
+
+const INDEX_NAME = process.env.NEXT_PUBLIC_ALGOLIA_INDEX_NAME
const API_KEY = process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY
const APP_ID = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID
@@ -64,10 +67,6 @@ export function SearchProvider({ children }: any) {
// @ts-ignore
initialQuery={initialQuery}
initialScrollY={window.scrollY}
- // searchParameters={{
- // facetFilters: 'version:v2',
- // distinct: 1,
- // }}
placeholder="Search documentation"
onClose={onClose}
indexName={INDEX_NAME}
@@ -83,7 +82,6 @@ export function SearchProvider({ children }: any) {
hitComponent={Hit}
transformItems={(items) => {
return items.map((item, index) => {
- console.log('transformItems', item)
// We transform the absolute URL into a relative URL to
// leverage Next's preloading.
const a = document.createElement('a')
@@ -115,7 +113,6 @@ export function SearchProvider({ children }: any) {
// @ts-ignore
function Hit({ hit, children }) {
- console.log('Hit', { hit })
return (
<Link href={hit.url}>
<a
diff --git a/apps/temp-docs/components/Navigation/Search.tsx b/apps/temp-docs/components/Navigation/AlgoliaSearch.tsx
similarity index 79%
rename from apps/temp-docs/components/Navigation/Search.tsx
rename to apps/temp-docs/components/Navigation/AlgoliaSearch.tsx
index 1dcf0092f44..e749ba034ee 100644
--- a/apps/temp-docs/components/Navigation/Search.tsx
+++ b/apps/temp-docs/components/Navigation/AlgoliaSearch.tsx
@@ -6,6 +6,23 @@ import { autocomplete, getAlgoliaResults } from '@algolia/autocomplete-js'
import { createLocalStorageRecentSearchesPlugin } from '@algolia/autocomplete-plugin-recent-searches'
import { useRouter } from 'next/router'
+// [Joshen] We're currently using DocSearch from Algolia as it provides a nice
+// UI out of the box + some good preconfigured search settings (e.g hierarchy).
+// However, we're using our own Algolia account to store the records in the indexes
+// (rather than going through the DocSearch program from Algolia where they'll crawl
+// our site for us). Refer to scripts/build-search on how we're saving the records.
+
+// Using Algolia's autocomplete library gives us full flexbility in terms of customizing
+// our search experience, but that will take time to figure out. Hence why for now we're just
+// using DocSearch with our own records.
+
+// Potentially for search, we could
+// - Go ahead with the DocSearch program and let them crawl our site to generate the records
+// - But we need to ensure that our site is semantically correct first
+// - Use Algolia itself to flesh out our own search logic
+// - The basics are already set up to be honest, but will take time to make it great
+// - Go back to Typesense if we deem that Algolia is not helpful in the long run
+
const searchClient = algoliasearch(
process.env.NEXT_PUBLIC_ALGOLIA_APP_ID,
process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY
@@ -38,7 +55,7 @@ const recentSearchesPlugin = createLocalStorageRecentSearchesPlugin({
interface Props {}
-const Search: FC<Props> = ({}) => {
+const AlgoliaSearch: FC<Props> = ({}) => {
const searchRef = useRef(null)
const router = useRouter()
@@ -79,7 +96,6 @@ const Search: FC<Props> = ({}) => {
templates: {
item({ item, components }) {
return (
- // <Link href={item.url as string}>
<a
href={item.url as string}
className="aa-ItemLink truncate flex justify-between space-x-4"
@@ -104,12 +120,7 @@ const Search: FC<Props> = ({}) => {
</div>
<p className="aa-ItemContentSubtitle">{item.description}</p>
</div>
- {/* [Joshen] Thinking of adding some meta tags here like where the doc is from, what version etc */}
- {/* <div>
- <Badge color="gray">{item.source}</Badge>
- </div> */}
</a>
- // </Link>
)
},
},
@@ -153,4 +164,4 @@ const Search: FC<Props> = ({}) => {
)
}
-export default Search
+export default AlgoliaSearch
diff --git a/apps/temp-docs/components/Navigation/NavBar.tsx b/apps/temp-docs/components/Navigation/NavBar.tsx
index 327b2cd6732..586a1fda003 100644
--- a/apps/temp-docs/components/Navigation/NavBar.tsx
+++ b/apps/temp-docs/components/Navigation/NavBar.tsx
@@ -2,10 +2,10 @@ import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState, useEffect, FC } from 'react'
-import { IconMenu, IconMoon, IconSun, Listbox } from 'ui'
+import { IconMenu, IconMoon, IconSearch, IconSun, IconCommand, Listbox } from 'ui'
import { useTheme } from '../Providers'
import { REFERENCES } from './Navigation.constants'
-import Search from './Search'
+import { SearchButton } from '../DocSearch'
interface Props {
currentPage: string
@@ -182,7 +182,22 @@ const NavBar: FC<Props> = ({ currentPage }) => {
</li>
</ul>
</div>
- <Search />
+ <SearchButton>
+ <div className="flex items-center justify-between space-x-6 bg-scale-300 border border-scale-700 pl-3 pr-1.5 py-1.5 rounded">
+ <div className="flex items-center space-x-2">
+ <IconSearch className="text-scale-1100" size={18} strokeWidth={2} />
+ <p className="text-scale-800 text-sm">Search docs</p>
+ </div>
+ <div className="flex items-center space-x-1">
+ <div className="text-scale-1200 flex items-center justify-center h-6 w-6 rounded bg-scale-500">
+ <IconCommand size={12} strokeWidth={1.5} />
+ </div>
+ <div className="text-xs text-scale-1200 flex items-center justify-center h-6 w-6 rounded bg-scale-500">
+ K
+ </div>
+ </div>
+ </div>
+ </SearchButton>
</div>
</nav>
)
diff --git a/apps/temp-docs/components/Navigation/Navigation.constants.ts b/apps/temp-docs/components/Navigation/Navigation.constants.ts
index 444f055cf58..802ed11794b 100644
--- a/apps/temp-docs/components/Navigation/Navigation.constants.ts
+++ b/apps/temp-docs/components/Navigation/Navigation.constants.ts
@@ -302,7 +302,7 @@ export const menuItems: NavMenu = {
label: 'Official',
items: [
{ name: 'Reference Documentation', url: '/reference', items: [] },
- { name: 'Supabase Javascript Library', url: '/reference/javascript', items: [] },
+ { name: 'Supabase JavaScript Library', url: '/reference/javascript', items: [] },
{ name: 'Supabase Flutter Library', url: '/reference/dart', items: [] },
{ name: 'Supabase CLI', url: '/reference/cli', items: [] },
{ name: 'Management API', url: '/reference/api', items: [] },
diff --git a/apps/temp-docs/data/nav/supabase-js/v1.ts b/apps/temp-docs/data/nav/supabase-js/v1.ts
index 828563e796a..ef9f20e8150 100644
--- a/apps/temp-docs/data/nav/supabase-js/v1.ts
+++ b/apps/temp-docs/data/nav/supabase-js/v1.ts
@@ -2,7 +2,7 @@ const Nav = [
{
label: 'Getting Started',
items: [
- { name: 'Supabase Javascript Library', url: '/reference/javascript/v1', items: [] },
+ { name: 'Supabase JavaScript Library', url: '/reference/javascript/v1', items: [] },
{ name: 'Installing', url: '/reference/javascript/v1/installing', items: [] },
{ name: 'Initializing', url: '/reference/javascript/v1/initializing', items: [] },
{ name: 'Generating Types', url: '/reference/javascript/v1/generating-types', items: [] },
diff --git a/apps/temp-docs/data/nav/supabase-js/v2.ts b/apps/temp-docs/data/nav/supabase-js/v2.ts
index e367be12e08..0e05c00eaec 100644
--- a/apps/temp-docs/data/nav/supabase-js/v2.ts
+++ b/apps/temp-docs/data/nav/supabase-js/v2.ts
@@ -2,7 +2,7 @@ const Nav = [
{
label: 'Getting Started',
items: [
- { name: 'Supabase Javascript Library', url: '/reference/javascript', items: [] },
+ { name: 'Supabase JavaScript Library', url: '/reference/javascript', items: [] },
{ name: 'Installing', url: '/reference/javascript/installing', items: [] },
{ name: 'Initializing', url: '/reference/javascript/initializing', items: [] },
{ name: 'Typescript Support', url: '/reference/javascript/typescript-support', items: [] },
diff --git a/apps/temp-docs/docs/reference/api/release-notes.mdx b/apps/temp-docs/docs/reference/api/release-notes.mdx
index a6cd0060519..39c55630952 100644
--- a/apps/temp-docs/docs/reference/api/release-notes.mdx
+++ b/apps/temp-docs/docs/reference/api/release-notes.mdx
@@ -1,5 +1,6 @@
---
id: release-notes
+title: Release Notes
---
# Release Notes
diff --git a/apps/temp-docs/docs/reference/auth/release-notes.mdx b/apps/temp-docs/docs/reference/auth/release-notes.mdx
index cb164542845..72f97f17886 100644
--- a/apps/temp-docs/docs/reference/auth/release-notes.mdx
+++ b/apps/temp-docs/docs/reference/auth/release-notes.mdx
@@ -1,5 +1,6 @@
---
id: release-notes
+title: Release Notes
---
# Release Notes
diff --git a/apps/temp-docs/docs/reference/cli.mdx b/apps/temp-docs/docs/reference/cli.mdx
index 8ac2186ca6e..50d64dcfb13 100644
--- a/apps/temp-docs/docs/reference/cli.mdx
+++ b/apps/temp-docs/docs/reference/cli.mdx
@@ -3,6 +3,7 @@ id: intro
slug: /
sidebar_position: 1
sidebar_label: Supabase CLI
+title: Supabase CLI
hide_table_of_contents: true
---
@@ -16,9 +17,9 @@ The CLI is still under development, but it contains all the functionality for wo
- CI/CD for releasing to production: [`supabase db push`](https://supabase.com/docs/reference/cli/usage#supabase-db-push)
- Manage your Supabase projects: [`supabase projects`](https://supabase.com/docs/reference/cli/usage#supabase-projects)
- Generate types directly from your database schema: [`supabase gen types`](https://supabase.com/docs/reference/cli/usage#supabase-gen)
- - A [community-supported GitHub Action](https://github.com/lyqht/generate-supabase-db-types-github-action) to generate TypeScript types
+ - A [community-supported GitHub Action](https://github.com/lyqht/generate-supabase-db-types-github-action) to generate TypeScript types
- Shell autocomplete: [`supabase completion`](https://supabase.com/docs/reference/cli/usage#supabase-completion)
- - A [community-supported Fig autocomplete spec](https://fig.io/manual/supabase) for macOS terminal
+ - A [community-supported Fig autocomplete spec](https://fig.io/manual/supabase) for macOS terminal
## Additional Links
diff --git a/apps/temp-docs/docs/reference/cli/release-notes.mdx b/apps/temp-docs/docs/reference/cli/release-notes.mdx
index e10337f8d04..3ba8fd666d7 100644
--- a/apps/temp-docs/docs/reference/cli/release-notes.mdx
+++ b/apps/temp-docs/docs/reference/cli/release-notes.mdx
@@ -1,5 +1,6 @@
---
id: release-notes
+title: Release Notes
---
# Release Notes
diff --git a/apps/temp-docs/docs/reference/dart/v0.mdx b/apps/temp-docs/docs/reference/dart/v0.mdx
index 9ba0ee46873..9684d4b9fe5 100644
--- a/apps/temp-docs/docs/reference/dart/v0.mdx
+++ b/apps/temp-docs/docs/reference/dart/v0.mdx
@@ -2,6 +2,7 @@
id: intro
slug: /
sidebar_label: Supabase Dart Library
+title: Supabase Dart Library
---
# Supabase Dart Library
diff --git a/apps/temp-docs/docs/reference/javascript.mdx b/apps/temp-docs/docs/reference/javascript.mdx
index 2d60a873b22..e2d98e082aa 100644
--- a/apps/temp-docs/docs/reference/javascript.mdx
+++ b/apps/temp-docs/docs/reference/javascript.mdx
@@ -2,7 +2,7 @@
slug: /
sidebar_position: 1
id: supabase-js
-title: Supabase Javascript Library
+title: Supabase JavaScript Library
sidebar_label: Supabase JavaScript Library
hide_table_of_contents: true
---
diff --git a/apps/temp-docs/docs/reference/javascript/release-notes.mdx b/apps/temp-docs/docs/reference/javascript/release-notes.mdx
index f102eb5493c..287766c07d9 100644
--- a/apps/temp-docs/docs/reference/javascript/release-notes.mdx
+++ b/apps/temp-docs/docs/reference/javascript/release-notes.mdx
@@ -1,5 +1,6 @@
---
id: release-notes
+title: Release Notes
---
# Release Notes
diff --git a/apps/temp-docs/docs/reference/javascript/typescript-support.mdx b/apps/temp-docs/docs/reference/javascript/typescript-support.mdx
index cb564843bba..2810b23f018 100644
--- a/apps/temp-docs/docs/reference/javascript/typescript-support.mdx
+++ b/apps/temp-docs/docs/reference/javascript/typescript-support.mdx
@@ -1,5 +1,6 @@
---
id: typescript-support
+title: Typescript Support
---
# Typescript Support
diff --git a/apps/temp-docs/docs/reference/storage/release-notes.mdx b/apps/temp-docs/docs/reference/storage/release-notes.mdx
index 8dad269f0d9..fb41e9fb6c9 100644
--- a/apps/temp-docs/docs/reference/storage/release-notes.mdx
+++ b/apps/temp-docs/docs/reference/storage/release-notes.mdx
@@ -1,5 +1,6 @@
---
id: release-notes
+title: Release Notes
---
# Release Notes
diff --git a/apps/temp-docs/pages/_app.tsx b/apps/temp-docs/pages/_app.tsx
index 0e5b07903fa..2504cf3e5a7 100644
--- a/apps/temp-docs/pages/_app.tsx
+++ b/apps/temp-docs/pages/_app.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import type { AppProps } from 'next/app'
import { ThemeProvider } from '../components/Providers'
-import { SearchProvider } from '~/components/Navigation/DocSearch'
+import { SearchProvider } from '~/components/DocSearch'
import '../styles/main.scss'
import '../styles/docsearch.scss'
import '../styles/algolia-search.scss'
diff --git a/apps/temp-docs/scripts/build-search.js b/apps/temp-docs/scripts/build-search.js
index aa480d25986..3ec789f839d 100644
--- a/apps/temp-docs/scripts/build-search.js
+++ b/apps/temp-docs/scripts/build-search.js
@@ -5,12 +5,15 @@ const matter = require('gray-matter')
const dotenv = require('dotenv')
const algoliasearch = require('algoliasearch/lite')
-// [Joshen] Scaffolding index logic to save to Algolia
-// Need to think about what object structure to send to algolia
-// Experiment is currently only sending MDX files from the docs/guides
-// We need to send everything else too
+// [Joshen] We initially thought of building out our search using Algolia directly,
+// but eventually decided to just use DocSearch since it provides us a UI and some
+// configurations out of the box (e.g Doc hierarchy).
-// Also note that we'll need to do a general clean up of the files in the docs
+// As such when creating the search object, the properties that are specifically read
+// by DocSearch are "type" and "hierarchy". The rest, though saved into Algolia (which we
+// can potentially use to craft more nuanced search experiences) are not used by DocSearch
+
+// Note that we'll need to do a general clean up of the files in the docs
// A lot of them are not even linked to within the docs site, so just need to
// double check if they can be removed or if we want them in the side bars.
const ignoredFiles = [
@@ -20,6 +23,16 @@ const ignoredFiles = [
'docs/guides.mdx',
]
+const nameMap = {
+ api: 'Management API',
+ cli: 'Supabase CLI',
+ auth: 'Auth Server',
+ storage: 'Storage Server',
+ postgres: 'Postgres',
+ dart: 'Supabase Flutter Library',
+ javascript: 'Supabase JavaScript Library',
+}
+
async function walk(dir) {
let files = await fs.promises.readdir(dir)
files = await Promise.all(
@@ -63,22 +76,27 @@ async function walk(dir) {
const { id, title, description } = data
const url = (slug.includes('/generated') ? slug.replace('/generated', '') : slug)
- .replace('docs', '/docs')
+ .replace('docs', '')
.replace(/\.mdx$/, '')
const source = slug.includes('/reference') ? 'reference' : 'guide'
const object = {
+ // For Algolia
objectID: crypto.randomUUID(),
id,
title,
description,
url,
source,
- // content,
+ pageContent: content,
+ category: undefined,
+ version: undefined,
+
+ // Docsearch specific
type: 'lvl1',
hierarchy: {
- lvl0: 'Core Concepts',
- lvl1: 'Dark Mode',
- lvl2: title,
+ lvl0: 'Guides',
+ lvl1: title,
+ lvl2: null,
lvl3: null,
lvl4: null,
lvl5: null,
@@ -87,15 +105,31 @@ async function walk(dir) {
}
if (slug.includes('/reference')) {
- const slugSegments = slug.split('/')
- const category = slugSegments[slugSegments.indexOf('reference') + 1]
- const version = slugSegments[slugSegments.indexOf('reference') + 2] || ''
-
- object.category = category.replace(/\.mdx$/, '')
- if (version.length === 2) object.version = version
- } else {
- object.category = undefined
- object.version = undefined
+ const urlSegments = url.split('/')
+ const category = urlSegments[urlSegments.indexOf('reference') + 1]
+ const version = urlSegments[urlSegments.indexOf('reference') + 2] || ''
+
+ const hasVersion = /v[0-9]+/.test(version)
+ if (hasVersion) {
+ object.version = version
+ object.type = title === nameMap[category] ? 'lvl2' : 'lvl3'
+ object.hierarchy.lvl1 = nameMap[category]
+ object.hierarchy.lvl2 = version
+ object.hierarchy.lvl3 = title
+ } else {
+ const page = urlSegments[urlSegments.indexOf('reference') + 2]
+ if (page === 'generated') {
+ } else {
+ if (page !== undefined) {
+ object.type = 'lvl2'
+ object.hierarchy.lvl1 = nameMap[category]
+ object.hierarchy.lvl2 = title
+ }
+ }
+ }
+
+ object.category = category ? category.replace(/\.mdx$/, '') : undefined
+ object.hierarchy.lvl0 = 'References'
}
return object