-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrap Image component to prevent SSR issues
This is related to hashicorp/next-mdx-remote#405 When Image is used directly it produces error when server rendered. Wrapping it allows server to render the component without issues.
- Loading branch information
Showing
3 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Image, { ImageProps } from 'next/image'; | ||
import * as React from 'react'; | ||
|
||
function ImageSSR(props: ImageProps) { | ||
return <Image {...props} />; | ||
} | ||
|
||
export default ImageSSR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ImageSSR'; | ||
export { default } from './ImageSSR'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import Image from 'next/image'; | ||
import { MDXComponents } from 'mdx/types'; | ||
|
||
import AboutMeToggleMessage from '@/components/AboutMeToggleMessage'; | ||
import { default as CodeSnippet } from '@/components/CodeSnippet/CodeSnippet'; | ||
import CV from '@/components/CurriculumVitae'; | ||
import FullWidthSplitSection from '@/components/FullWidthSplitSection'; | ||
import Image from '@/components/ImageSSR'; | ||
import ResponsiveImage from '@/components/ResponsiveImage'; | ||
import Spinner from '@/components/Spinner'; | ||
import TooltipMessage from '@/components/TooltipMessage'; | ||
|
||
export const COMPONENT_MAP = { | ||
export const COMPONENT_MAP: MDXComponents = { | ||
pre: CodeSnippet, | ||
ResponsiveImage, | ||
Image, | ||
FullWidthSplitSection, | ||
Spinner, | ||
AboutMeToggleMessage, | ||
TooltipMessage, | ||
CV, | ||
FullWidthSplitSection, | ||
}; |