kalamuna / kalastatic

:electric_plug: Facilitate the front-end experience through Styleguides and Prototypes
https://kalamuna.github.io/kalastatic/
41 stars 14 forks source link

Include twig components with JSON datasource #523

Closed timwasson closed 6 years ago

timwasson commented 6 years ago

I have a component set up with several menu items currently in JSON format. This works fine on the component itself, but when I include the component as part of a prototype page, the JSON data is not included. I can bypass this using 'with', but the menu is quite long and I don't want to duplicate all the various links.

Is there a way around this problem?

soniktrooth commented 6 years ago

@timwasson You can reference a JSON file from other JSON files. We often do this in the global navigation.json to avoid repeating large chunks of data:

{
  "primary": "@kalastatic/components/molecules/nav--primary/nav--primary.html.json",
  "secondary": "@kalastatic/components/molecules/nav--secondary/nav--secondary.html.json",
  "footer": "@kalastatic/components/molecules/nav--footer/nav--footer.html.json"
}

Any variable declared in this file should be available to reference from any file.

timwasson commented 6 years ago

This is exactly what I needed. Closing this issue. Thank you for your time.