static.js 766 B

123456789101112131415161718192021
  1. import { appStatic } from 'app/lib/app-static'
  2. import { BlockWrapper } from 'app/components/block-wrapper'
  3. /**
  4. * `static` element: a UNA block content item of type `static` with `data.element: '<name>'`
  5. * renders the frontend static component `components_<name>` in the regular block wrapper.
  6. * UNA decides where it goes on the page; the content lives in the static registry (see
  7. * appStatic in lib/app-static.tsx).
  8. */
  9. export default function ElementStatic({ data, blockWrapperProps }) {
  10. const element = data?.element
  11. if (!element) return null
  12. return (
  13. <BlockWrapper {...blockWrapperProps}>
  14. {appStatic('components_' + element)}
  15. </BlockWrapper>
  16. )
  17. }
  18. ElementStatic.checkEmpty = (item) => Boolean(item?.data?.element)