[site][xl]: move site folder to root
This commit is contained in:
26
site/lib/getAuthorsDetails.ts
Normal file
26
site/lib/getAuthorsDetails.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { siteConfig } from "config/siteConfig";
|
||||
import clientPromise from "lib/mddb";
|
||||
|
||||
export const getAuthorsDetails = async (authors: string[]) => {
|
||||
const mddb = await clientPromise;
|
||||
const allPeople = await mddb.getFiles({ folder: "people" });
|
||||
|
||||
// Temporary, flowershow UI component expects contentlayer obj props
|
||||
const allPeopleMetadata = allPeople.map((p) => p.metadata);
|
||||
|
||||
let blogAuthors = [];
|
||||
|
||||
if (authors) {
|
||||
blogAuthors = authors;
|
||||
} else if (siteConfig.defaultAuthor) {
|
||||
blogAuthors = [siteConfig.defaultAuthor];
|
||||
}
|
||||
|
||||
return blogAuthors.map((author) => {
|
||||
const person = allPeopleMetadata.find(
|
||||
({ id, name }) => id === author || name === author
|
||||
);
|
||||
|
||||
return person ?? { name: author, avatar: siteConfig.avatarPlaceholder };
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user