@imi-shared/apester-composer
v1.0.1-beta.0
Published
initial Apester composer component
Downloads
4
Readme
Apester Composer Element
How do I use it? This component is intended to be used to setup pages within PB Admin that can be used for custom power-up settings in Composer. To create the needed pages to power the embed, create a wrapper component in your Fusion repo which only imports and returns this package component - ApesterComposerPowerUpIframe. Each setting for iFrame URL should contain the page url, along with a hash #EDIT, #VIEW or #SEARCH. The component will extract these along with the query parameters that composer appends, and serve up the required edit/search/view ui so editors can add a Apester element to an article. No other props are referenced or needed.
Usage
Each setting for iFrame URL should contain the page url, along with a hash #EDIT, #VIEW or #SEARCH For example, if the URI for your page is apester-composer
, the 3 Apester urls will be:
- http://localhost/pf/apester-composer/?_website={arcSite}#SEARCH
- http://localhost/pf/apester-composer/?_website={arcSite}#VIEW
- http://localhost/pf/apester-composer/?_website={arcSite}#EDIT
The component will extract the hash key, along with the query parameters that composer appends. It will then serve up the required edit/search/view user interface, in order for editors to add a Apester element to an article.
To test these, you can use this power=up testing tool.
ARC Code Splitting
This components are intended for use with Composer and are not intended to be used on a page consumed by an end reader. Thus, to improve performance, it is recommended that code splitting be leveraged to include this package only when needed. There are two ways to achieve this: Dynamic Loading and Splitting Components across Fusion Output Type Bundles.
Dynamic Loading
Code splitting via dynamic loading is well documented in React's Code-Splitting documentation found here: https://reactjs.org/docs/code-splitting.html
Using React's Suspense and lazy functions, will automatically load the bundle containing the dynamic import when this component is first rendered. In this way, the package will not be included in the mono-bundle but rather dynamically loaded only when it is needed - when the wrapper component is rendered.
Fusion Output Type Bundle
It is also possible to leverage the fusion feature of creating a separate bundle for each output type to achieve code splitting. To achieve code splitting this way, 2 wrapper components would beed to be created in the component feature directory. The default output type bundle would not include this package so one file should be created called 'default.jsx' which would return only null - no component and no package. One other wrapper component would be created but instead of creating that component in a file called 'default.jsx', it would be created in a file with the name of the alternate output type (perhaps 'composer-powerup.jsx'). Another output type file would need to be declared in the component output-type directory which corresponds to the output-type name ('composer-powerup.jsx' in this example). Pages visited under the default output type would get the default.jsx version of this component in the default bundle - null. Pages visited under the component-powerup output type would get hte component-powerup version of this component - the wrapper component returning the ApesterComposerPowerUpIframe. Thus, the composer-powerup output type can be used for composer settings, to serve up ApesterComposerPowerUpIframe but elsewhere when the default output type is used, such as homepages or article pages, null is returned - not the package or its imports.