You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example ^ there are 4 components: hero, grid, quote, slider. The challenge is dynamically loading the svelte component that corresponds to these using a simple text match since it will require having a component class instance.
In example, we're using the components key in the content source JSON. Ideally there will be a way to do this without having a required key.
The text was updated successfully, but these errors were encountered:
However, the internal gopack does not support dynamic imports so you currently have to go into public/spa/content/pages.js after building and convert the .svelte extension in the loadComponent() function to be .js manually.
Currently Gopack actually checks that static import paths exist in the filesystem, this will be challenging to implement with dynamic imports since they can use variables that we'd have to get the value of. For now the easiest thing to do would be a simple string replace of .svelte to .js when they match regex import(); with single or double quotes inside the brackets and a sub-pattern of .svelte. This won't account for paths defined outside the import like in the example above and doesn't guarantee that the converted path won't throw an error. Down the road it would be nice to make this better.
It would also be nice to move the loadComponent() function into the /layout/scripts/ folder of the starter since this is something a lot of folks might be interested in using.
Users should have the flexibility to load components based on the keys in their content structure (JSON).
Example JSON structure
In the example ^ there are 4 components:
hero
,grid
,quote
,slider
. The challenge is dynamically loading the svelte component that corresponds to these using a simple text match since it will require having a component class instance.In example, we're using the
components
key in the content source JSON. Ideally there will be a way to do this without having a required key.The text was updated successfully, but these errors were encountered: