Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/Http/Controllers/DocsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function __invoke(Documentation $docs, ?string $page = null)
return redirect()->route('docs', [self::DEFAULT_PAGE]);
}

$isMarkdown = str($page)->endsWith('.md');
$page = str($page)->replace('.md', '')->toString();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't love that this mutates the original parameter but it seemed like a better call than refactoring all the existing usages of it given i couldn't run the tests locally


if (! $docs->exists(config('site.defaultVersion'), $page) || in_array($page, self::EXCLUDED)) {
abort(404);
}
Expand All @@ -37,6 +40,10 @@ public function __invoke(Documentation $docs, ?string $page = null)
$markdown = $document['markdown'];
$body = $document['html'];

if ($isMarkdown) {
return response($markdown, 200, ['Content-Type' => 'text/plain']);
}

return view('docs', compact('body', 'matter', 'markdown', 'page', 'index'));
}
}
1 change: 0 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
Route::get('/docs/editor-setup', IDEPluginsController::class)->name('ide-plugins');
Route::get('/docs/{page?}', DocsController::class)->name('docs')->where('page', '.*');
});

4 changes: 4 additions & 0 deletions tests/Browser/SmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@

$response->assertNoSmoke();
});

it('serves pages in markdown format', function () {
visit('/docs/installation.md')->assertNoSmoke();
});