From 28fbd0f6c2a901d542583dcd6a263d7939a183ba Mon Sep 17 00:00:00 2001 From: r-freeman Date: Sat, 14 Jan 2023 22:42:49 +0000 Subject: [PATCH] Converted getAllArticles to TypeScript --- src/lib/{getAllArticles.js => getAllArticles.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/lib/{getAllArticles.js => getAllArticles.ts} (81%) diff --git a/src/lib/getAllArticles.js b/src/lib/getAllArticles.ts similarity index 81% rename from src/lib/getAllArticles.js rename to src/lib/getAllArticles.ts index 1790759..b525290 100644 --- a/src/lib/getAllArticles.js +++ b/src/lib/getAllArticles.ts @@ -1,7 +1,7 @@ import glob from 'fast-glob' import * as path from 'path' -async function importArticle(articleFilename) { +async function importArticle(articleFilename: string) { let {meta, default: component} = await import( `../pages/writing/${articleFilename}` ) @@ -19,5 +19,5 @@ export async function getAllArticles() { let articles = await Promise.all(articleFilenames.map(importArticle)) - return articles.sort((a, z) => new Date(z.date) - new Date(a.date)) + return articles.sort((a, z) => a.date < z.date ? 1 : -1) }