seo fixes
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ApiDocsController extends Controller
|
||||
{
|
||||
public function show(): View
|
||||
{
|
||||
$markdown = str_replace('{{BASE_URL}}', config('app.url'), $this->markdown());
|
||||
|
||||
return view('api-docs', [
|
||||
'bodyHtml' => Str::markdown($markdown, [
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]),
|
||||
'title' => 'API Documentation — '.config('app.name'),
|
||||
'description' => 'REST API reference for creating posts, categories, tags, and AI tool listings on '.config('app.name').'.',
|
||||
'canonical' => route('api.docs'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function llmsTxt(): Response
|
||||
{
|
||||
$baseUrl = config('app.url');
|
||||
|
||||
$text = <<<TXT
|
||||
# {$this->appName()}
|
||||
|
||||
> {$this->appName()} is a blog and AI tools directory with a public JSON REST API for programmatic publishing.
|
||||
|
||||
This site welcomes AI agents that have been given valid credentials by the site operator. See the API documentation for authentication and endpoint details.
|
||||
|
||||
## Docs
|
||||
|
||||
- [API documentation]({$baseUrl}/api-docs): full REST API reference (auth, posts, categories, tags, tools)
|
||||
- [Sitemap]({$baseUrl}/sitemap.xml)
|
||||
- [RSS feed]({$baseUrl}/blog/feed.xml)
|
||||
TXT;
|
||||
|
||||
return response($text, 200)->header('Content-Type', 'text/plain; charset=UTF-8');
|
||||
}
|
||||
|
||||
private function markdown(): string
|
||||
{
|
||||
return file_get_contents(resource_path('docs/api.md'));
|
||||
}
|
||||
|
||||
private function appName(): string
|
||||
{
|
||||
return config('app.name');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user