-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1315 from dpc-sdp/feat/sd-198-reusable-paragraphs
[SD-198] Reusable paragraphs
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
packages/ripple-tide-landing-page/mapping/components/from-library/from-library-mapping.ts
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,33 @@ | ||
import { TideDynamicPageComponent } from '@dpc-sdp/ripple-tide-api/types' | ||
import componentMappings from '../../components' | ||
import { reusableParagraphTypes } from '../../../types' | ||
|
||
interface TideFromLibrary { | ||
id: string | null | ||
type: string | ||
} | ||
|
||
export const fromLibraryMapping = ( | ||
field: { field_reusable_paragraph: { paragraphs: TideFromLibrary } }, | ||
page: any, | ||
tidePageApi: any | ||
): TideDynamicPageComponent<TideFromLibrary> => { | ||
const paragraph = field?.field_reusable_paragraph?.paragraphs | ||
if (paragraph && reusableParagraphTypes.includes(paragraph.type)) { | ||
return componentMappings[paragraph.type].mapping( | ||
paragraph, | ||
page, | ||
tidePageApi | ||
) | ||
} | ||
|
||
console.error(`No mapping found for paragraphs library item ${field?.id}`) | ||
} | ||
|
||
export const fromLibraryIncludes = [] | ||
|
||
export default { | ||
includes: fromLibraryIncludes, | ||
mapping: fromLibraryMapping, | ||
contentTypes: ['landing_page'] | ||
} |
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