mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-06-26 14:42:02 +05:30
24 lines
476 B
TypeScript
24 lines
476 B
TypeScript
import type { PageServerLoad } from "./$types";
|
|
import db from "$lib/db";
|
|
|
|
export const load: PageServerLoad = async ({ params }) => {
|
|
const Posts = db.model("Posts");
|
|
|
|
const data = await Posts.findAll({
|
|
attributes: ["author"]
|
|
})
|
|
|
|
if (data.length === 0 || data[0] === undefined) {
|
|
return {
|
|
authors: []
|
|
}
|
|
} else {
|
|
const authors = data.map((post) => post["author"]);
|
|
const uniqueAuthors = [...new Set(authors)];
|
|
|
|
return {
|
|
authors: uniqueAuthors
|
|
}
|
|
}
|
|
};
|