-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup all sections and proper CMS default config
- Loading branch information
Showing
11 changed files
with
221 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,83 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import type { CmsConfigExtend } from '@@sf/content'; | ||
import { cmsFields as heroFields } from '~/sections/Hero.astro'; | ||
import { cmsFields as bannersGridFields } from '~/sections/BannersGrid.astro'; | ||
import { cmsFields as bannersGridFields } from '~/sections/BannersGridSection.astro'; | ||
import { cmsFields as pageTitleFields } from '~/sections/PageTitleSection.astro'; | ||
import { cmsFields as productShelfFields } from '~/sections/ProductShelfSection.astro'; | ||
import { cmsFields as searchShowcaseFields } from '~/sections/SearchShowcaseSection.astro'; | ||
import { cmsFields as contentEntryFields } from '~/sections/ContentEntrySection.astro'; | ||
import { cmsFields as customHtmlFields } from '~/sections/CustomHtmlSection.astro'; | ||
import { cmsFields as productDetailsFields } from '~/sections/ProductDetailsSection.astro'; | ||
|
||
export async function GET() { | ||
return new Response(JSON.stringify({ | ||
fields: { | ||
hero: heroFields, | ||
const cmsConfig: CmsConfigExtend = { | ||
components: { | ||
hero: { | ||
label: 'Hero slider', | ||
fields: heroFields, | ||
}, | ||
sections: { | ||
'banners-grid': bannersGridFields, | ||
'banners-grid': { | ||
label: 'Grade de banners', | ||
fields: bannersGridFields, | ||
}, | ||
'page-title': { | ||
label: 'Título da página (SEO)', | ||
fields: pageTitleFields, | ||
}, | ||
'product-shelf': { | ||
label: 'Estante de produtos', | ||
fields: productShelfFields, | ||
}, | ||
'search-showcase': { | ||
label: 'Vitrine de produtos e busca', | ||
fields: searchShowcaseFields, | ||
}, | ||
/* | ||
'c:foo': { | ||
label: 'Bar', | ||
}, | ||
'c:foo-with-fields': { | ||
label: 'Bar with fields', | ||
fields: fooBarFields, | ||
}, | ||
*/ | ||
'content-entry': { | ||
label: 'Bloco de conteúdo', | ||
fields: contentEntryFields, | ||
}, | ||
'custom-html': { | ||
label: 'HTML customizado', | ||
fields: customHtmlFields, | ||
}, | ||
breadcrumbs: { | ||
label: 'Breadcrumbs', | ||
}, | ||
'product-details': { | ||
label: 'Detalhes do produto', | ||
fields: productDetailsFields, | ||
}, | ||
'related-products': { | ||
label: 'Produtos relacionados', | ||
}, | ||
'context-showcase': { | ||
label: 'Vitrine da página', | ||
fields: searchShowcaseFields, | ||
}, | ||
'doc-banners': { | ||
label: 'Banners da categoria/marca', | ||
}, | ||
'doc-description': { | ||
label: 'Descrição da categoria/marca', | ||
}, | ||
}, | ||
}, | ||
})); | ||
settingsMetafields: { | ||
}, | ||
headerCustom: { | ||
}, | ||
footerCustom: { | ||
}, | ||
}; | ||
return new Response(JSON.stringify(cmsConfig)); | ||
} |
19 changes: 5 additions & 14 deletions
19
functions/ssr/src/sections/BannersGrid.astro → ...ssr/src/sections/BannersGridSection.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
import type { CmsFields, InferCmsOutput } from '@@sf/content'; | ||
import ContentEntry from '~/components/ContentEntry.vue'; | ||
export const cmsFields = ({ | ||
/* Keeping the fields optional because the data may come | ||
from the current CMS collection entry. */ | ||
title: { | ||
widget: 'text', | ||
label: 'Título', | ||
}, | ||
markdown: { | ||
widget: 'markdown', | ||
label: 'Conteúdo', | ||
}, | ||
}) as const satisfies CmsFields; | ||
export type Props = InferCmsOutput<typeof cmsFields>; | ||
const { | ||
title = '', | ||
markdown = '', | ||
} = Astro.props; | ||
--- | ||
|
||
<ContentEntry {title} {markdown} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import type { CmsFields, InferCmsOutput } from '@@sf/content'; | ||
import ContentClearfix from '@@sf/components/ContentClearfix.vue'; | ||
export const cmsFields = ({ | ||
html: { | ||
required: true, | ||
widget: 'code', | ||
label: 'HTML customizado', | ||
}, | ||
}) as const satisfies CmsFields; | ||
export type Props = InferCmsOutput<typeof cmsFields>; | ||
--- | ||
|
||
<ContentClearfix html={Astro.props.html} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
import type { CmsFields, InferCmsOutput } from '@@sf/content'; | ||
import PageTitle from '~/components/PageTitle.vue'; | ||
export const cmsFields = ({ | ||
title: { | ||
widget: 'string', | ||
label: 'Título', | ||
}, | ||
description: { | ||
widget: 'text', | ||
label: 'Descrição', | ||
}, | ||
}) as const satisfies CmsFields; | ||
export type Props = InferCmsOutput<typeof cmsFields>; | ||
--- | ||
|
||
<PageTitle {...Astro.props} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
import type { CmsFields, InferCmsOutput } from '@@sf/content'; | ||
import ProductDetails from '~/components/ProductDetails.vue'; | ||
import DocDescription from '~/components/DocDescription.vue'; | ||
import ProductSpecifications from '~/components/ProductSpecifications.vue'; | ||
export const cmsFields = ({ | ||
hasDescription: { | ||
widget: 'boolean', | ||
label: { pt: 'Mostrar descrição', en: 'Show description' }, | ||
}, | ||
hasSpecifications: { | ||
widget: 'boolean', | ||
label: { pt: 'Listar especificações', en: 'List specifications' }, | ||
}, | ||
}) as const satisfies CmsFields; | ||
export type Props = InferCmsOutput<typeof cmsFields>; | ||
const { hasDescription, hasSpecifications } = Astro.props; | ||
const { routeContext: { apiContext } } = Astro.locals; | ||
const product = apiContext.resource === 'products' && apiContext.doc; | ||
--- | ||
|
||
{product && <> | ||
<ProductDetails {product} client:sf="load"> | ||
<Fragment slot="description"> | ||
{hasDescription && <DocDescription apiDoc={product} />} | ||
{hasSpecifications && <ProductSpecifications {product} />} | ||
</Fragment> | ||
</ProductDetails> | ||
</>} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
import type { InferCmsOutput } from '@@sf/content'; | ||
import { productShelfCmsFields } from '@@sf/composables/use-product-shelf'; | ||
import ProductShelf from '~/components/ProductShelf.vue'; | ||
export const cmsFields = productShelfCmsFields; | ||
export type Props = InferCmsOutput<typeof cmsFields> & { | ||
isRelatedProducts?: boolean; | ||
}; | ||
--- | ||
|
||
<ProductShelf {...Astro.props} client:sf="lazy,interaction" />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
import type { InferCmsOutput } from '@@sf/content'; | ||
import { searchShowcaseCmsFields } from '@@sf/composables/use-search-showcase'; | ||
import SearchShowcase from '~/components/SearchShowcase.vue'; | ||
export const cmsFields = searchShowcaseCmsFields; | ||
export type Props = InferCmsOutput<typeof cmsFields>; | ||
--- | ||
|
||
<article class="min-h-[500px]"> | ||
<SearchShowcase {...Astro.props} client:sf="load" /> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters