CloudCannon / bookshop

📚 A component development workflow for static websites.
MIT License
249 stars 21 forks source link

Functionality to embed component schemas inside other component schemas #55

Closed bglw closed 2 years ago

bglw commented 3 years ago

A current hiccup in many workflows is when one component uses another. This is solved from the template side, as a hero component can use {% bookshop button bind=button %} in its template. This is not solved from the TOML side yet, and thus the following needs to be written:

# button.bookshop.toml
[props]
link = "/"
text = "Click"

# hero.bookshop.toml
[props]
title = "Hello World"
[props.button]
link = "/"
text = "Click"

This is an undesirable duplication of schema and will cause components to lose parity in a way that can't be caught automatically. Ideally we would write something like the following:

# button.bookshop.toml
[props]
link = "/"
text = "Click"

# hero.bookshop.toml
[props]
title = "Hello World"
button = "{button}" # <-- something that embeds the button component here 

This would necessitate a change in architecture where the plugin that builds structures (cloudcannon-structures) has access to all TOML files, rather than processing them in isolation like it does currently.

bglw commented 2 years ago

Implemented!