Skip to main content
Glama
CodeConditionalRenderer.tsx1.14 kB
'use client'; import type { FC, PropsWithChildren } from 'react'; import type { CodeCompAttributes } from './Code'; import { useCodeContext } from './CodeContext'; export const CodeConditionalRender: FC< PropsWithChildren<CodeCompAttributes> > = ({ children, ...props }) => { const { packageManager, codeFormat, contentDeclarationFormat } = useCodeContext(); const isPackageManagerUndefined = typeof props.packageManager === 'undefined'; const isPackageManagerSelected = packageManager === props.packageManager; const isCodeFormatUndefined = typeof props.codeFormat === 'undefined'; const isCodeFormatSelected = codeFormat === props.codeFormat; const isContentDeclarationFormatUndefined = typeof props.contentDeclarationFormat === 'undefined'; const isContentDeclarationFormatSelected = contentDeclarationFormat === props.contentDeclarationFormat; if ( (isPackageManagerUndefined || isPackageManagerSelected) && (isCodeFormatUndefined || isCodeFormatSelected) && (isContentDeclarationFormatUndefined || isContentDeclarationFormatSelected) ) { return children; } return <></>; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server