statamic / ideas

šŸ’”Discussions on ideas and feature requests for Statamic
https://statamic.dev
31 stars 1 forks source link

Starter kits 2: let starter kits hook into stubs for resource scaffolding #576

Closed robdekort closed 2 years ago

robdekort commented 3 years ago

I talked about this one with @jesseleite last week. With the upcoming updates for Starter Kits (SK) it would be nice if a SK developer could add stubs that should be used when a site developer scaffolds resources for a collection.

I'm talking about these resources:

Screenshot 2021-06-11 at 09 38 44

Currently the show and index templates that are generated are just empty files. In SK's however you probably have some default wrapper styling in both templates. In the index template you might have a commented out collection tag ready to be used. And for the show template you might want to use your SK's page builder code.

To clarify in Peak you'd ideally want something like this for the index template:

{{#
    @name Index: your collection
    @desc The index template for your collection with an outer wrapper grid as defined in tailwind.config.js. It makes sure all blocks on a page get evenly spaced without having to worry about margins or paddings. Page builder content can be placed above the collection index.
#}}

<main class="outer-grid">
    {{ page_builder scope="block" }}
        {{ partial src="page_builder/{type}" }}
    {{ /page_builder }}

    {{#
        <div class="fluid-container flex flex-col space-y-4">
            {{ collection:your_collection limit="10" paginate="true" as="items" }}
                {{ items }}
                    {{ partial:typography/h1 as="h2" class="mb-4" :content="title" }}
                    {{ partial:typography/paragraph content="{excerpt | nl2br}"}}
                {{ /items}}

                {{ partial:components/pagination }}
            {{ /collection:your_collection }}
        </div>
    #}}
</main>

Or this for the show template:

{{#
    @name Show: your collection
    @desc The show template for your collection with an outer wrapper grid as defined in tailwind.config.js. It makes sure all blocks on a page get evenly spaced without having to worry about margins or paddings.
#}}

<main class="outer-grid">    
    {{ page_builder scope="block" }}
        {{ partial src="page_builder/{type}" }}
    {{ /page_builder }}
</main>

Providing these stubs would increase development speed and make "best practices" (at least for the current SK) more discoverable.

Hope this makes sense.

robdekort commented 2 years ago

I recently added some CLI commands to generate this all. If anyone needs this for their kit, check out the commands in Peak for reference.