--- import type { Docs } from '@/types'; import { siteConfig } from '@/config'; import { generateDocumentationSEO } from '@/utils/seo'; import { isValidDate } from '@/utils/markdown'; import { optimizeContentImagePath, getOptimizedFormat } from '@/utils/images'; import { hasDocCategories } from '@/utils/categories'; import { getCollection } from 'astro:content'; import BaseLayout from '@/layouts/BaseLayout.astro'; import TableOfContents from '@/components/TableOfContents.astro'; import Lightbox from '@/components/Lightbox.astro'; import ImageWrapper from '@/components/ImageWrapper.astro'; import DocsSidebar from '@/components/DocsSidebar.astro'; import Icon from '@/components/Icon.astro'; import { shouldShowContent, getAdjacentDocs, formatDate } from '@/utils/markdown'; export interface Props { documentation: Docs; } const { documentation } = Astro.props; // Check if there are any real categories in the system const allDocs = await getCollection('docs'); const docsHaveCategories = hasDocCategories(allDocs); // Filter visible docs (exclude drafts in production) const isDev = import.meta.env.DEV; const visibleDocs = allDocs.filter(doc => shouldShowContent(doc, isDev)); // Get current category (normalize "General" to null) const currentCategory = documentation.data.category && documentation.data.category.trim() !== '' && documentation.data.category !== 'General' ? documentation.data.category : null; // Render the documentation content const { render } = await import('astro:content'); const { Content, headings } = await render(documentation); // Generate SEO data const siteUrl = import.meta.env.SITE || siteConfig.site; const docUrl = `${siteUrl.replace(/\/+$/, '')}/docs/${documentation.id}`; const seoData = generateDocumentationSEO(documentation, docUrl); // Generate table of contents from headings using configurable depth const maxDepth = siteConfig.tableOfContents.depth; const toc = headings.filter(h => h.depth >= 2 && h.depth <= maxDepth); // Check if TOC should be shown - global setting, then hideTOC frontmatter, then showTOC frontmatter (default true for docs) const hideTOC = documentation.data.hideTOC === true; const showTOC = documentation.data.showTOC !== undefined ? documentation.data.showTOC : true; const shouldShowTOC = siteConfig.tableOfContents.enabled && !hideTOC && showTOC && toc.length > 0; // Get adjacent docs for navigation (only within same category, sorted by order) const { prev: prevDoc, next: nextDoc } = getAdjacentDocs(visibleDocs, documentation.id, currentCategory); // Generate structured data const structuredData = { '@context': 'https://schema.org', '@type': 'TechArticle', name: documentation.data.title, description: documentation.data.description, url: Astro.url.href, isPartOf: { '@type': 'WebSite', name: siteConfig.title, url: siteConfig.site }, author: { '@type': 'Person', name: siteConfig.author }, dateCreated: documentation.data.lastModified?.toISOString() || new Date().toISOString(), dateModified: documentation.data.lastModified?.toISOString() || new Date().toISOString(), version: documentation.data.version || '1.0', articleSection: docsHaveCategories ? (documentation.data.category && documentation.data.category.trim() !== '' && documentation.data.category !== 'General' ? documentation.data.category : 'Unsorted') : undefined }; ---