hydephp / develop

The HydePHP Source Code Monorepo
https://hydephp.com
MIT License
12 stars 6 forks source link

Add a `php hyde publish:template` command? #1776

Open caendesilva opened 1 week ago

caendesilva commented 1 week ago

Something I often do is to do php hyde publish:homepage posts and then rename the created index.blade.php to posts.blade.php.

But what if we added a php hyde publish:template command? We could bundle a few templates that follow the default styles.

It supports a few modes, same as the publish:homepage command, where no arguments prompts for the listing, or the template key can be provided as an argument. By default the published file will be saved matching the template name, but an optional second argument can be provided to override this name.

Examples of templates we could include:

caendesilva commented 1 week ago

We'd also want to make sure these don't introduce any new Tailwind classes. They should be very minimal.

caendesilva commented 1 week ago

Simple authors listing (mirror: https://gist.github.com/caendesilva/983d8242a3edd8f1046638920523bc43)

@php($title = 'Authors')
@extends('hyde::layouts.app')
@section('content')

    <main id="content" class="mx-auto max-w-7xl py-12 px-8">
        <header class="lg:mb-12 xl:mb-16">
            <h1 class="text-3xl text-left leading-10 tracking-tight font-extrabold sm:leading-none mb-8 md:mb-12 md:text-4xl md:text-center lg:text-5xl text-gray-700 dark:text-gray-200">
                Authors
            </h1>
        </header>

        <div id="authors" class="max-w-3xl mx-auto prose dark:prose-invert">
            <dl>
                @foreach(\Hyde\Framework\Features\Blogging\Models\PostAuthor::all() as $author)
                    <dt>Username</dt>
                    <dd>{{ $author->username }}</dd>

                    <dt>Name</dt>
                    <dd>{{ $author->name }}</dd>

                    <dt>Website</dt>
                    <dd><a href="{{ $author->website }}">{{ $author->website }}</a></dd>
                @endforeach
            </dl>
        </div>
    </main>

@endsection

Slightly styled version

@php($title = 'Authors')
@extends('hyde::layouts.app')
@section('content')

    <main id="content" class="mx-auto max-w-7xl py-12 px-8">
        <header class="lg:mb-12 xl:mb-16">
            <h1 class="text-3xl text-left leading-10 tracking-tight font-extrabold sm:leading-none mb-4 md:mb-8 md:text-center lg:text-5xl text-gray-700 dark:text-gray-200">
                Site Authors
            </h1>
            <p class="text-xl md:text-2xl text-left md:text-center text-gray-600 dark:text-gray-400">Meet the talented writers behind our content.</p>
        </header>

        <div id="authors" class="max-w-3xl mx-auto prose dark:prose-invert">
            @foreach(Hyde::authors() as $author)
                <div class="author-card">
                    <h2 class="flex flex-row items-center">
                        @if($author->avatar)
                            <img src="{{ Hyde::asset($author->avatar) }}" alt="{{ $author->name }}" class="mr-2 my-0 inline rounded-full" width="32px" height="32px">
                        @endif
                        {{ $author->name }}
                    </h2>
                    <blockquote>
                        <p>{{ $author->bio }}</p>
                    </blockquote>
                </div>
            @endforeach
        </div>
    </main>

@endsection
caendesilva commented 1 week ago

Could be fun to have a template repository where people can submit templates that get vetted, and a command can download them from GitHub. Templates using vendors also prompt a third party warning confirmation before downloading. Either the latest tag can be used (default) or a specific version hash (tied to number of times the file was updated)

Example repository tree (hydephp/template-repository)

templates/
  vendor-one/
    template-name.blade.php
    another-template.blade.php

Can then use php hyde download:template vendor-one/template-name (with version tags like in Composer)

Templates could be added through a web interface too, but backed by GitHub for public version control.