Knowledge base plugin
Introduction
The KnowledgeBasePlugin is one of the two plugins this package comes with and is the primary plugin you will use.
This plugin turns any panel you add it to into a knowledge base.
It is currently required to use a custom, separate panel for your knowledge base, as it will override the sidebar navigation.
Usage
If you don't have a separate panel yet for your knowledge base, please create one using the built in filament command:
php artisan make:filament-panel
For example, you might create a panel named knowledge-base.
Next, add the KnowledgeBasePlugin plugin to your panel service provider:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
$panel->plugin(KnowledgeBasePlugin::make());
Customization
There are a lot of customization options available for your knowledge base. All options are configured via the KnowledgeBasePlugin added to your knowledge base panel.
We currently support the following options:
Custom documentation path
By default, all documentation files live in the docs/<panel-id> directory in the root of your project.
If you want to change this path, you can do so when registering the plugin:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make(base_path('kb/my-knowledge-base'));
Table of contents
By default, a table of contents is generated for each documentation file and rendered as a sidebar on the right side of the page.
Changing the position of the table of contents
You can change the position of the table of contents using the tableOfContentsPosition option.
The available options are:
TableOfContentsPosition::StartTableOfContentsPosition::End(default)
use Guava\FilamentKnowledgeBase\Enums\TableOfContentsPosition;
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->tableOfContentsPosition(TableOfContentsPosition::Start);
Disabling the table of contents
If you don't want to use the table of contents, you can disable it using the disableTableOfContents option:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->disableTableOfContents();
Anchors
Anchors are automatically generated symbols in front of each heading in your documentation files. They act as links to specific sections of the documentation.
Customizing the anchor symbol
By default, we use the # symbol. You can customize the symbol using:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->anchorSymbol('¶');
Disabling anchors
If you don't want to use anchors, you can disable them using the disableAnchors option:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->disableAnchors();
Breadcrumbs
Each documentation page has a breadcrumb navigation at the top of the page. This is especially useful for nested documentation pages to navigate back to previous pages.
Disabling breadcrumbs
If you don't want the breadcrumb navigation, you can disable it if you wish:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->disableBreadcrumbs();
Back button
At the bottom of the knowledge base sidebar, a "Back" button is rendered to send the user back to your app, mirroring the "Knowledge base" button rendered by the KnowledgeBaseCompanionPlugin.
By default, it links to your default panel.
Customizing the URL
If your users should be sent back to a different panel (or any other URL), you can customize it using the backUrl option:
use Filament\Facades\Filament;
use Guava\FilamentKnowledgeBase\Facades\KnowledgeBase;
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->backUrl(fn () => KnowledgeBase::url(Filament::getPanel('app')));
Customizing the button
If you want to modify the button itself (label, icon, ...), you can do so using the modifyBackButtonUsing option:
use Filament\Navigation\NavigationItem;
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->modifyBackButtonUsing(fn (NavigationItem $item) => $item
->label('Back to app')
->icon('heroicon-o-arrow-left'));
Disabling the back button
If you don't want the back button, you can disable it using the disableBackButton option:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
KnowledgeBasePlugin::make()
->disableBackButton();
Guest access
Previously in version 1.x, guest access had to be enabled specifically via a plugin option.
In version 2.x and up, you have full control over your knowledge base panel and thus can enable guest access just like you would for any other panel.
Please visit the filament documentation to learn how to enable guest access.
Authorization
Similarly, authorization is handled just like any other panel. In your User model, you can implement the FilamentUser interface to control access to different knowledge base panels.
More information in the filament documentation.