Skip to content

Commit

Permalink
fix(@dpc-sdp/ripple-tide-landing-page): use siteID from TidePageApi
Browse files Browse the repository at this point in the history
  • Loading branch information
David Featherston committed Jul 13, 2023
1 parent 051234f commit 5433389
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/ripple-tide-api/src/services/tide-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class TidePageApi extends TideApiBase {
...data
})
} else if (typeof componentMapping === 'function') {
const data = componentMapping.apply(this, [cmpData, pageData])
const data = componentMapping.apply(this, [cmpData, pageData, this])
mappedComponents.push({
uuid: cmpData.uuid || cmpData.id,
...data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,6 @@ const searchResultsMappingFn = (item): any => {
}
}
const searchFilters = computed(() => {
if (!config.tide?.site) return props.filters
return [
...props.filters,
{ type: 'any', field: 'field_node_site', values: [config.tide.site] }
]
})
const searchDriverOptions = {
trackUrlState: false,
alwaysSearchOnInitialLoad: true,
Expand All @@ -129,7 +120,7 @@ const searchDriverOptions = {
sortList: props.sortBy
},
searchQuery: {
filters: searchFilters.value,
filters: props.filters,
result_fields: {
title: {
raw: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export interface ITideContentCollectionConfig {
}

const getContentCollectionFiltersFromConfig = (
config: ITideContentCollectionConfig
config: ITideContentCollectionConfig,
siteId?: string
): IContentCollectionFilter[] => {
const filters = []
if (config.internal?.contentTypes) {
Expand All @@ -69,6 +70,15 @@ const getContentCollectionFiltersFromConfig = (
)
filters.push(...contentFieldFilters)
}

if (siteId) {
filters.push({
type: 'any',
field: 'field_node_site',
values: [siteId]
})
}

return filters
}

Expand All @@ -91,7 +101,9 @@ const getContentCollectionSortBy = (config) => {
}

export const contentCollectionMapping = (
field
field,
pageData,
TidePageApi
): TideDynamicPageComponent<IContentCollection> => {
return {
component: 'TideLandingPageContentCollection',
Expand All @@ -104,7 +116,8 @@ export const contentCollectionMapping = (
'callToAction'
]),
filters: getContentCollectionFiltersFromConfig(
field.field_content_collection_config
field.field_content_collection_config,
TidePageApi?.site
),
sortBy: getContentCollectionSortBy(field.field_content_collection_config),
perPage: getField(
Expand Down

0 comments on commit 5433389

Please sign in to comment.