There are two primary reasons for following naming conventions in your Tina project:
naming convention | Purpose |
|---|---|
| Used for collections and code shared between collections |
| Used for template definitions used for block-based rendering |
The typical convention is to add the schema for a given React component to an accompanying file of the same name with the suffix schema.tsx. This ensures your index is only rebuilt when changes are made to your data model and not to the component.
src/āāā app/ā āāā components/ā ā āāā events-list.schema.tsxā ā āāā events-list.tsx
Code shared between multiple collections, including field definitions and lists of field definitions are also typically stored in files ending in .schema.tsx. In the Example below assume we are sharing the title field between the hero-image and image-text-block. Component.
src/āāā tina/ā āāā collections/ā ā āāā shared-fields/ā ā ā āāā title.schema.tsxāāā app/ā āāā components/ā ā āāā blocks/ā ā ā āāā hero-image.schema.tsxā ā ā āāā hero-image.tsxā ā ā āāā image-text-block.schema.tsxā ā ā āāā image-text-block.tsx
If you're re-using the template for a block component between multiple collections it's good practice to separate that template into a file ending in .template.tsx.
templatesare passed into existing collections using a block-based editing
In the example below, assume we are using the image-carousel block template in the our block renderer. The image-carousel template can be shared between the home and about collections.
src/āāā tina/ā āāā collections/ā ā āāā home.tsxā ā āāā about.tsxāāā app/ā āāā components/ā ā āāā blocks/ā ā ā āāā image-carousel.tsxā ā ā āāā image-carousel.template.tsxā ā ā āāā blocks-renderer.tsx