Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
edgrosvenor committed Jul 29, 2024
1 parent d8f6c99 commit 22a83c6
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 33 deletions.
37 changes: 18 additions & 19 deletions src/Actions/AddNavigationToAllRenderedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,35 @@ public function __construct()
{
$this->content = collect();
}

public function __invoke(DocumentationSite $site, \Closure $next)
{
$navigation = collect(json_decode(file_get_contents($site->configuration['folio_path'].'/navigation.json'), true, 512, JSON_THROW_ON_ERROR));

$this->content->push('<x-slot name="navigation"><ul><li><a href="/'.$site->configuration['folio_uri'].'">' . $site->configuration['name'] . '</a></li>');
$this->content->push('<x-slot name="navigation"><ul><li><a href="/'.$site->configuration['folio_uri'].'">'.$site->configuration['name'].'</a></li>');

$navigation->where('parent', '')->each(function($item) use ($navigation) {
$navigation->where('parent', '')->each(function ($item) use ($navigation) {
$this->content->push('<li><a href="'.$item['uri'].'">'.$item['title'].'</a>');
$uri = explode('/', $item['uri']);
$parent = '/'.last($uri);
$navigation->where('parent', $parent)->each(function($child) {
$navigation->where('parent', $parent)->each(function ($child) {
$this->content->push('<li><a class="ml-4" href="'.$child['uri'].'">&raquo; '.$child['title'].'</a>');
});
});
/* $navigation->each(function($item) {
$parent = Str::uuid();
if ($item['parent'] === '') {
$uri = explode('/', $item['uri']);
array_pop($uri);
$parent = '/'.last($uri);
dump($parent);
}
if ($item['parent'] === $parent) {
$this->content->push('<li><a class="ml-4" href="'.$item['uri'].'">'.$item['title'].'</a>');
}
});*/


/* $navigation->each(function($item) {
$parent = Str::uuid();
if ($item['parent'] === '') {
$uri = explode('/', $item['uri']);
array_pop($uri);
$parent = '/'.last($uri);
dump($parent);
}
if ($item['parent'] === $parent) {
$this->content->push('<li><a class="ml-4" href="'.$item['uri'].'">'.$item['title'].'</a>');
}
});*/

$this->content->push('</ul></x-slot>');

Expand Down
3 changes: 2 additions & 1 deletion src/Actions/BuildNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __invoke(DocumentationSite $site, Closure $next)
$site->blade_files->each(fn ($page) => $page->lines->each(fn ($line) => $line->stripTag((string) $weight)));
});

File::put($site->configuration['folio_path'].'/navigation.json', $navigation->sortBy('weight')->filter(fn ($item) => $item['weight'] !== null)->toJson(JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
File::put($site->configuration['folio_path'].'/navigation.json', $navigation->sortBy('weight')->filter(fn ($item) => $item['weight'] !== null)->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

return $next($site);
}
Expand All @@ -36,6 +36,7 @@ public function getParent($page, $site)
{
$uri = explode('/', $page->uri);
array_pop($uri);

return ltrim('/', str_replace($site->configuration['folio_uri'], '', implode('/', $uri)));
}

Expand Down
1 change: 0 additions & 1 deletion src/Actions/EscapeBladeBreakingCharacters.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ protected function addLiteral($line)
$line->content = str_replace('@', '@@', $line->content);
$line->content = str_replace('{{', '@{{', $line->content);


return $line;

}
Expand Down
1 change: 1 addition & 0 deletions src/Actions/TranformInternalLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __invoke(DocumentationSite $site, Closure $next)
$page->lines = $page->lines->map(function ($line) {
$line->content = str_replace('index.md"', '"', $line->content);
$line->content = str_replace('.md"', '"', $line->content);

return $line;
});
});
Expand Down
14 changes: 14 additions & 0 deletions src/Commands/DiscoverCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DiscoverCommand extends Command

public function handle(): int
{

$directories = File::directories($this->argument('directory') ?? config('docsidian.md_path'));

foreach ($directories as $directory) {
Expand Down Expand Up @@ -44,6 +45,19 @@ public function handle(): int
$this->info("Created record for {$key}");
}



// Now clean up any deleted directories
foreach (DocsidianSite::get() as $site) {
if (is_dir($site->md_path)) {
continue;
}

$this->info("Deleted {$site->md_path}");

$site->delete();
}

return self::SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use ArtisanBuild\Docsidian\Actions\EnableLiveCode;
use ArtisanBuild\Docsidian\Actions\EnableMermaid;
use ArtisanBuild\Docsidian\Actions\EnsureAllHeadingsHaveAnId;
use ArtisanBuild\Docsidian\Actions\EscapeBladeBreakingCharacters;
use ArtisanBuild\Docsidian\Actions\GenerateOnPageNavigation;
use ArtisanBuild\Docsidian\Actions\HandleWikiStyleImages;
use ArtisanBuild\Docsidian\Actions\EscapeBladeBreakingCharacters;
use ArtisanBuild\Docsidian\Actions\RemoveEmptyParagraphs;
use ArtisanBuild\Docsidian\Actions\SetBlockVisibility;
use ArtisanBuild\Docsidian\Actions\SetPageVisibility;
Expand Down
4 changes: 1 addition & 3 deletions src/Contracts/HighlightsCodeBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace ArtisanBuild\Docsidian\Contracts;

interface HighlightsCodeBlocks
{
}
interface HighlightsCodeBlocks {}
4 changes: 1 addition & 3 deletions src/Contracts/IndexesSiteForSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace ArtisanBuild\Docsidian\Contracts;

interface IndexesSiteForSearch
{
}
interface IndexesSiteForSearch {}
4 changes: 1 addition & 3 deletions src/Docsidian.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace ArtisanBuild\Docsidian;

class Docsidian
{
}
class Docsidian {}
2 changes: 0 additions & 2 deletions src/Models/DocsidianCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace ArtisanBuild\Docsidian\Models;

use ArtisanBuild\Docsidian\SiteStatus;
use Eloquent;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

Expand Down

0 comments on commit 22a83c6

Please sign in to comment.