+ {post.data.excerpt} +
+ ) + } + { + variant === "feature" && ( + + ) + } + + { + (bylines.length > 0 || visibleTags.length > 0) && ( + + ) + } +-
- {tags.map((tag) => (
-
- - {tag.label} - - ))} -
diff --git a/demos/playground/astro.config.mjs b/demos/playground/astro.config.mjs index 3b8d2e9123..a983708587 100644 --- a/demos/playground/astro.config.mjs +++ b/demos/playground/astro.config.mjs @@ -32,7 +32,7 @@ export default defineConfig({ { provider: fontProviders.google(), name: "Inter", - cssVariable: "--font-sans", + cssVariable: "--font-body", weights: [400, 500, 600, 700], fallbacks: ["sans-serif"], }, diff --git a/demos/playground/src/components/Byline.astro b/demos/playground/src/components/Byline.astro new file mode 100644 index 0000000000..a76857c0d2 --- /dev/null +++ b/demos/playground/src/components/Byline.astro @@ -0,0 +1,230 @@ +--- +import type { ContentBylineCredit } from "emdash"; + +interface Props { + bylines: ContentBylineCredit[]; + /** inline: stacked avatars + names on one line. list: one row per author with role. */ + layout?: "inline" | "list"; + /** How many names the inline layout spells out before collapsing the rest into "+N" */ + max?: number; + size?: "xs" | "sm" | "md" | "lg"; + class?: string; +} + +const { + bylines, + layout = "inline", + max = 1, + size = layout === "list" ? "lg" : "xs", + class: className, +} = Astro.props; + +const WHITESPACE = /\s+/; + +const people = bylines.map(({ byline, roleLabel }) => ({ + name: byline.displayName, + role: roleLabel, + src: byline.avatarStorageKey + ? (Astro.locals.emdash?.getPublicMediaUrl?.(byline.avatarStorageKey) ?? + `/_emdash/api/media/file/${byline.avatarStorageKey.split("/").map(encodeURIComponent).join("/")}`) + : null, + initials: byline.displayName + .split(WHITESPACE) + .filter(Boolean) + .slice(0, layout === "list" ? 2 : 1) + .map((word) => [...word][0]?.toUpperCase() ?? "") + .join(""), +})); +const shown = people.slice(0, max).map((person) => person.name); +const hidden = people.slice(max).map((person) => person.name); +--- + +{ + people.length > 0 && layout === "list" && ( +
+ {post.data.excerpt} +
+ ) + } + { + variant === "feature" && ( + + ) + } + + { + (bylines.length > 0 || visibleTags.length > 0) && ( + + ) + } +