Skip to content
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
12 changes: 3 additions & 9 deletions astro/src/layouts/BlogLayout.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { getEntry, render } from "astro:content";
import { getBlogCatalog, type BlogCatalog } from "@lib/blog";
import { formatAuthorName, getBlogCatalog, type BlogCatalog } from "@lib/blog";
import { getOpenGraphImageData } from "@lib/og-image";
import { isEmpty, kebabCase, startCase } from "lodash-es";

Expand Down Expand Up @@ -53,12 +53,6 @@ const metadata: PageMetadata = {
),
};

function formatName(author) {
const { name, cited = undefined } = author.data;
const { first, middle, last } = cited || name;
return [first, middle, last].filter((n) => n).join(" ");
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to reviewer: This was moved to blog.ts so it could be reused in multiple pages

const { Content } = await render(blog);

import components from "../lib/mdx";
Expand All @@ -75,7 +69,7 @@ import ThemedSection from "@components/ThemedSection.astro";
property="article:published_time"
content={blog.data.published.toISOString()}
/>
<meta property="article:author" content={formatName(blogAuthor)} />
<meta property="article:author" content={formatAuthorName(blogAuthor)} />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue that copilot is calling out was not introduced by these changes as blogAuthor was used in the previous version.

              <TeamVignette member={blogAuthor} />

When I ran astro check, which runs typescript checks under the hood, no errors were flagged for BlogLayout.astro

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking this!

<meta property="article:section" content="Accessibility" />
{blog.data.tags.map((tag) => <meta property="article:tag" content={tag} />)}
</Fragment>
Expand Down Expand Up @@ -154,7 +148,7 @@ import ThemedSection from "@components/ThemedSection.astro";
{authors.map((author) => (
<li>
<a href={`/blog/authors/${author.id}`}>
{formatName(author)}
{formatAuthorName(author)}
</a>
</li>
))}
Expand Down
6 changes: 6 additions & 0 deletions astro/src/lib/blog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { getCollection, getEntries, type CollectionEntry } from "astro:content";
import { isEmpty, isNil, reverse, sortBy, uniqBy } from "lodash-es";

export function formatAuthorName(author: CollectionEntry<"staff">): string {
const { name, cited } = author.data;
const { first, middle, last } = cited || name;
return [first, middle, last].filter((n) => n).join(" ");
}

Comment thread
brian-montgomery marked this conversation as resolved.
export async function getBlogAuthors(
blogs?,
): Promise<Array<CollectionEntry<"staff">>> {
Expand Down
6 changes: 3 additions & 3 deletions astro/src/pages/blog/authors/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { getCollection } from "astro:content";
import { getBlogAuthors, orderByRecent } from "../../../lib/blog";
import { formatAuthorName, getBlogAuthors, orderByRecent } from "../../../lib/blog";
import type { Breadcrumbs } from "@lib/types";
import type { CollectionEntry } from "astro:content";

Expand Down Expand Up @@ -43,13 +43,13 @@ import BlogLayout from "../../../layouts/BlogLayout.astro";
---

<BlogLayout
title={`Blogs by ${author.data.name}`}
title={`Blogs by ${formatAuthorName(author)}`}
{crumbs}
blog={orderedBlogs[0]}
catalog={{ blogs: orderedBlogs }}
sidebar={true}
>
<Fragment slot="header">
<strong>Blogs</strong> by {author.data.name}
<strong>Blogs</strong> by {formatAuthorName(author)}
</Fragment>
</BlogLayout>
4 changes: 2 additions & 2 deletions astro/src/pages/blog/authors/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { getBlogAuthors } from "../../../lib/blog";
import { formatAuthorName, getBlogAuthors } from "../../../lib/blog";

const authors = await getBlogAuthors();
const title = "Authors";
Expand Down Expand Up @@ -29,7 +29,7 @@ import ThemedSection from "../../../components/ThemedSection.astro";
{
authors.map((author) => (
<li>
<a href={`/blog/authors/${author.id}`}>{author.data.name}</a>
<a href={`/blog/authors/${author.id}`}>{formatAuthorName(author)}</a>
</li>
))
}
Expand Down
Loading