mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 13:49:09 +03:00
* Demo api side panel * Add docs for storage and edge functions * Add content * fix * Add scroll to logic * Add storage docs * Add docs URLs * Add connecting to project section in getting started * Link back to docs site for product + resource specific docs * Add entry points into API side panel for table editor, auth users and storage * Add entry points into API side panel for edge functions * Beef up feature preview modal with content * Fix asset path * Address several feedback * Addressing more feedback * Shift GraphiQL page to database if new api docs flag enabled * Spelling * Wording changes * Spacing and wording * Fix small issues * Fix * Update key showing toggle button --------- Co-authored-by: Terry Sutton <saltcod@gmail.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { useParams } from 'common'
|
|
|
|
import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
|
|
import { Markdown } from '../Markdown'
|
|
import { PropsWithChildren } from 'react'
|
|
|
|
interface ContentSnippetProps {
|
|
apikey?: string
|
|
endpoint?: string
|
|
selectedLanguage: 'js' | 'bash'
|
|
snippet: {
|
|
key: string
|
|
category: string
|
|
title: string
|
|
description?: string
|
|
js?: (apikey?: string, endpoint?: string) => string
|
|
bash?: (apikey?: string, endpoint?: string) => string
|
|
}
|
|
}
|
|
|
|
const ContentSnippet = ({
|
|
apikey,
|
|
endpoint,
|
|
selectedLanguage,
|
|
snippet,
|
|
children,
|
|
}: PropsWithChildren<ContentSnippetProps>) => {
|
|
const { ref: projectRef } = useParams()
|
|
const codeSnippet = snippet[selectedLanguage]?.(apikey, endpoint).replaceAll(
|
|
'[ref]',
|
|
projectRef ?? ''
|
|
)
|
|
|
|
return (
|
|
<div id={snippet.key} className="space-y-4 py-6 pb-2 last:pb-6">
|
|
<div className="px-4 space-y-4">
|
|
<h2 className="doc-heading">{snippet.title}</h2>
|
|
{snippet.description !== undefined && (
|
|
<div className="doc-section">
|
|
<article className="text text-sm text-light">
|
|
<Markdown
|
|
className="max-w-none"
|
|
content={snippet.description.replaceAll('[ref]', projectRef ?? '_')}
|
|
/>
|
|
</article>
|
|
</div>
|
|
)}
|
|
</div>
|
|
{children}
|
|
{codeSnippet !== undefined && (
|
|
<div className="px-4 codeblock-container">
|
|
<div className="bg rounded p-2">
|
|
<SimpleCodeBlock className={selectedLanguage}>{codeSnippet}</SimpleCodeBlock>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
export default ContentSnippet
|