Load Code component dynamically

This commit is contained in:
Marcus Blättermann 2023-01-24 18:14:20 +01:00
parent 69334843ce
commit b557d06263
No known key found for this signature in database
GPG Key ID: A1E1F04008AC450D
4 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import Code from './code' import Code from './codeDynamic'
import classes from '../styles/code.module.sass' import classes from '../styles/code.module.sass'
export const Pre = (props) => { export const Pre = (props) => {

View File

@ -0,0 +1,5 @@
import dynamic from 'next/dynamic'
export default dynamic(() => import('./code'), {
loading: () => 'Loading...',
})

View File

@ -5,7 +5,7 @@ import classNames from 'classnames'
import Icon from './icon' import Icon from './icon'
import Link from './link' import Link from './link'
import classes from '../styles/code.module.sass' import classes from '../styles/code.module.sass'
import Code from './code' import Code from './codeDynamic'
const defaultErrorMsg = `Can't fetch code example from GitHub :( const defaultErrorMsg = `Can't fetch code example from GitHub :(

View File

@ -1,7 +1,7 @@
import Link from './components/link' import Link from './components/link'
import Section, { Hr } from './components/section' import Section, { Hr } from './components/section'
import { Table, Tr, Th, Tx, Td } from './components/table' import { Table, Tr, Th, Tx, Td } from './components/table'
import Code from './components/code' import Code from './components/codeDynamic'
import { TypeAnnotation } from './components/typeAnnotation' import { TypeAnnotation } from './components/typeAnnotation'
import { InlineCode } from './components/inlineCode' import { InlineCode } from './components/inlineCode'
import CodeBlock, { Pre } from './components/codeBlock' import CodeBlock, { Pre } from './components/codeBlock'