Installation
You can install the package via composer:
composer require guava/filament-knowledge-base:"^2.0"
Next, install @tailwindcss/typography if you don't have it already, since we use prose to style the markdown output:
npm install -D @tailwindcss/typography
Then publish the package assets:
php artisan filament:assets
Setup
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 knowledge base panel service provider:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBasePlugin;
$panel->plugin(KnowledgeBasePlugin::make());
Similarly, add the KnowledgeBaseCompanionPlugin plugin to your regular panel service provider:
use Guava\FilamentKnowledgeBase\Plugins\KnowledgeBaseCompanionPlugin;
$panel->plugin(KnowledgeBaseCompanionPlugin::make()
->knowledgeBasePanelId('knowledge-base') // Put your knowledge base panel ID here
);
If you don't have one, please refer to the filament documentation on how to create a custom theme.
And lastly, add the following to your custom filament theme to correctly build the CSS and use the required tailwind plugins:
@plugin "@tailwindcss/typography";
@source '../../../../vendor/guava/filament-knowledge-base/src/**/*';
@source '../../../../vendor/guava/filament-knowledge-base/resources/views/**/*';
Creating documentation pages
By default, all your documentation files should live in the docs/<panel-id> directory in the root of your project. The structure is covered in detail on the markdown files page.
To create documentation pages, simply run the docs:make command and follow the instructions:
php artisan docs:make
This will create a basic empty documentation file. To edit it, simply open it in your favorite editor.
An example of a documentation page:
---
title: Introduction
---
# Introduction
This is my first documentation page
If you visit your regular filament panel, you should now see a button at the bottom of your sidebar that will lead you to your knowledge base panel with your first documentation page!