GuavaCZ / filament-knowledge-base

MIT License
94 stars 9 forks source link

[Request]: The knowledge base panel needs to be registered with a custom vite theme. #25

Open dmb-220 opened 4 weeks ago

dmb-220 commented 4 weeks ago

What feature would you like to add?

The knowledge base panel needs to be registered with a custom vite theme. new install laraavel new versio 11.10 new filament 3.2.85 press documentation button get error

Notes

No response

dmb-220 commented 4 weeks ago

http://new.test/kb/\prologue\getting-started get Not Found

The requested URL was not found on this server.

cooljet84 commented 3 weeks ago

You should configure the custom theme in you AppServiceProvider (app/Providers/AppServiceProvider.php) not in your Panel ServiceProvider

use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;

KnowledgeBasePanel::configureUsing(
    fn(KnowledgeBasePanel $panel) => $panel
        ->viteTheme('resources/css/filament/admin/theme.css') // your filament vite theme path here
);
damms005 commented 3 weeks ago

@dmb-220 I can almost bet that you are registering this in your boot() method like every other Filament setup plugin. The docs, unusual of most filament plugins, instructs that it should be registered in the register method.

I have a good number of filament plugins in my app, and this is the first and only plugin that registerd in register method of service provider. @cooljet84 any ideas why this design decision please?

eelco2k commented 1 week ago

@cooljet84 i've got the same problem. i've added the configureUsing() function to my AppServiceProvider.php

but i still get the error that i need to use custom theme.

 KnowledgeBasePanel::configureUsing(function (KnowledgeBasePanel $panel) {
            return
                $panel
                    ->brandName('Knowledge base')
                    ->guestAccess(true)
                    ->disableBackToDefaultPanelButton()
                    // ->syntaxHighlighting() // Needs nodeJs on server
                    ->viteTheme('resources/css/filament/portal/theme.css')
                    ->middleware([
                        'requestlog',
                    ]);
            }

i'm using the same custom viteTheme as in my Portal filament admin panel.

I've also run the npm run build and double checked the manual as stated here: https://filamentphp.com/docs/3.x/panels/themes#creating-a-custom-theme

if i just hardcode $this->viteTheme('resources/css/filament/portal/theme.css'); at the KnowledgeBasePanel.php in ```php function getTheme(): Theme { $this->viteTheme('resources/css/filament/portal/theme.css');



  everything works...
eelco2k commented 1 week ago

Also when i set breakpoints with XDebug.

 KnowledgeBasePanel::configureUsing(function (KnowledgeBasePanel $panel) {
            $test = $panel ; // added breakpoint here.... 

the debugger does not execute the function in ::configureUsing... so it looks like it's not correctly registered... as ComponentManager::resolve() should resolve the plugin...???