Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lisi Linhart
committed
May 11, 2021
1 parent
8a6542e
commit cf90b8c
Showing
2 changed files
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import SbEditable from 'storyblok-react' | ||
import Teaser from './Teaser' | ||
import React from "react" | ||
|
||
const Components = { | ||
'teaser': Teaser, | ||
} | ||
|
||
const DynamicComponent = ({ blok }) => { | ||
if (typeof Components[blok.component] !== 'undefined') { | ||
const Component = Components[blok.component] | ||
return (<SbEditable content={blok}><Component blok={blok} /></SbEditable>) | ||
} | ||
return (<p>The component <strong>{blok.component}</strong> has not been created yet.</p>) | ||
} | ||
|
||
export default DynamicComponent |
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,14 @@ | ||
import * as React from "react" | ||
|
||
const Teaser = ({ blok }) => ( | ||
<div> | ||
<h2> | ||
{ blok.headline } | ||
</h2> | ||
<p> | ||
{ blok.intro } | ||
</p> | ||
</div> | ||
) | ||
|
||
export default Teaser |