Add text post previews. (#328)

* Add text post previews.

* Add mask gradient over post preview text

* Increase post title font weight for contrast

Co-authored-by: spikecodes <19519553+spikecodes@users.noreply.github.com>
This commit is contained in:
mikupls 2021-11-20 22:13:50 +01:00 committed by GitHub
parent 3a9e6b4ca0
commit c2053524c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View file

@ -251,11 +251,20 @@ impl Post {
// Determine the type of media along with the media URL
let (post_type, media, gallery) = Media::parse(data).await;
// selftext is set for text posts when browsing a (sub)reddit.
// Do NOT use selftext_html, because we truncate this content
// in the template code, and using selftext_html might result
// in truncated html.
let mut body = rewrite_urls(&val(post, "selftext"));
if body == "" {
body = rewrite_urls(&val(post, "body_html"))
}
posts.push(Self {
id: val(post, "id"),
title: esc!(if title.is_empty() { fallback_title.clone() } else { title }),
community: val(post, "subreddit"),
body: rewrite_urls(&val(post, "body_html")),
body,
author: Author {
name: val(post, "author"),
flair: Flair {