0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Added image fallback and site icon/title to <GhPostBookmark> (#2401)

no issue

- adds `{{get-setting "key"}}` helper to make settings available in templates without needing a backing class
- updated `<GhPostBookmark>` component
  - if post feature image isn't present, fall back to site cover image
  - add site icon (if present) and title to the details line
  - removed author image

Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
This commit is contained in:
Kevin Ansfield 2022-05-18 19:05:27 +01:00 committed by GitHub
parent f2b9fa544f
commit 473831ac2b
3 changed files with 49 additions and 19 deletions

View file

@ -1,19 +1,20 @@
<div class="gh-post-bookmark-container"> <div class="gh-post-bookmark-container">
<div class="gh-post-bookmark"> <div class="gh-post-bookmark">
{{#if @post.featureImage}} {{#let (or @post.featureImage (get-setting "coverImage")) as |imageUrl|}}
<div class="gh-post-bookmark-image"> {{#if imageUrl}}
<img src={{@post.featureImage}} alt="" role="presentation" /> <div class="gh-post-bookmark-image">
</div> <img src={{imageUrl}} alt="" role="presentation" />
{{/if}} </div>
{{/if}}
{{/let}}
<div class="gh-post-bookmark-content"> <div class="gh-post-bookmark-content">
<div class="gh-post-bookmark-title">{{@post.title}}</div> <div class="gh-post-bookmark-title">{{@post.title}}</div>
<div class="gh-post-bookmark-text truncate">{{@post.excerpt}}</div> <div class="gh-post-bookmark-text truncate">{{@post.excerpt}}</div>
<div class="gh-post-bookmark-details"> <div class="gh-post-bookmark-details">
{{#if @post.primaryAuthor.profileImage}} {{#if (get-setting "icon")}}
<div class="gh-post-bookmark-author-image"> <div class="gh-post-bookmark-site-icon"><img src={{get-setting "icon"}} alt="" role="presentation" /></div>
<img src={{@post.primaryAuthor.profileImage}} alt="" role="presentation" />
</div>
{{/if}} {{/if}}
<div class="gh-post-bookmark-site-title">{{get-setting "title"}}</div>
<div class="gh-post-bookmark-authors">{{post-author-names @post}}</div> <div class="gh-post-bookmark-authors">{{post-author-names @post}}</div>
</div> </div>
</div> </div>

View file

@ -0,0 +1,11 @@
import Helper from '@ember/component/helper';
import {get} from '@ember/object';
import {inject as service} from '@ember/service';
export default class GetSetting extends Helper {
@service settings;
compute([key = '']) {
return get(this.settings, key);
}
}

View file

@ -657,8 +657,8 @@
} }
.gh-post-bookmark { .gh-post-bookmark {
display: flex; display: grid;
align-items: center; grid-template-columns: 1fr minmax(0, 2fr);
width: 100%; width: 100%;
max-width: 640px; max-width: 640px;
margin-top: 1.6rem; margin-top: 1.6rem;
@ -681,33 +681,39 @@
} }
.gh-post-bookmark-image { .gh-post-bookmark-image {
max-width: 33%;
max-height: 152px;
display: inherit; display: inherit;
} }
.gh-post-bookmark-image img { .gh-post-bookmark-image img {
width: 100%; width: 100%;
height: 100%;
max-height: 152px;
object-fit: cover; object-fit: cover;
border-radius: var(--border-radius) 0 0 var(--border-radius); border-radius: var(--border-radius) 0 0 var(--border-radius);
} }
.gh-post-bookmark-content { .gh-post-bookmark-content {
max-width: 67%; display: flex;
flex-direction: column;
justify-content: space-between;
padding: 2rem; padding: 2rem;
} }
.gh-post-bookmark-title { .gh-post-bookmark-title {
display: -webkit-box;
margin-bottom: .4rem; margin-bottom: .4rem;
color: var(--darkgrey); color: var(--darkgrey);
font-size: 1.5rem; font-size: 1.5rem;
font-weight: 600; font-weight: 600;
line-height: 1.4em; line-height: 1.4em;line-clamp: 2;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
} }
.gh-post-bookmark-text { .gh-post-bookmark-text {
margin-bottom: 1.6rem; margin-bottom: 1.6rem;
color: var(--midgrey); color: var(--middarkgrey);
font-size: 1.4rem; font-size: 1.4rem;
font-weight: 400; font-weight: 400;
} }
@ -715,15 +721,27 @@
.gh-post-bookmark-details { .gh-post-bookmark-details {
display: flex; display: flex;
align-items: center; align-items: center;
color: var(--midgrey); color: var(--middarkgrey);
font-size: 1.4rem; font-size: 1.4rem;
font-weight: 500; font-weight: 400;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.gh-post-bookmark-site-title {
color: var(--darkgrey);
font-weight: 500;
}
.gh-post-bookmark-authors:before {
content: "•";
margin: 0 6px;
color: var(--darkgrey);
}
.gh-post-bookmark-site-icon,
.gh-post-bookmark-author-image { .gh-post-bookmark-author-image {
width: 20px; width: 20px;
height: 20px; height: 20px;
margin-right: 6px; margin-right: 6px;
} }