Skip to content

Commit

Permalink
Feat/conscia package sort (#36)
Browse files Browse the repository at this point in the history
* attempting conscia component sort

* component sort

* undoing conscia install changes

* updating image domain note
  • Loading branch information
maria0r authored Mar 25, 2024
1 parent 24e35af commit 020e5f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/conscia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,18 @@ In order to use data from Conscia, the `cmsRouter` needs to use the `getPage` da
import { getPage } from '@composable/conscia'
```
:::note
Don't forget to update the `composable-ui/next.config.js` file with the image domains that you will be receiving. Please refer to the Next.JS documentation on `remotePatterns` [here](https://nextjs.org/docs/app/api-reference/components/image#remotepatterns). For example,
```json
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**.contentstack.io',
port: '',
},
],
}
```
:::
6 changes: 6 additions & 0 deletions packages/conscia/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export type ConsciaHeroBanner = {
description: string
url: string
}
sort_order?: number
}

export type ConsciaCTABanner = {
__typename: BannerFullProps['__typename']
sort_order?: number
containerMarginBottom?: number
containerMarginTop?: number
containerSize: BannerFullProps['containerSize']
Expand All @@ -67,6 +69,7 @@ export type ConsciaCTABanner = {

export type ConsciaFeatureCardsHeader = {
__typename: BannerTextOnlyProps['__typename']
sort_order?: number
centered: BannerTextOnlyProps['centered']
id: BannerTextOnlyProps['id']
content: BannerTextOnlyProps['content']
Expand All @@ -77,6 +80,7 @@ export type ConsciaFeatureCardsHeader = {

export interface ConsciaFeaturedProducts {
__typename: CommerceConnectorProps['__typename']
sort_order?: number
id: CommerceConnectorProps['id']
title: CommerceConnectorProps['title']
containerMarginBottom?: number
Expand All @@ -91,6 +95,7 @@ export interface ConsciaFeaturedProducts {

export type ConsciaGrid = {
__typename: GridProps['__typename']
sort_order?: number
id: GridProps['id']
columns: GridProps['columns']
containerMarginBottom?: number
Expand All @@ -102,6 +107,7 @@ export type ConsciaGrid = {

export type ConsciaTextCard = {
__typename: TextCardProps['__typename']
sort_order?: number
id: TextCardProps['id']
title: TextCardProps['title']
image: {
Expand Down
6 changes: 5 additions & 1 deletion packages/conscia/src/utils/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export const transformPage = ({
return {
__typename: 'pageSlug',
id: pageSlug,
items: Object.values(consciaPage.components).map(transformPageComponent),
items: Object.values(consciaPage.components)
.sort((a, b) => {
return (a.response.sort_order ?? 0) - (b.response.sort_order ?? 0)
})
.map(transformPageComponent),
metaDescription: '',
metaKeywords: [],
metaTitle: '',
Expand Down

1 comment on commit 020e5f5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 46%
45.08% (436/967) 19.08% (54/283) 19.58% (38/194)

Please sign in to comment.