--- import SearchModal from "../ui/SearchModal.astro"; type Navigation = Record< string, { title: string; url: string; order: number }[] >; const currentUrl = Astro.url.pathname; const isCurrentUrl = (url: string) => currentUrl === url; export function formatTitle(title: string): string { return title .split("-") .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) .join(" "); } export async function setup() { // setup navigation const getStartedFiles = await Astro.glob("../../pages/get-started/*"); const guideFiles = await Astro.glob("../../pages/guide/*"); const markdownFiles = [...getStartedFiles, ...guideFiles]; const navigation: Navigation = {}; for (const file of markdownFiles) { const filePath = file.url; const [_, category] = filePath!.split("/"); const formattedCategory = formatTitle(category); const formattedTitle = file.frontmatter.title; const order = file.frontmatter.order ?? 0; if (!navigation[formattedCategory]) { navigation[formattedCategory] = []; } navigation[formattedCategory].push({ title: formattedTitle, url: filePath || "", order, }); } // sort by "order" const sortedNavigation: Navigation = {}; Object.keys(navigation) .sort() .forEach((key) => { sortedNavigation[key] = navigation[key].sort( (a, b) => a.order - b.order ); }); return { navigation: sortedNavigation, }; } interface Props { showHome?: boolean | null; } // setup navigation const { navigation } = await setup(); // show Home link in vertical navbar only on mobile const { showHome } = Astro.props; ---