Rewrite the news data loading (#23)

This commit is contained in:
Alessandro Jean 2023-09-08 02:49:15 -03:00 committed by GitHub
parent 1d1bf5fba9
commit 3e437da62d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,10 +10,9 @@ export interface News {
declare const data: News[];
export { data };
export default defineLoader({
async load(): Promise<News[]> {
const articles = await createContentLoader("news/*.md", { excerpt: true }).load();
export default createContentLoader("news/*.md", {
excerpt: true,
transform(articles) {
return articles
.filter(({ url }) => url !== "/news/")
.map(
@ -26,5 +25,5 @@ export default defineLoader({
}
)
.sort((a, b) => b.date.localeCompare(a.date));
},
}
});