Programming

Prezet

#Installation

Installation of Prezet was pretty straight forward and was a breeze. Kudos to the team and contributors for make such a seamless install process.

#Customization

I noticed that the sidebar was composed of a separate SUMMARY.md. A Laracast series which introduced me to Prezet deleted this item entirely. My first instinct was to make this section valuable. 💡 So I turned it into a category sorter. According to the documentation we can utilize Document model to access data stored with the SQLite Database.

Let's modify the main entry point App\Http\Controllers\Prezet\IndexController. We won't need the $nav variable anymore. We will add $categories in place of it.

1<?php
2 
3namespace App\Http\Controllers\Prezet;
4 
5class IndexController
6{
7 public function __invoke(Request $request): View
8 {
9 ...
10 //$nav = Prezet::getSummary();
11 ...
12 $categories = Document::all()->groupBy('category')->keys()->toArray();
13 
14 return view('prezet.index', [
15 //'nav' => $nav,
16 ...
17 'categories' => $categories,
18 ...
19 ]);
20 }
21}

In addition, we need to remove $nav and add $categories to App\resources\views\prezet\index.blade.php

1<x-slot name="left">
2 <x-prezet.sidebar :categories="$categories" />
3</x-slot>

And we need to remove $nav and add $categories from App\resources\views\components\prezet\sidebar.blade.php

1<x-slot name="left">
2 <x-prezet.nav :categories="$categories"/>
3</x-slot>

Finally we can make the changes to App\resources\views\components\prezet\nav.blade.php.

1<nav class="text-base lg:text-sm">
2 <ul role="list" class="space-y-9">
3 <li>
4 <p class="font-display font-medium text-gray-900">
5 🏯 Categories
6 </p>
7 <ul
8 role="list"
9 class="mt-2 space-y-2 border-l-2 border-gray-100 lg:mt-4 lg:space-y-4 lg:border-gray-200"
10 >
11 
12 <li class="relative">
13 <a
14 @class([
15 'before:-trangray-y-1/2 block w-full pl-3.5 before:pointer-events-none before:absolute before:top-1/3 before:-left-1 before:h-1.5 before:w-1.5 before:rounded-full',
16 'text-primary-500 before:bg-primary-500 font-semibold' =>
17 url()->full() === route('prezet.index'),
18 'text-gray-500 before:hidden before:bg-gray-300 hover:text-gray-600 hover:before:block' =>
19 url()->full() !== route('prezet.index'),
20 ])
21 href="{{ route('prezet.index') }}"
22 >
23 All
24 </a>
25 </li>
26 @foreach ($categories as $category)
27 <li class="relative">
28 <a
29 @class([
30 'before:-trangray-y-1/2 block w-full pl-3.5 before:pointer-events-none before:absolute before:top-1/3 before:-left-1 before:h-1.5 before:w-1.5 before:rounded-full',
31 'text-primary-500 before:bg-primary-500 font-semibold' =>
32 url()->full() === route('prezet.index', ['category' => $category]),
33 'text-gray-500 before:hidden before:bg-gray-300 hover:text-gray-600 hover:before:block' =>
34 url()->full() !== route('prezet.index', ['category' => $category]),
35 ])
36 href="{{ route('prezet.index', ['category' => $category]) }}"
37 >
38 {{ $category }}
39 </a>
40 </li>
41 @endforeach
42 </ul>
43 </li>
44 </ul>
45</nav>