diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000..aa9f667 --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,184 @@ +--- +import { getCollection } from 'astro:content'; +import '~/styles/anhh-tokens.css'; +import '@fontsource-variable/inter'; + +interface Product { + slug: string; + title: string; + blurb: string; + href: string; + count: number; +} + +// Hardcoded product metadata. Adding a new product = adding to this map. +const PRODUCT_META: Record = { + whp: { + title: 'WHP', + blurb: 'Our hosting control panel. Add domains, create sites, manage email, set up backups.', + firstSection: 'getting-started/welcome', + }, + wordpress: { + title: 'WordPress', + blurb: 'Tips and tricks for getting the most out of WordPress on WHP.', + firstSection: 'index', + }, + 'email-clients': { + title: 'Email clients', + blurb: 'Configure Outlook, Apple Mail, Thunderbird, and mobile clients.', + firstSection: 'index', + }, +}; + +const docs = await getCollection('docs'); + +// Group articles by top-level product folder +const byProduct = new Map(); +for (const entry of docs) { + const product = entry.id.split('/')[0]; + byProduct.set(product, (byProduct.get(product) ?? 0) + 1); +} + +const visibleProducts: Product[] = Array.from(byProduct.entries()) + .filter(([slug]) => PRODUCT_META[slug] !== undefined) + .filter(([, count]) => count > 0) + .map(([slug, count]) => ({ + slug, + title: PRODUCT_META[slug].title, + blurb: PRODUCT_META[slug].blurb, + href: `/${slug}/${PRODUCT_META[slug].firstSection}/`, + count, + })) + .sort((a, b) => a.title.localeCompare(b.title)); +--- + + + + + + An Honest Host Knowledge Base + + + + + + +
An Honest Host · Knowledge Base
+
+

Knowledge Base

+

Pick a product to get started.

+ + { + visibleProducts.length === 0 ? ( +
No documentation has been published yet.
+ ) : ( + + ) + } +
+ + +