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:
40
src/routes/web.php
Normal file
40
src/routes/web.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Livewire\DocumentViewer;
|
||||
use App\Livewire\DocumentEditor;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
$homeDocument = Document::where('slug', 'home')->first();
|
||||
|
||||
if ($homeDocument) {
|
||||
return redirect()->route('documents.show', $homeDocument);
|
||||
}
|
||||
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Route::get('/dashboard', function () {
|
||||
return view('dashboard');
|
||||
})->middleware(['auth', 'verified'])->name('dashboard');
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
||||
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
|
||||
});
|
||||
|
||||
Route::prefix('documents')->name('documents.')->group(function () {
|
||||
// 認証が必要なルート(より具体的なルートを先に定義)
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/create', DocumentEditor::class)->name('create');
|
||||
Route::get('/{document}/edit', DocumentEditor::class)->name('edit');
|
||||
});
|
||||
|
||||
// 公開ルート(動的ルートは最後に)
|
||||
Route::get('/{document}', DocumentViewer::class)->name('show');
|
||||
});
|
||||
|
||||
require __DIR__.'/auth.php';
|
||||
Reference in New Issue
Block a user