mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 18:11:51 +08:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added new public MCP base URL environment variables for hosted and self-hosted setups. * Introduced reusable MDX components to render custom MCP configuration content. * **Documentation** * Updated the MCP guide to reference shared MCP server template values for examples. * Swapped the CI configuration example for a component-rendered snippet for consistency. * **Bug Fixes** * Improved self-hosted MCP base URL fallback so it prefers the new non-platform URL when no custom API URL is provided. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import {
|
|
getCustomContent,
|
|
type CustomContent as CustomContentKey,
|
|
} from '~/lib/custom-content/getCustomContent'
|
|
import type { ReactNode } from 'react'
|
|
|
|
import { resolveSharedDataPath } from './SharedData.utils'
|
|
|
|
type ValueFor<T extends CustomContentKey> = ReturnType<
|
|
typeof getCustomContent<[T]>
|
|
>[keyof ReturnType<typeof getCustomContent<[T]>>]
|
|
|
|
/**
|
|
* A wrapper component to access values from `custom-content.json` within MDX
|
|
* files. Mirrors the `getCustomContent` helper used in TSX code, and follows
|
|
* the same `data`/path-or-render-function pattern as `SharedData`.
|
|
*
|
|
* @param data - The `custom-content.json` key to read, e.g. `navigation:logo`.
|
|
* @param children - How to access the selected value. If it is a render
|
|
* function, it takes the value as a param. If it is a
|
|
* string, it takes a path through the value, formatted like
|
|
* `a[0].b.c`. If omitted, the value itself is rendered.
|
|
*
|
|
* @example Render a value inline
|
|
* <CustomContent data="metadata:title" />
|
|
*
|
|
* @example Address a nested field with a path
|
|
* <CustomContent data="navigation:logo">light</CustomContent>
|
|
*
|
|
* @example Use a render function for richer output
|
|
* <CustomContent data="navigation:logo">
|
|
* {(logo) => <img src={logo?.light} />}
|
|
* </CustomContent>
|
|
*/
|
|
function CustomContent<T extends CustomContentKey>({
|
|
data,
|
|
children,
|
|
}: {
|
|
data: T
|
|
children?: ((value: ValueFor<T>) => ReactNode) | string
|
|
}) {
|
|
const result = getCustomContent([data])
|
|
const value = Object.values(result)[0] as ValueFor<T>
|
|
|
|
if (typeof children === 'function') {
|
|
return children(value)
|
|
}
|
|
if (typeof children === 'string') {
|
|
return resolveSharedDataPath(value, children) as ReactNode
|
|
}
|
|
|
|
if (value != null && typeof value === 'object') {
|
|
return JSON.stringify(value) as unknown as ReactNode
|
|
}
|
|
|
|
return (value ?? null) as ReactNode
|
|
}
|
|
|
|
export { CustomContent }
|