mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-01 17:38:58 +00:00
Don't render markdown for summaries. Fixes #658
This commit is contained in:
parent
b77689ebd1
commit
58c25d1157
|
@ -374,3 +374,11 @@ br.big {
|
|||
.slight-radius {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.preview-lines {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import {
|
|||
isMod,
|
||||
mdToHtml,
|
||||
numToSI,
|
||||
previewLines,
|
||||
relTags,
|
||||
restoreScrollPosition,
|
||||
routeSortTypeToEnum,
|
||||
|
@ -221,7 +220,7 @@ export class Profile extends Component<any, ProfileState> {
|
|||
|
||||
get bioTag(): string {
|
||||
return this.state.personRes.person_view.person.bio
|
||||
? previewLines(this.state.personRes.person_view.person.bio)
|
||||
? this.state.personRes.person_view.person.bio
|
||||
: undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import {
|
|||
md,
|
||||
mdToHtml,
|
||||
numToSI,
|
||||
previewLines,
|
||||
relTags,
|
||||
setupTippy,
|
||||
showScores,
|
||||
|
@ -355,9 +354,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
|||
<li className="list-inline-item">
|
||||
<button
|
||||
className="text-muted btn btn-sm btn-link p-0"
|
||||
data-tippy-content={md.render(
|
||||
previewLines(post_view.post.body)
|
||||
)}
|
||||
data-tippy-content={md.render(post_view.post.body)}
|
||||
data-tippy-allowHtml={true}
|
||||
onClick={linkEvent(this, this.handleShowBody)}
|
||||
>
|
||||
|
@ -1093,12 +1090,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
|||
return (
|
||||
post.body &&
|
||||
!this.showBody && (
|
||||
<div
|
||||
className="md-div mb-1"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: md.render(previewLines(post.body)),
|
||||
}}
|
||||
/>
|
||||
<div className="md-div mb-1 preview-lines">{post.body}</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import {
|
|||
insertCommentIntoTree,
|
||||
isBrowser,
|
||||
isImage,
|
||||
previewLines,
|
||||
restoreScrollPosition,
|
||||
saveCommentRes,
|
||||
saveScrollPosition,
|
||||
|
@ -287,8 +286,7 @@ export class Post extends Component<any, PostState> {
|
|||
}
|
||||
|
||||
get descriptionTag(): string {
|
||||
let body = this.state.postRes.post_view.post.body;
|
||||
return body ? previewLines(body) : undefined;
|
||||
return this.state.postRes.post_view.post.body;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -1034,21 +1034,6 @@ function hsl(num: number) {
|
|||
return `hsla(${num}, 35%, 50%, 1)`;
|
||||
}
|
||||
|
||||
export function previewLines(
|
||||
text: string,
|
||||
maxChars = 300,
|
||||
maxLines = 1
|
||||
): string {
|
||||
return (
|
||||
text
|
||||
.slice(0, maxChars)
|
||||
.split("\n")
|
||||
// Use lines * 2 because markdown requires 2 lines
|
||||
.slice(0, maxLines * 2)
|
||||
.join("\n") + "..."
|
||||
);
|
||||
}
|
||||
|
||||
export function hostname(url: string): string {
|
||||
let cUrl = new URL(url);
|
||||
return cUrl.port ? `${cUrl.hostname}:${cUrl.port}` : `${cUrl.hostname}`;
|
||||
|
|
Loading…
Reference in a new issue