Files
supabase/apps/studio/components/layouts/DocsLayout/DocsLayout.utils.tsx
T
Ivan VasilovandJoshen Lim 05a542ccea chore: Migrate all feather icons to lucide icons (#29038)
* Add lucide-react to docs (to make the autocomplete work).

* Migrate the docs app icons.

* Migrate the ui-patterns.

* Remove the old icons from ui package.

* Migrate the www app from react-feather icons.

* Migrate all of studio icons.

* Migrate the only component in design-system.

* Fix an old import in ui package. Revert an import in docs app.

* Fix some pages in www.

* Remove unneeded files used in generation of icons.

* Fix a prettier error.

* Fix more issues in www.

* Fix an issue in Log Date picker.

* Replace all string sizes with number sizes because the icons grew in some cases.

* Fix more imports in security page.

* Fix an extra import.

* Remove the size prop from all icons if they're in a button and they match the button size.

* Minor fixes for docs and www.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-09-04 19:46:21 +08:00

110 lines
2.7 KiB
TypeScript

import type { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'
import { BASE_PATH } from 'lib/constants'
import { Book, BookOpen } from 'lucide-react'
import SVG from 'react-inlinesvg'
export const generateDocsMenu = (
ref: string,
tables: string[],
functions: string[],
flags?: { authEnabled: boolean }
): ProductMenuGroup[] => {
return [
{
title: 'Getting Started',
items: [
{ name: 'Introduction', key: 'introduction', url: `/project/${ref}/api`, items: [] },
{
name: 'Authentication',
key: 'auth',
url: `/project/${ref}/api?page=auth`,
items: [],
},
...(flags?.authEnabled
? [
{
name: 'User Management',
key: 'users',
url: `/project/${ref}/api?page=users`,
items: [],
},
]
: []),
],
},
{
title: 'Tables and Views',
items: [
{
name: 'Introduction',
key: 'tables-intro',
url: `/project/${ref}/api?page=tables-intro`,
items: [],
},
...tables.sort().map((table) => {
return {
name: table,
key: table,
url: `/project/${ref}/api?resource=${table}`,
items: [],
}
}),
],
},
{
title: 'Stored Procedures',
items: [
{
name: 'Introduction',
key: 'rpc-intro',
url: `/project/${ref}/api?page=rpc-intro`,
items: [],
},
...functions.map((fn) => {
return { name: fn, key: fn, url: `/project/${ref}/api?rpc=${fn}`, items: [] }
}),
],
},
{
title: 'GraphQL',
items: [
{
name: 'GraphiQL',
key: 'graphiql',
url: `/project/${ref}/api/graphiql`,
icon: (
<SVG
src={`${BASE_PATH}/img/graphql.svg`}
style={{ width: `${16}px`, height: `${16}px` }}
className="text-foreground"
preProcessor={(code) => code.replace(/svg/, 'svg class="m-auto text-color-inherit"')}
/>
),
items: [],
},
],
},
{
title: 'More Resources',
items: [
{
name: 'Guides',
key: 'guides',
url: `https://supabase.com/docs`,
icon: <Book size={14} strokeWidth={2} />,
items: [],
isExternal: true,
},
{
name: 'API Reference',
key: 'api-reference',
url: `https://supabase.com/docs/guides/api`,
icon: <BookOpen size={14} strokeWidth={2} />,
items: [],
isExternal: true,
},
],
},
]
}