From 0637cad186bed816f4989e6e0c0639dc2f2556c2 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 26 Feb 2026 14:59:50 +1100 Subject: [PATCH] refactor: extract Learning Hub article ordering into shared config Move duplicated fundamentalsOrder and referenceOrder arrays from index.astro and ArticleLayout.astro into a shared config file at src/config/learning-hub.ts. Both consumers now import from the single source of truth. Addresses PR review comment about maintenance burden of keeping two copies in sync. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- website/src/config/learning-hub.ts | 20 ++++++++++++++++++++ website/src/layouts/ArticleLayout.astro | 19 +------------------ website/src/pages/learning-hub/index.astro | 19 +------------------ 3 files changed, 22 insertions(+), 36 deletions(-) create mode 100644 website/src/config/learning-hub.ts diff --git a/website/src/config/learning-hub.ts b/website/src/config/learning-hub.ts new file mode 100644 index 00000000..0fbe9dc2 --- /dev/null +++ b/website/src/config/learning-hub.ts @@ -0,0 +1,20 @@ +// Shared article ordering for the Learning Hub. +// Used by both the index page and the article sidebar layout. + +export const fundamentalsOrder = [ + 'what-are-agents-skills-instructions', + 'understanding-copilot-context', + 'copilot-configuration-basics', + 'defining-custom-instructions', + 'creating-effective-skills', + 'building-custom-agents', + 'understanding-mcp-servers', + 'automating-with-hooks', + 'using-copilot-coding-agent', + 'installing-and-using-plugins', + 'before-after-customization-examples', +]; + +export const referenceOrder = [ + 'github-copilot-terminology-glossary', +]; diff --git a/website/src/layouts/ArticleLayout.astro b/website/src/layouts/ArticleLayout.astro index 62663874..76867646 100644 --- a/website/src/layouts/ArticleLayout.astro +++ b/website/src/layouts/ArticleLayout.astro @@ -1,6 +1,7 @@ --- import BaseLayout from './BaseLayout.astro'; import { getCollection } from 'astro:content'; +import { fundamentalsOrder, referenceOrder } from '../config/learning-hub'; interface Props { title: string; @@ -15,24 +16,6 @@ const base = import.meta.env.BASE_URL; const articles = await getCollection('learning-hub'); -const fundamentalsOrder = [ - 'what-are-agents-skills-instructions', - 'understanding-copilot-context', - 'copilot-configuration-basics', - 'defining-custom-instructions', - 'creating-effective-skills', - 'building-custom-agents', - 'understanding-mcp-servers', - 'automating-with-hooks', - 'using-copilot-coding-agent', - 'installing-and-using-plugins', - 'before-after-customization-examples', -]; - -const referenceOrder = [ - 'github-copilot-terminology-glossary', -]; - const fundamentals = articles .filter((a) => fundamentalsOrder.includes(a.id)) .sort((a, b) => fundamentalsOrder.indexOf(a.id) - fundamentalsOrder.indexOf(b.id)); diff --git a/website/src/pages/learning-hub/index.astro b/website/src/pages/learning-hub/index.astro index 99b34e7f..f3e278a8 100644 --- a/website/src/pages/learning-hub/index.astro +++ b/website/src/pages/learning-hub/index.astro @@ -1,28 +1,11 @@ --- import BaseLayout from '../../layouts/BaseLayout.astro'; import { getCollection } from 'astro:content'; +import { fundamentalsOrder, referenceOrder } from '../../config/learning-hub'; const base = import.meta.env.BASE_URL; const articles = await getCollection('learning-hub'); -const fundamentalsOrder = [ - 'what-are-agents-skills-instructions', - 'understanding-copilot-context', - 'copilot-configuration-basics', - 'defining-custom-instructions', - 'creating-effective-skills', - 'building-custom-agents', - 'understanding-mcp-servers', - 'automating-with-hooks', - 'using-copilot-coding-agent', - 'installing-and-using-plugins', - 'before-after-customization-examples', -]; - -const referenceOrder = [ - 'github-copilot-terminology-glossary', -]; - const fundamentals = articles .filter((a) => fundamentalsOrder.includes(a.id)) .sort((a, b) => fundamentalsOrder.indexOf(a.id) - fundamentalsOrder.indexOf(b.id));