mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 01:52:42 +03:00
Merge pull request #4875 from urbit/lf/snippets
publish: fix snippet generation
This commit is contained in:
commit
f32caa87c1
@ -1,4 +1,4 @@
|
||||
import { GraphNode, Post, TextContent } from '@urbit/api';
|
||||
import { Content, GraphNode, Post, TextContent } from '@urbit/api';
|
||||
import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap';
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
import { buntPost } from '~/logic/lib/post';
|
||||
@ -118,8 +118,9 @@ export function getComments(node: GraphNode): GraphNode {
|
||||
return comments;
|
||||
}
|
||||
|
||||
export function getSnippet(body: any) {
|
||||
const firstContent = Object.values(body[0])[0];
|
||||
export function getSnippet(body: Content[]) {
|
||||
const firstContent = body
|
||||
.filter((c: Content): c is TextContent => 'text' in c).map(c => c.text)[0] ?? '';
|
||||
const newlineIdx = firstContent.indexOf('\n', 2);
|
||||
const end = newlineIdx > -1 ? newlineIdx : firstContent.length;
|
||||
const start = firstContent.substr(0, end);
|
||||
|
Loading…
Reference in New Issue
Block a user