--- 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 // Define the order of categories let categoryOrder = ["Get Started", "Guide", "Tutorials"]; const getStartedFiles = await Astro.glob("../../pages/get-started/*"); const guideFiles = await Astro.glob("../../pages/guide/*"); const tutorialFiles = await Astro.glob("../../pages/tutorials/*"); let markdownFiles = [...getStartedFiles, ...guideFiles, ...tutorialFiles]; let navigation: Navigation = {}; for (const file of markdownFiles) { let filePath = file.url; let [_, category] = filePath!.split("/"); let formattedCategory = formatTitle(category).toLowerCase(); let formattedTitle = file.frontmatter.title; let order = file.frontmatter.order ?? 0; if (!navigation[formattedCategory]) { navigation[formattedCategory] = []; } navigation[formattedCategory].push({ title: formattedTitle, url: filePath || "", order, }); } // Create a new navigation object with the desired order let orderedNavigation: Navigation = {}; for (let category of categoryOrder) { if (navigation[category.toLowerCase()]) { orderedNavigation[category] = navigation[ category.toLowerCase() ].sort((a, b) => a.order - b.order); } } return { navigation: orderedNavigation, }; } interface Props { showHome?: boolean | null; } // setup navigation const { navigation } = await setup(); // show Home link in vertical navbar only on mobile const { showHome } = Astro.props; ---