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