mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(home): preserve popular thread preview markers
This commit is contained in:
@@ -138,6 +138,26 @@ describe('PopularThreadsBox', () => {
|
||||
expect(container.textContent).toContain('thread title');
|
||||
});
|
||||
|
||||
it('preserves literal preview markers without applying body markdown styles', () => {
|
||||
testState.popularPosts = [
|
||||
{
|
||||
cid: 'thread-markers',
|
||||
communityAddress: 'music-posting.eth',
|
||||
content: '>we got 5chan before Half Life 3\n*poisons u*',
|
||||
link: 'https://cdn.example/thread-markers.jpg',
|
||||
thumbnailUrl: 'https://cdn.example/thread-markers-thumb.jpg',
|
||||
title: '',
|
||||
},
|
||||
];
|
||||
|
||||
renderPopularThreadsBox();
|
||||
|
||||
expect(container.textContent).toContain('>we got 5chan before Half Life 3');
|
||||
expect(container.textContent).toContain('*poisons u*');
|
||||
expect(container.querySelector('.greentext')).toBeNull();
|
||||
expect(container.querySelector('.spoilertext')).toBeNull();
|
||||
});
|
||||
|
||||
it('subscribes to feed state only while popular threads are loading', () => {
|
||||
testState.isLoading = true;
|
||||
testState.popularPosts = [];
|
||||
|
||||
@@ -14,7 +14,7 @@ import { DirectoryCommunity, findDirectoryByAddress } from '../../../hooks/use-d
|
||||
import { useCommunityIdentifiers } from '../../../hooks/use-community-identifiers';
|
||||
import { getCommentCommunityAddress } from '../../../lib/utils/comment-utils';
|
||||
import { getBoardPath } from '../../../lib/utils/route-utils';
|
||||
import { removeMarkdown } from '../../../lib/utils/post-utils';
|
||||
import { CATALOG_PREVIEW_MARKDOWN_OPTIONS, removeMarkdown } from '../../../lib/utils/post-utils';
|
||||
|
||||
interface PopularThreadProps {
|
||||
post: Comment;
|
||||
@@ -30,7 +30,7 @@ const PopularThreadsLoading = ({ boardAddresses }: { boardAddresses: string[] })
|
||||
};
|
||||
|
||||
const ContentPreview = ({ content, maxLength = 99 }: { content: string; maxLength?: number }) => {
|
||||
const plainText = removeMarkdown(content).trim().replaceAll(' ', '').replace(/\n\n/g, '\n').replaceAll('\n\n', '');
|
||||
const plainText = removeMarkdown(content, CATALOG_PREVIEW_MARKDOWN_OPTIONS).trim().replaceAll(' ', '').replace(/\n\n/g, '\n').replaceAll('\n\n', '');
|
||||
const truncatedText = plainText.length > maxLength ? `${plainText.substring(0, maxLength).trim()}...` : plainText;
|
||||
|
||||
return truncatedText;
|
||||
|
||||
Reference in New Issue
Block a user