publish: snippets allow image previews

This commit is contained in:
Matilde Park 2020-11-25 00:19:17 -05:00
parent 059b52ea23
commit 49fbdc9236
2 changed files with 6 additions and 3 deletions

View File

@ -113,6 +113,6 @@ export function getComments(node: GraphNode): GraphNode {
export function getSnippet(body: string) { export function getSnippet(body: string) {
const start = body.slice(0, body.indexOf('\n', 2)); const start = body.slice(0, body.indexOf('\n', 2));
return start === body ? start : `${start}...`; return (start === body || start.startsWith("![")) ? start : `${start}...`;
} }

View File

@ -3,7 +3,7 @@ import moment from "moment";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import styled from "styled-components"; import styled from "styled-components";
import ReactMarkdown from "react-markdown"; import ReactMarkdown from "react-markdown";
import { Col, Box, Text } from "@tlon/indigo-react"; import { Col, Box, Text, Image } from "@tlon/indigo-react";
import { cite } from "~/logic/lib/util"; import { cite } from "~/logic/lib/util";
import { Contact } from "~/types/contact-update"; import { Contact } from "~/types/contact-update";
@ -67,7 +67,10 @@ export function NotePreview(props: NotePreviewProps) {
<Text fontSize='14px'> <Text fontSize='14px'>
<ReactMarkdown <ReactMarkdown
unwrapDisallowed unwrapDisallowed
allowedTypes={["text", "root", "break", "paragraph"]} allowedTypes={["text", "root", "break", "paragraph", "image"]}
renderers={{
image: (props) => <Image src={props.src} maxHeight='300px' style={{ objectFit: 'cover' }}/>
}}
source={snippet} source={snippet}
/> />
</Text> </Text>