mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
Follow-up to #48344: collapses the two resolution paths for the Admonition module into one. `src/admonition.tsx` was a back-compat shim re-exporting `src/Admonition/`. Two ways to resolve one module is exactly what produced the macOS self-import bug fixed in #48344, and the local typecheck errors that #48374 worked around. This removes the shim and standardizes on the PascalCase subpath, matching every other export in the package. **Changed:** - Codemodded all 246 `ui-patterns/admonition` imports to `ui-patterns/Admonition` (240 `.tsx`, 5 `.mdx`, 1 `.ts` across studio, docs, www, design-system, and lite-studio) - Pointed the 5 internal `'../admonition'` imports back at the `'../Admonition'` directory **Removed:** - `packages/ui-patterns/src/admonition.tsx`, and its `./admonition` entry in the exports map (regenerated with `pnpm gen:exports`) ## To test - `grep -r "ui-patterns/admonition" --include='*.ts*'` → no hits - `pnpm test:case-hazards` → passes - `pnpm typecheck` → all 15 tasks green - `pnpm --filter studio run lint:ratchet` → passes - `pnpm --filter ui-patterns vitest run src/Admonition` → 11 tests pass <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Standardized Admonition component imports across the application and documentation. * Improved compatibility with case-sensitive environments by using the canonical component path. * Removed the legacy Admonition import entry point. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
139 lines
4.0 KiB
TypeScript
139 lines
4.0 KiB
TypeScript
import {
|
|
Annotation,
|
|
annotations,
|
|
Code,
|
|
CodeSlot,
|
|
InlineCode,
|
|
Preview,
|
|
PreviewSlot,
|
|
Scrollycoding,
|
|
Section,
|
|
SectionCode,
|
|
SectionLink,
|
|
Slideshow,
|
|
Spotlight,
|
|
} from '@code-hike/mdx/components'
|
|
import Avatar from '~/components/Avatar'
|
|
import BlogCollapsible from '~/components/Blog/BlogCollapsible'
|
|
import DeveloperGrowthChart from '~/components/Charts/DeveloperGrowthChart'
|
|
import Chart from '~/components/Charts/PGCharts'
|
|
import CodeBlock from '~/components/CodeBlock/CodeBlock'
|
|
import { NamedCodeBlock } from '~/components/CodeTabs'
|
|
import ImageFadeStack from '~/components/ImageFadeStack'
|
|
import ImageGrid from '~/components/ImageGrid'
|
|
import InlineCodeTag from '~/components/InlineCode'
|
|
import Quote from '~/components/Quote'
|
|
import Tabs, { TabPanel } from '~/components/Tabs/Tabs'
|
|
import { ArrowUpRight } from 'lucide-react'
|
|
import type { PropsWithChildren } from 'react'
|
|
import { Badge, cn, Heading } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import { Image, type ImageProps } from 'ui-patterns/Image'
|
|
import { Mermaid } from 'ui-patterns/Mermaid'
|
|
|
|
const CH = {
|
|
Annotation,
|
|
Code,
|
|
CodeSlot,
|
|
InlineCode,
|
|
Preview,
|
|
PreviewSlot,
|
|
Scrollycoding,
|
|
Section,
|
|
SectionCode,
|
|
SectionLink,
|
|
Slideshow,
|
|
Spotlight,
|
|
annotations,
|
|
}
|
|
|
|
// import all components used in blog articles here
|
|
// to do: move this into a helper/utils, it is used elsewhere
|
|
|
|
const ignoreClass = 'ignore-on-export'
|
|
|
|
const LinkComponent = (props: PropsWithChildren<HTMLAnchorElement>) => (
|
|
<a
|
|
href={props.href}
|
|
target={props.target}
|
|
className={cn('inline relative [&_p]:inline', props.target === '_blank' && 'mr-4')}
|
|
>
|
|
{props.children}{' '}
|
|
{props.target === '_blank' && <ArrowUpRight className="absolute -right-3.5 w-3 top-0" />}
|
|
</a>
|
|
)
|
|
|
|
export default function mdxComponents(type?: 'blog' | 'lp' | undefined) {
|
|
const components = {
|
|
CodeBlock,
|
|
Tabs,
|
|
TabPanel,
|
|
NamedCodeBlock,
|
|
CH,
|
|
h1: (props: any) => <Heading {...props} tag="h1" />,
|
|
h2: (props: any) => <Heading {...props} tag="h2" />,
|
|
h3: (props: any) => <Heading {...props} tag="h3" />,
|
|
h4: (props: any) => <Heading {...props} tag="h4" />,
|
|
h5: (props: any) => <Heading {...props} tag="h5" />,
|
|
h6: (props: any) => <Heading {...props} tag="h6" />,
|
|
Badge,
|
|
Quote,
|
|
Avatar,
|
|
PGChart: (props: any) => {
|
|
return <Chart {...props} />
|
|
},
|
|
DeveloperGrowthChart,
|
|
pre: (props: any) => {
|
|
if (props.className !== ignoreClass) {
|
|
const childProps = props.children?.props
|
|
// Detect mermaid code blocks and render with Mermaid component
|
|
if (childProps?.className === 'language-mermaid') {
|
|
return <Mermaid chart={childProps.children} />
|
|
}
|
|
return <CodeBlock {...childProps} />
|
|
} else {
|
|
return <code {...props} />
|
|
}
|
|
},
|
|
ImageGrid,
|
|
ImageFadeStack,
|
|
img: (props: any) => {
|
|
if (props.className !== ignoreClass) {
|
|
return (
|
|
<Image
|
|
fill
|
|
className={cn(
|
|
'm-0 object-cover',
|
|
type === 'blog' ? 'rounded-md border' : '',
|
|
props.wide && 'wide',
|
|
props.className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
// biome-ignore lint/a11y/useAltText: provided in props
|
|
return <img {...props} />
|
|
},
|
|
Img: ({ zoomable = true, className, ...props }: ImageProps & { wide?: boolean }) => (
|
|
<Image
|
|
fill
|
|
containerClassName={cn(props.wide && 'wide')}
|
|
className={cn('m-0 object-cover', type === 'blog' ? 'rounded-md border' : '', className)}
|
|
zoomable={zoomable}
|
|
{...props}
|
|
/>
|
|
),
|
|
Link: LinkComponent,
|
|
code: (props: any) => <InlineCodeTag>{props.children}</InlineCodeTag>,
|
|
BlogCollapsible: (props: any) => <BlogCollapsible {...props} />,
|
|
Subtitle: (props: any) => (
|
|
<p className={cn('-mt-6 text-foreground-lighter text-lg', props.className)} {...props} />
|
|
),
|
|
Admonition,
|
|
Mermaid,
|
|
}
|
|
|
|
return components as any
|
|
}
|