Skip to content

Commit 99a7ef8

Browse files
aaronpowellCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d73c0bb commit 99a7ef8

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

website/src/layouts/ArticleLayout.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ const currentSlug = Astro.url.pathname.replace(/\/$/, '').split('/').pop();
5454
<h1>{title}</h1>
5555
{description && <p>{description}</p>}
5656
<div class="article-meta">
57-
{estimatedReadingTime && <span class="meta-item">📖 {estimatedReadingTime}</span>}
57+
{estimatedReadingTime && (
58+
<span class="meta-item">
59+
<span aria-hidden="true">📖</span> {estimatedReadingTime}
60+
</span>
61+
)}
5862
{lastUpdated && <span class="meta-item">Updated: {lastUpdated}</span>}
5963
</div>
6064
{tags && tags.length > 0 && (

website/src/pages/learning-hub/index.astro

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@ import { fundamentalsOrder, referenceOrder } from '../../config/learning-hub';
66
const base = import.meta.env.BASE_URL;
77
const articles = await getCollection('learning-hub');
88
9-
const fundamentalsOrderIndex = {};
10-
fundamentalsOrder.forEach((id, index) => {
11-
fundamentalsOrderIndex[id] = index;
12-
});
9+
const createOrderIndexMap = (order) => {
10+
const map = new Map();
11+
order.forEach((id, index) => {
12+
map.set(id, index);
13+
});
14+
return map;
15+
};
1316
14-
const referenceOrderIndex = {};
15-
referenceOrder.forEach((id, index) => {
16-
referenceOrderIndex[id] = index;
17-
});
17+
const fundamentalsOrderIndex = createOrderIndexMap(fundamentalsOrder);
18+
const referenceOrderIndex = createOrderIndexMap(referenceOrder);
1819
1920
const fundamentals = articles
2021
.filter((a) => fundamentalsOrder.includes(a.id))
21-
.sort((a, b) => fundamentalsOrderIndex[a.id] - fundamentalsOrderIndex[b.id]);
22+
.sort((a, b) => fundamentalsOrderIndex.get(a.id) - fundamentalsOrderIndex.get(b.id));
2223
2324
const reference = articles
2425
.filter((a) => referenceOrder.includes(a.id))
25-
.sort((a, b) => referenceOrderIndex[a.id] - referenceOrderIndex[b.id]);
26+
.sort((a, b) => referenceOrderIndex.get(a.id) - referenceOrderIndex.get(b.id));
2627
---
2728

2829
<BaseLayout title="Learning Hub" description="Curated articles and walkthroughs to help you unlock everything you can do with GitHub Copilot" activeNav="learning-hub">

0 commit comments

Comments
 (0)