ChristopherBiscardi/toast

[idea] how could a clear "only do this at build time" API work?

Closed this issue · 3 comments

it would be great if there was a clear way to specify which work in the app should only happen during build time. this could be something like Next's getStaticProps, or something entirely different

11ty does an interesting thing where you basically execute arbitrary Node and dump the output into its data layer, which is flexible to the point of being potentially very confusing, but might be worth exploring as a true "pre-processing" step instead of mixing into the React logic directly?

going galaxy brain for a second, I feel like there are a couple opportunities in this API design:

  1. a clear way to feed static data into React apps. we could sidestep this entirely by generating JSON files instead of worrying about a custom data layer, or we could auto-insert a data prop into components (or something different; I'd love to hear how this is handled in other frameworks, languages, etc. to see if there are some existing patterns that are really intuitive)

  2. a clear way to register custom data into the static data layer. Gatsby's GraphQL approach is cool because it has a clear API, but it's A Lot™ to get ramped up on, so that's probably more than we need. 11ty and Next let you write whatever code you want and just fire that back into your pages, which is extremely flexible but not super approachable for someone who doesn't have a lot of JavaScript experience. I feel like finding the goldlocks zone of "structured enough to be teachable/predictable" and "flexible enough that I can just add data" is where the magic lies, but I also think that this could be its own project that emerges after seeing how people are adding and using this data in the wild for a while

I'm kinda braindumping here in hopes of getting smarter people than me thinking about this, because I know what I want the outcome to be, but I don't have strong opinions on how it's actually done 😅

I'm in full support of everything said here. Not sure I have any concrete suggestions but will do some thinking. I particularly like making this an independent project (or eventually).

This only talks about data fetching/processing. Is there anything else people use this functionality for?

Right now we're interfacing with JSON files. Each page has a JSON file that you can do whatever to associated with it, that JSON file is used as the props.

I'm interested in this and would appreciate any research any passing-by issue looking-at people are interested in providing. This isn't top priority which is good because we're just in the research phase anyway.