Add inline markdown rendering for post titles. Fixes #827 (#860)

This commit is contained in:
Dessalines 2022-11-17 21:01:52 -05:00 committed by GitHub
parent 927702625a
commit 78a6a19d8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -42,6 +42,7 @@ import {
isVideo,
md,
mdToHtml,
mdToHtmlInline,
numToSI,
relTags,
setupTippy,
@ -459,7 +460,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
title={url}
rel={relTags}
>
{post.name}
<div dangerouslySetInnerHTML={mdToHtmlInline(post.name)} />
</a>
),
none: (
@ -468,7 +469,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
to={`/post/${post.id}`}
title={i18n.t("comments")}
>
{post.name}
<div dangerouslySetInnerHTML={mdToHtmlInline(post.name)} />
</Link>
),
})}

View file

@ -167,6 +167,10 @@ export function mdToHtml(text: string) {
return { __html: md.render(text) };
}
export function mdToHtmlInline(text: string) {
return { __html: md.renderInline(text) };
}
export function getUnixTime(text: string): number {
return text ? new Date(text).getTime() / 1000 : undefined;
}