diff --git a/packages/ui/app/src/mdx/base-components.tsx b/packages/ui/app/src/mdx/base-components.tsx index 9a33455e04..da6b966086 100644 --- a/packages/ui/app/src/mdx/base-components.tsx +++ b/packages/ui/app/src/mdx/base-components.tsx @@ -116,9 +116,9 @@ export const A: FC> = ({ className, chil !isValidElement(child) ? child : isImgElement(child) - ? cloneElement(child, { disableZoom: true }) + ? cloneElement(child, { noZoom: true }) : child.type === "img" - ? createElement(Image, { ...child.props, disableZoom: true }) + ? createElement(Image, { ...child.props, noZoom: true }) : child, )} @@ -126,35 +126,71 @@ export const A: FC> = ({ className, chil }; export interface ImgProps extends ComponentProps<"img"> { - disableZoom?: boolean; + noZoom?: boolean; } function isImgElement(element: ReactElement): element is ReactElement { return element.type === Image; } -export const Image: FC = ({ className, src, height, width, disableZoom, ...rest }) => { +export const Image: FC = ({ className, src, width: w, height: h, noZoom, style, ...rest }) => { const { files } = useDocsContext(); - // const mounted = useMounted(); - // if (!mounted || disableZoom) { - // return {alt}; - // } + const fernImageSrc = useMemo((): DocsV1Read.File_ | undefined => { if (src == null) { return undefined; } + // if src starts with `file:`, assume it's a referenced file; fallback to src if not found if (src.startsWith("file:")) { const fileId = src.slice(5); - return files[fileId]; + return files[fileId] ?? { type: "url", url: src }; } return { type: "url", url: src }; }, [files, src]); + const width = stripUnits(w); + const height = stripUnits(h); + + const fernImage = ( + + ); + + if (noZoom) { + return fernImage; + } + return ( - + {fernImage} ); }; + +// preserves pixel widths and heights, but strips units from other values +function stripUnits(str: string | number | undefined): number | `${number}` | undefined { + if (str == null || typeof str === "number") { + return str; + } else if (/^\d+$/.test(str)) { + // if str is a number, return it as a string + return str as `${number}`; + } else if (/^\d+(\.\d+)?(px)$/.test(str)) { + // if str is a number followed by "px", return the number as a string + return str.slice(0, -2) as `${number}`; + } + + // TODO: handle rem + + return undefined; +} diff --git a/tests/fern/fern/content/overview/home/january.mdx b/tests/fern/fern/content/overview/home/january.mdx new file mode 100644 index 0000000000..9961cb89b0 --- /dev/null +++ b/tests/fern/fern/content/overview/home/january.mdx @@ -0,0 +1,51 @@ +--- +title: January 2024 Release Notes +subtitle: Fern product updates and release notes for January 2024 +--- + +
+ + Added +
+ +
+ + Added +
+ +
+ + Added +
+ +
+ + Added +
+ +
+ + Added +
+ +
+ + Added +
+ +--- + +
+ + Added +
+ +
+ + Added +
+ +
+ + Added +
diff --git a/tests/fern/fern/docs.yml b/tests/fern/fern/docs.yml index d2df41d063..bf46633581 100644 --- a/tests/fern/fern/docs.yml +++ b/tests/fern/fern/docs.yml @@ -31,6 +31,8 @@ navigation: path: ./content/overview/home/introduction.mdx - page: Getting Started path: ./content/overview/home/getting-started.mdx + - page: Release January + path: ./content/overview/home/january.mdx - page: Components path: ./content/components.mdx hidden: true diff --git a/tests/fern/fern/fern.config.json b/tests/fern/fern/fern.config.json index 23db219601..04e6d6a4d7 100644 --- a/tests/fern/fern/fern.config.json +++ b/tests/fern/fern/fern.config.json @@ -1,4 +1,4 @@ { "organization": "fern", - "version": "0.20.0-1-g8f601b6ab" + "version": "0.26.2-9-g50eeced23" } \ No newline at end of file diff --git a/tests/fern/fern/images/plus.svg b/tests/fern/fern/images/plus.svg new file mode 100644 index 0000000000..94034c1f62 --- /dev/null +++ b/tests/fern/fern/images/plus.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file