-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resolve authors rendering as
[object Object]
- Loading branch information
Showing
3 changed files
with
20 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { type CollectionEntry, getCollection, getEntry } from 'astro:content'; | ||
|
||
export async function listAllAuthors() { | ||
const authorEntries = await getCollection('authors'); | ||
const authors = authorEntries.sort((first, second) => first.data.name.localeCompare(second.data.name, 'en-US', { usage: 'sort' })); | ||
|
||
return authors as unknown as CollectionEntry<'authors'>[]; | ||
} | ||
|
||
export async function getAuthor(authorId: string) { | ||
return getEntry('authors', authorId) as unknown as Promise<CollectionEntry<'authors'> | undefined>; | ||
} |