jongacnik/kirby2-spad

setup example

Closed this issue · 2 comments

hi!

(total noob with node.js over here)

sorry to be the only issue opened so far, asking for help... i've been trying to setup kirby + spad together with choo.js, for the frontend, and i'm having some problems at the basic understanding of how things move between the two environments:

  • kirby spad outputs a json object (all good)
  • choo needs to read / import this object somehow, but how do you do that?

once bankai starts, it outputs and index.html on its own, or if you set a custom one, it still lives elsewhere far away than where you set <script>var data = <?= $site->spad() ?></script>.

my question would be if you could point to an existing setup or to give some suggestions on how to hook the kirby json output with choo.

thank!
af

yo! thanks for the note. Only have time right now for a really brief rundown but maybe this will help?

Generally there's a couple ways to go about it, if you want to use bankai, you'll need 2 servers running. The bankai server, and then the server running kirby. Then from w/in your choo app you can fetch the data from kirby to populate state using xhr or fetch or w/e you like to use with the route that spad exposes: https://github.com/jongacnik/spad#route

The other way to go about it is to not use bankai and use browserify/watchify to compile your choo app directly into your kirby site (ouput the bundle.js into assets/js of your kirby site). Then you could inline your data like <script>var data = <?= $site->spad() ?></script> into kirby's default.php template. Since the data and the choo app live in the same place in this case, yoru choo app could just look for the data variable and use that for state.

thank you for your answer, very helpful explanation for both options.