diff --git a/website/src/layouts/ArticleLayout.astro b/website/src/layouts/ArticleLayout.astro index cb073bcf..9eb2dc48 100644 --- a/website/src/layouts/ArticleLayout.astro +++ b/website/src/layouts/ArticleLayout.astro @@ -54,7 +54,11 @@ const currentSlug = Astro.url.pathname.replace(/\/$/, '').split('/').pop();
{description}
} {tags && tags.length > 0 && ( diff --git a/website/src/pages/learning-hub/index.astro b/website/src/pages/learning-hub/index.astro index 3a10ed19..b350c4a1 100644 --- a/website/src/pages/learning-hub/index.astro +++ b/website/src/pages/learning-hub/index.astro @@ -6,23 +6,24 @@ import { fundamentalsOrder, referenceOrder } from '../../config/learning-hub'; const base = import.meta.env.BASE_URL; const articles = await getCollection('learning-hub'); -const fundamentalsOrderIndex = {}; -fundamentalsOrder.forEach((id, index) => { - fundamentalsOrderIndex[id] = index; -}); +const createOrderIndexMap = (order) => { + const map = new Map(); + order.forEach((id, index) => { + map.set(id, index); + }); + return map; +}; -const referenceOrderIndex = {}; -referenceOrder.forEach((id, index) => { - referenceOrderIndex[id] = index; -}); +const fundamentalsOrderIndex = createOrderIndexMap(fundamentalsOrder); +const referenceOrderIndex = createOrderIndexMap(referenceOrder); const fundamentals = articles .filter((a) => fundamentalsOrder.includes(a.id)) - .sort((a, b) => fundamentalsOrderIndex[a.id] - fundamentalsOrderIndex[b.id]); + .sort((a, b) => fundamentalsOrderIndex.get(a.id) - fundamentalsOrderIndex.get(b.id)); const reference = articles .filter((a) => referenceOrder.includes(a.id)) - .sort((a, b) => referenceOrderIndex[a.id] - referenceOrderIndex[b.id]); + .sort((a, b) => referenceOrderIndex.get(a.id) - referenceOrderIndex.get(b.id)); ---