Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple authors in feature card #2723

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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