Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hydeflip? HydePHP 馃 Kickflip (Experimenting with using Kickflip together with HydePHP) #160

Closed
caendesilva opened this issue May 16, 2022 · 2 comments

Comments

@caendesilva
Copy link
Member

Creating this thread to discuss compatibility between HydePHP and Kickflip created by @mallardduck (https://github.com/KickflipCli/kickflip-src / https://kickflip.lucidinternets.com/)

@caendesilva
Copy link
Member Author

caendesilva commented May 16, 2022

Experimenting with porting a Kickflip project to Hyde. I'm using the dev-master branch that will become the 0.25.x release as it allows the changing of source directories.

Setup

Rough process of what I did as follows:

Create new project,

composer create-project hyde/hyde hydeflip -s dev

Then create a Kickflip project,

composer create-project mallardduck/kickflip example-site

Then I copied the example-site source directory to the hydeflip root.

Now we need to configure Hyde to auto-discover the files. I did this in a service provider.

// app\Providers\HydeflipServiceProvider.php

<?php

namespace App\Providers;

use Hyde\Framework\HydeServiceProvider;
use Hyde\Framework\Models\BladePage;
use Hyde\Framework\Models\MarkdownPage;
use Hyde\Framework\Models\MarkdownPost;
use Hyde\Framework\Models\DocumentationPage;

class HydeflipServiceProvider extends HydeServiceProvider
{
    public function register()
    {
        $this->registerDefaultDirectories([
            BladePage::class => 'source',
            MarkdownPage::class => 'source',
            MarkdownPost::class => 'source/_posts',
            DocumentationPage::class => 'source/docs',
        ]);

	$this->discoverBladeViewsIn('source'); // Adds the source directory to the view config
    }
}

Register the service provider after the Hyde one

// config/app.php

'providers' => [
	App\Providers\AppServiceProvider::class,
	Hyde\Framework\HydeServiceProvider::class,
	App\Providers\HydeflipServiceProvider::class, // Add the service provider
],

Next, I only needed to make a few changes to the Hydeflip 404 page since we use the Hyde layout, and the Hyde::relativeLink helper since Hyde does not have access to the $site variable.

// source\404.blade.php

@extends('hyde::layouts.app')

@section('content')
<div class="flex flex-col items-center mt-32 text-gray-700">
    <h1 class="text-6xl font-light leading-none mb-2">404</h1>

    <h2 class="text-3xl">Page not found</h2>

    <hr class="block w-full max-w-lg mx-auto my-8 border">

    <p class="text-xl">
        Let's get you back on track, head to the <a href="{{ Hyde::relativeLink('index.html', $currentPage) }}">Home Page</a>
    </p>
</div>
@endsection

Result

So, how does it work? Pretty great!

Hyde automatically registers the Kickflip index.md and even uses the page front matter for the title.

image

Notes

A few notes

To get the Tailwind to register you need to add the source directories to your Tailwind config.
image

Once done, the 404 page is nicely styled
image

I have not yet implemented the changing of media files, so assets/build is not yet discovered. There is also a ticket open to support changing the output directory, and is tracked in hydephp/framework#362

Blog posts work too, but they do not show up in the navigation menu automatically. This is a bug.

image

@hydephp
Copy link
Collaborator

hydephp commented May 29, 2022

Resolving issue. Feel free to reopen!

@hydephp hydephp closed this as completed May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant