Implement ID-based routing and folder auto-generation from titles

Major features:
- Switch from slug-based to ID-based routing (/documents/123)
- Enable title editing with automatic slug/path regeneration
- Auto-generate folder structure from title slashes (e.g., Laravel/Livewire/Components)
- Persist sidebar folder open/close state using localStorage
- Remove slug unique constraint (ID routing makes it unnecessary)
- Implement recursive tree view with multi-level folder support

Architecture changes:
- DocumentService: Add generatePathAndSlug() for title-based path generation
- Routes: Change from {document:slug} to {document} for ID binding
- SidebarTree: Extract recursive rendering to partials/tree-item.blade.php
- Database: Remove unique constraint from documents.slug column

UI improvements:
- Display only last path component in sidebar (Components vs Laravel/Livewire/Components)
- Folder state persists across page navigation via localStorage
- Title field accepts slashes for folder organization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 09:41:38 +09:00
commit 6e7f8566ef
140 changed files with 40590 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
<div class="max-w-4xl mx-auto p-8">
<!-- Document Header -->
<div class="mb-8">
<div class="flex items-center justify-between mb-4">
<h1 class="text-4xl font-bold text-gray-900">
{{ $document->title }}
</h1>
@auth
<a
href="{{ route('documents.edit', $document) }}"
class="inline-flex items-center px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
</svg>
Edit
</a>
@endauth
</div>
<div class="flex items-center text-sm text-gray-500 space-x-4">
@if($document->created_by)
<span>
Created by {{ $document->creator->name }}
</span>
@endif
<span>
Updated {{ $document->updated_at->diffForHumans() }}
</span>
</div>
</div>
<!-- Document Content -->
<div class="prose prose-lg max-w-none mb-12">
{!! $renderedContent !!}
</div>
<!-- Backlinks Section -->
@if(count($backlinks) > 0)
<div class="border-t border-gray-200 pt-8">
<h2 class="text-xl font-semibold text-gray-900 mb-4">
Linked References
</h2>
<div class="space-y-3">
@foreach($backlinks as $backlink)
<a
href="{{ route('documents.show', $backlink) }}"
class="block p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition"
wire:navigate
>
<div class="flex items-center">
<svg class="w-4 h-4 mr-2 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
<span class="text-sm font-medium text-gray-900">
{{ $backlink->title }}
</span>
</div>
</a>
@endforeach
</div>
</div>
@endif
<!-- Document Metadata -->
<div class="mt-12 pt-8 border-t border-gray-200">
<div class="grid grid-cols-2 gap-4 text-sm text-gray-500">
<div>
<span class="font-medium">Path:</span>
<code class="ml-2 text-xs bg-gray-100 px-2 py-1 rounded">{{ $document->path }}</code>
</div>
<div>
<span class="font-medium">Last modified:</span>
<span class="ml-2">{{ $document->updated_at->format('Y-m-d H:i:s') }}</span>
</div>
</div>
</div>
</div>