Skip to content

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

1.4 KB
Raw Blame
---
import { getCollection, render } from 'astro:content'
import { Admonition } from 'ui-patterns/Admonition'

import ArticleLayout from '../../layouts/ArticleLayout.astro'
import { breadcrumbListSchema, canonicalUrl, KB_BASE_URL, techArticleSchema } from '../../lib/json-ld'
import { getGithubUrlsBySlug } from '../../lib/troubleshooting-db'

export async function getStaticPaths() {
	const troubleshooting = await getCollection('troubleshooting')

	// github_url lives in the DB, not the fetched frontmatter — looked up here
	// (build time; kb is fully static, no SSR) rather than baked into the
	// fetched files.
	const githubUrlBySlug = await getGithubUrlsBySlug(troubleshooting.map((entry) => entry.id))

	return troubleshooting.map((entry) => ({
		params: { slug: entry.id },
		props: { entry, githubUrl: githubUrlBySlug.get(entry.id) },
	}))
}

const { entry, githubUrl } = Astro.props
const { title, description, topics } = entry.data
const { Content } = await render(entry)

const url = canonicalUrl(Astro.url.pathname)
const jsonLd = [
	techArticleSchema({ url, headline: title, description }),
	breadcrumbListSchema([
		{ name: 'Knowledge Base', url: KB_BASE_URL },
		{ name: title, url },
	]),
]
---

<ArticleLayout title={title} description={description} topics={topics} github_url={githubUrl} jsonLd={jsonLd}>
	<Content components={{ Admonition }} />
</ArticleLayout>