--- import { getCollection, getEntry, render } from 'astro:content'; import { siteConfig } from '@/config'; import { generatePostsListSEO } from '@/utils/seo'; import { shouldShowContent } from '@/utils/markdown'; import { hasDocCategories, getDocCategories, groupDocsByCategory } from '@/utils/categories'; import BaseLayout from '@/layouts/BaseLayout.astro'; import PageLayout from '@/layouts/PageLayout.astro'; import DocumentationCard from '@/components/DocumentationCard.astro'; import TableOfContents from '@/components/TableOfContents.astro'; import Icon from '@/components/Icon.astro'; // Check if docs are enabled and handle fallback let fallbackPage = null; if (!siteConfig.optionalContentTypes.docs) { // Check for fallback page in pages collection try { fallbackPage = await getEntry('pages', 'docs'); if (fallbackPage) { // PageLayout will handle the rendering } else { return Astro.redirect('/404'); } } catch (error) { // No fallback page found, redirect to 404 return Astro.redirect('/404'); } } // Get all docs const allDocs = await getCollection('docs'); const isDev = import.meta.env.DEV; // Filter documentation const visibleDocs = allDocs.filter(doc => shouldShowContent(doc, isDev)); // Get docs page content from special collection let docsPageContent = null; let docsPageHideTOC = false; let DocsPageContent = null; try { docsPageContent = await getEntry('special', 'docs'); if (docsPageContent) { const { Content } = await render(docsPageContent); DocsPageContent = Content; docsPageHideTOC = docsPageContent.data.hideTOC === true; } } catch (error) { // Fallback to default if docs.md doesn't exist } // Check if any docs have categories const docsHaveCategories = hasDocCategories(visibleDocs); // Group docs by category or list them without categories let docsByCategory: Record; let sortedCategories: string[]; let tocHeadings: any[]; let shouldShowTOC: boolean; // Always group docs by category (creates "Unsorted" for docs without categories) docsByCategory = groupDocsByCategory(visibleDocs); sortedCategories = Object.keys(docsByCategory).sort(); if (docsHaveCategories) { // Generate TOC headings from categories tocHeadings = sortedCategories.map(category => ({ depth: 2, slug: `category-${category.toLowerCase().replace(/\s+/g, '-')}`, text: category })); } else { // No real categories - just list docs by order without TOC headings tocHeadings = []; } // Show TOC if not hidden and there are headings to show shouldShowTOC = !docsPageHideTOC && tocHeadings.length > 0; // Generate SEO data const seoData = generatePostsListSEO(import.meta.env.SITE || '', undefined); seoData.title = docsPageContent?.data.title ? `${docsPageContent.data.title} | ${siteConfig.title}` : `Documentation | ${siteConfig.title}`; seoData.description = docsPageContent?.data.description || `Browse all documentation on ${siteConfig.title}`; seoData.noIndex = (docsPageContent?.data as any)?.noIndex || false; --- {fallbackPage ? ( ) : (

{docsPageContent?.data.title || 'Documentation'}

{DocsPageContent ? (
) : (

Guides, tutorials, and reference materials

)}
{sortedCategories.length > 0 ? (
{sortedCategories.map(category => { const categoryId = `category-${category.toLowerCase().replace(/\s+/g, '-')}`; const contentId = `${categoryId}-content`; const toggleId = `${categoryId}-toggle`; const chevronId = `${categoryId}-chevron`; return (
{docsHaveCategories && ( )}
{docsByCategory[category].map((doc, index) => ( ))}
)})}
) : (

No documentation yet

Check back soon for guides and tutorials!

)} {shouldShowTOC && ( )}
)}