Skip to content

Commit

Permalink
fix: try fallback locale if locale not found
Browse files Browse the repository at this point in the history
fix: try fallback locale if locale not found
  • Loading branch information
lukas-frey authored Sep 26, 2024
2 parents 398e258 + 43fa722 commit d83cca4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Models/FlatfileDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function getLocale(): string
return App::getLocale();
}

public function getFallbackLocale(): string
{
return App::getFallbackLocale();
}

public function getRows()
{
$path = base_path(
Expand All @@ -37,6 +42,14 @@ public function getRows()
->append($this->getLocale())
);

if (! File::exists($path)) {
$path = base_path(
str(config('filament-knowledge-base.docs-path'))
->append('/')
->append($this->getFallbackLocale())
);
}

return collect(File::allFiles($path))
->map(function (\SplFileInfo $file) use ($path) {
$data = KnowledgeBase::parseMarkdown($file->getRealPath());
Expand Down

0 comments on commit d83cca4

Please sign in to comment.