Skip to content

Commit

Permalink
Multiple authors in feature card (#2723)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas authored Nov 21, 2023
1 parent 6c72853 commit 4bf9d60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
21 changes: 15 additions & 6 deletions frontend/components/welcome/FeaturedCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export const FeaturedCard = ({ entry, source_manifest, direct_html_links, disabl
? null
: html`
<div class="author">
<a href=${author.url}> <img src=${author.image ?? transparent_svg} /><span>${author.name}</span></a>
<img src=${author.image ?? transparent_svg} />
<span>
<a href=${author.url}>${author.name}</a>
${author.has_coauthors ? html` and others` : null}
</span>
</div>
`}
<h3><a href=${href} title=${entry?.frontmatter?.title}>${entry?.frontmatter?.title ?? entry.id}</a></h3>
Expand All @@ -74,9 +78,13 @@ export const FeaturedCard = ({ entry, source_manifest, direct_html_links, disabl
* name: string?,
* url: string?,
* image: string?,
* has_coauthors?: boolean,
* }}
*/

/**
* @returns {AuthorInfo?}
*/
const author_info = (frontmatter) =>
author_info_item(frontmatter.author) ??
author_info_item({
Expand All @@ -90,9 +98,11 @@ const author_info = (frontmatter) =>
*/
const author_info_item = (x) => {
if (x instanceof Array) {
return author_info_item(x[0])
} else if (x == null) {
return null
const first = author_info_item(x[0])
if (first?.name) {
const has_coauthors = x.length > 1
return { ...first, has_coauthors }
}
} else if (typeof x === "string") {
return {
name: x,
Expand All @@ -111,7 +121,6 @@ const author_info_item = (x) => {
url,
image,
}
} else {
return null
}
return null
}
12 changes: 4 additions & 8 deletions frontend/featured-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ featured-card .author {
background: var(--welcome-card-author-backdrop);
/* background: hsl(var(--card-color-hue) 34% 46% / 59%); */
backdrop-filter: blur(15px);
color: black;
color: var(--index-text-color);
border-radius: 117px;
/* height: 2.5em; */
padding: 0.3em;
padding-right: 0.8em;
display: flex;
align-items: center;
gap: 0.4ch;
margin-left: 0.3rem;
}

featured-card .author img {
Expand All @@ -76,13 +79,6 @@ featured-card .author img {
overflow: hidden;
}

featured-card .author a {
display: flex;
flex-direction: row;
align-items: center;
gap: 0.4ch;
}

featured-card h3 a {
padding: 0.6em;
padding-bottom: 0;
Expand Down

0 comments on commit 4bf9d60

Please sign in to comment.