Skip to content

Commit

Permalink
Add inline markdown rendering for post titles. Fixes #827
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Nov 18, 2022
1 parent 9277026 commit be48e1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/shared/components/post/post-listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
isVideo,
md,
mdToHtml,
mdToHtmlInline,
numToSI,
relTags,
setupTippy,
Expand Down Expand Up @@ -459,7 +460,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
title={url}
rel={relTags}
>
{post.name}
<div dangerouslySetInnerHTML={mdToHtmlInline(post.name)} />
</a>
),
none: (
Expand All @@ -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>
),
})}
Expand Down
4 changes: 4 additions & 0 deletions src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit be48e1b

Please sign in to comment.