Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

1.8 KB
Raw Blame
---
import { getCollection } from 'astro:content'

import { FeaturedSection } from '../components/FeaturedSection'
import { GuideBrowser } from '../components/GuideBrowser'
import { HomeHero } from '../components/Hero'
import Layout from '../layouts/Layout.astro'
import { padFeatured, toSummary, toTroubleshootingSummary, type FeaturedItem } from '../lib/guides'
import { getListedTopics, topicToSlug } from '../lib/topics'

const guides = await getCollection('guides')
const summaries = guides.map(toSummary)
const troubleshooting = (await getCollection('troubleshooting')).map(toTroubleshootingSummary)
const listedTopics = getListedTopics({ guides: summaries, troubleshooting })
const pinnedTopics = listedTopics.filter((topic) => topic.pinned)
const featuredTopics: FeaturedItem[] = (pinnedTopics.length > 0 ? pinnedTopics : listedTopics.slice(0, 3)).map(
	(topic) => ({
		id: `topic-${topicToSlug(topic.name)}`,
		slot: `topic-${topicToSlug(topic.name)}`,
		title: topic.name,
		description: topic.description,
		topics: [topic.name],
		href: `${import.meta.env.BASE_URL}/topics/${topicToSlug(topic.name)}`,
	})
)
const featuredGuides = padFeatured({
	featured: guides.filter((guide) => guide.data.pinned).map(toSummary),
	fallback: summaries,
})
---

<Layout description="In-depth guides, tutorials, troubleshooting, and explainers for best practices for Supabase">
	<HomeHero client:load />
	<div class="flex flex-col gap-20 pb-24 pt-16 sm:gap-24 sm:pt-20">
		<FeaturedSection client:load title="Featured topics" items={featuredTopics} />
		<FeaturedSection client:load title="Featured guides" items={featuredGuides} />
		{
			troubleshooting.length > 0 ? (
				<GuideBrowser client:load title="Troubleshooting" guides={troubleshooting} param="troubleshooting" />
			) : null
		}
		<GuideBrowser client:load title="All guides" guides={summaries} />
	</div>
</Layout>