mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-05 15:52:55 +00:00
feat: open images in new tab
This commit is contained in:
parent
1b8ba9cf25
commit
dc6680f12f
1 changed files with 27 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
Box,
|
||||||
Flex,
|
Flex,
|
||||||
Heading,
|
Heading,
|
||||||
Link,
|
Link,
|
||||||
|
|
@ -10,16 +11,41 @@ import {
|
||||||
UnorderedList
|
UnorderedList
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import NextLink from 'next/link';
|
import NextLink from 'next/link';
|
||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
import { Code, Note } from '.';
|
import { Code, Note } from '.';
|
||||||
import { textStyles } from '../../../theme/foundations';
|
import { textStyles } from '../../../theme/foundations';
|
||||||
import { parseHeadingId } from '../../../utils/parseHeadingId';
|
import { parseHeadingId } from '../../../utils/parseHeadingId';
|
||||||
|
import { childrenIsAnImage } from '../../../utils';
|
||||||
|
|
||||||
const { h1, h2, h3, h4 } = textStyles;
|
const { h1, h2, h3, h4 } = textStyles;
|
||||||
|
|
||||||
const MDComponents = {
|
const MDComponents = {
|
||||||
// paragraphs
|
// paragraphs & images
|
||||||
p: ({ children }: any) => {
|
p: ({ children }: any) => {
|
||||||
|
// images in markdown are rendered as children of p tags for some reason
|
||||||
|
if (childrenIsAnImage(children)) {
|
||||||
|
const src = children[0].props.src;
|
||||||
|
const alt = children[0].props.alt || src;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link href={src} isExternal>
|
||||||
|
<Box position='relative' mb={7}>
|
||||||
|
<Image
|
||||||
|
alt={alt}
|
||||||
|
src={src}
|
||||||
|
width={700}
|
||||||
|
height={475}
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
height: 'auto'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text mb='7 !important' lineHeight={1.6}>
|
<Text mb='7 !important' lineHeight={1.6}>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue