feat: add contacts from cms
This commit is contained in:
@@ -5,15 +5,24 @@ import { getCollection, type CollectionEntry } from 'astro:content'
|
||||
import { Header } from '../sections/Header'
|
||||
import { Footer } from '../sections/Footer'
|
||||
import { CategoryView } from '../views/CategoryView'
|
||||
import type { SiteConfigContact } from '../lib/cms/contact/types'
|
||||
import { siteConfigQueryQuery } from '../graphql-documents/site-config.gql.generated'
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const categories = await getCollection('categories')
|
||||
const siteResult = await siteConfigQueryQuery.execute()
|
||||
if (siteResult.errors?.length) {
|
||||
throw new Error(siteResult.errors.map(e => e.message).join(', '))
|
||||
}
|
||||
const contacts = siteResult.data?.siteConfig?.contacts?.filter(c => c != null) ?? []
|
||||
|
||||
return categories.map((entry: CollectionEntry<'categories'>) => ({
|
||||
params: { slug: entry.id },
|
||||
props: {
|
||||
title: entry.data.title,
|
||||
description: entry.data.description,
|
||||
vendors: entry.data.vendors,
|
||||
contacts,
|
||||
},
|
||||
}))
|
||||
}
|
||||
@@ -26,15 +35,16 @@ interface Props {
|
||||
description: string
|
||||
products?: string[]
|
||||
}[]
|
||||
contacts: SiteConfigContact[]
|
||||
}
|
||||
|
||||
const { title, description, vendors } = Astro.props as Props
|
||||
const { title, description, vendors, contacts } = Astro.props as Props
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<div class="min-h-screen bg-white w-full overflow-x-hidden">
|
||||
<Header client:load />
|
||||
<Header client:load contacts={contacts} />
|
||||
<CategoryView client:load title={title} description={description} vendors={vendors} />
|
||||
<Footer client:load />
|
||||
<Footer client:load contacts={contacts} />
|
||||
</div>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user