--- // Hero meta columns: Authors / Affiliations / Published / Resources. // Styles in src/styles/layout/_hero.css, behaviour in src/scripts/layout/meta.ts. import type { Author } from "./heroUtils"; interface Props { authors?: Author[]; affiliations?: Array<{ id: number; name: string; url?: string }>; published?: string; doi?: string; showPdf?: boolean; pdfProOnly?: boolean; pdfFilename: string; citationText: string; bibtex: string; links?: Array<{ label: string; url: string }>; } const { authors = [], affiliations = [], published, doi, showPdf = true, pdfProOnly = false, pdfFilename, citationText, bibtex, links = [], } = Astro.props as Props; // Authors are never hidden behind a hover: up to 6 listed, 7-12 listed in a // double-width cell, beyond that the first ones plus the last author and an // in-place "Show all" toggle. const AUTHORS_SHOWN = 10; const AFFILIATIONS_MAX = 6; const AFFILIATIONS_SHOWN = 5; const n = authors.length; const tier = n <= 6 ? "list" : n <= 12 ? "wide" : "long"; const keepAuthor = (i: number) => tier !== "long" || i < AUTHORS_SHOWN - 1 || i === n - 1; const hiddenAuthors = authors.filter((_, i) => !keepAuthor(i)).length; const firstHidden = authors.findIndex((_, i) => !keepAuthor(i)); const multi = affiliations.length > 1; const affName = (id: number) => affiliations.find((a) => a.id === id)?.name ?? ""; const affCollapsible = affiliations.length > AFFILIATIONS_MAX; const publishedDate = published ? new Date(published) : null; const pad = (v: number) => String(v).padStart(2, "0"); const publishedIso = publishedDate && !Number.isNaN(publishedDate.getTime()) ? `${publishedDate.getFullYear()}-${pad(publishedDate.getMonth() + 1)}-${pad(publishedDate.getDate())}` : undefined; const doiUrl = doi ? `https://doi.org/${doi}` : undefined; const cells = [ n > 0, affiliations.length > 0, Boolean(published || doi), true, ].filter(Boolean).length; const template = tier === "list" ? `repeat(${cells}, minmax(0, 1fr))` : `minmax(0, 2fr) repeat(${cells - 1}, minmax(0, 1fr))`; const ICON = { pdf: '', cite: '', ext: '', lock: '', }; ---
{ n > 0 && (

Author{n > 1 ? "s" : ""}

    {authors.map((a, i) => { const ids = a.affiliationIndices ?? []; const label = multi && ids.length ? `${a.name}, ${ids.map(affName).join(", ")}` : undefined; return ( {i === firstHidden && ( )}
  • {a.url ? {a.name} : {a.name}} {multi && ids.length > 0 && }
  • ); })}
{tier === "long" && ( )}
) } { affiliations.length > 0 && (

Affiliation{multi ? "s" : ""}

    {affiliations.map((f, i) => (
  1. = AFFILIATIONS_SHOWN }]} data-aff={String(f.id)} > {multi && } {f.url ? {f.name} : f.name}
  2. ))}
{affCollapsible && ( )}
) } { (published || doi) && (

Published

{published && (

)}

 

{doi && (

DOI {doi}

)}
) }

Resources

{ showPdf && ( PDF PDF (Pro) ) }
{ links.length > 0 && ( ) }