mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-03 01:31:14 +00:00
Add inline markdown rendering for post titles. Fixes #827
This commit is contained in:
parent
927702625a
commit
be48e1be40
2 changed files with 7 additions and 2 deletions
|
@ -42,6 +42,7 @@ import {
|
||||||
isVideo,
|
isVideo,
|
||||||
md,
|
md,
|
||||||
mdToHtml,
|
mdToHtml,
|
||||||
|
mdToHtmlInline,
|
||||||
numToSI,
|
numToSI,
|
||||||
relTags,
|
relTags,
|
||||||
setupTippy,
|
setupTippy,
|
||||||
|
@ -459,7 +460,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
title={url}
|
title={url}
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
>
|
>
|
||||||
{post.name}
|
<div dangerouslySetInnerHTML={mdToHtmlInline(post.name)} />
|
||||||
</a>
|
</a>
|
||||||
),
|
),
|
||||||
none: (
|
none: (
|
||||||
|
@ -468,7 +469,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
to={`/post/${post.id}`}
|
to={`/post/${post.id}`}
|
||||||
title={i18n.t("comments")}
|
title={i18n.t("comments")}
|
||||||
>
|
>
|
||||||
{post.name}
|
<div dangerouslySetInnerHTML={mdToHtmlInline(post.name)} />
|
||||||
</Link>
|
</Link>
|
||||||
),
|
),
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -167,6 +167,10 @@ export function mdToHtml(text: string) {
|
||||||
return { __html: md.render(text) };
|
return { __html: md.render(text) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function mdToHtmlInline(text: string) {
|
||||||
|
return { __html: md.renderInline(text) };
|
||||||
|
}
|
||||||
|
|
||||||
export function getUnixTime(text: string): number {
|
export function getUnixTime(text: string): number {
|
||||||
return text ? new Date(text).getTime() / 1000 : undefined;
|
return text ? new Date(text).getTime() / 1000 : undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue