@@ -5,6 +5,7 @@ import { profileAsync } from "../core/server-timing";
55import { feeds , visits , visitStats } from "../db/schema" ;
66import { HyperLogLog } from "../utils/hyperloglog" ;
77import { extractImageWithMetadata } from "../utils/image" ;
8+ import { stripMarkdown } from "../utils/markdown" ;
89import { syncFeedAISummaryQueueState } from "./feed-ai-summary" ;
910import { bindTagToPost } from "./tag" ;
1011import { clearFeedCache } from "./clear-feed-cache" ;
@@ -94,8 +95,9 @@ export function FeedService(): Hono<{
9495 limit : limit_num + 1 ,
9596 } ) ) ) . map ( ( { content, hashtags, summary, ...other } : any ) => {
9697 const avatar = extractImageWithMetadata ( content ) ;
98+ const plainText = stripMarkdown ( content ) ;
9799 return {
98- summary : summary . length > 0 ? summary : content . length > 100 ? content . slice ( 0 , 100 ) : content ,
100+ summary : summary . length > 0 ? summary : plainText . length > 100 ? plainText . slice ( 0 , 100 ) : plainText ,
99101 hashtags : hashtags . map ( ( { hashtag } : any ) => hashtag ) ,
100102 avatar,
101103 ...other
@@ -309,11 +311,10 @@ export function FeedService(): Hono<{
309311 function formatAndCacheData ( feed : any , feedDirection : "previous_feed" | "next_feed" ) {
310312 if ( feed ) {
311313 const hashtags_flatten = feed . hashtags . map ( ( f : any ) => f . hashtag ) ;
314+ const plainText = stripMarkdown ( feed . content ) ;
312315 const summary = feed . summary . length > 0
313316 ? feed . summary
314- : feed . content . length > 50
315- ? feed . content . slice ( 0 , 50 )
316- : feed . content ;
317+ : plainText . length > 50 ? plainText . slice ( 0 , 50 ) : plainText ;
317318 const cacheKey = `${ feed . id } _${ feedDirection } _${ id_num } ` ;
318319 const cacheData = {
319320 id : feed . id ,
@@ -531,8 +532,9 @@ export function SearchService(): Hono<{
531532 } ,
532533 orderBy : [ desc ( feeds . createdAt ) , desc ( feeds . updatedAt ) ] ,
533534 } ) ) ) ) . map ( ( { content, hashtags, summary, ...other } : any ) => {
535+ const plainText = stripMarkdown ( content ) ;
534536 return {
535- summary : summary . length > 0 ? summary : content . length > 100 ? content . slice ( 0 , 100 ) : content ,
537+ summary : summary . length > 0 ? summary : plainText . length > 100 ? plainText . slice ( 0 , 100 ) : plainText ,
536538 hashtags : hashtags . map ( ( { hashtag } : any ) => hashtag ) ,
537539 ...other
538540 } ;
0 commit comments