File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ class Kernel extends HttpKernel
3838 \App \Http \Middleware \VerifyCsrfToken::class,
3939 \Illuminate \Routing \Middleware \SubstituteBindings::class,
4040 \App \Http \Middleware \RedirectRequest::class,
41+ \App \Http \Middleware \AddLlmsTxtHeader::class,
4142 ],
4243
4344 'api ' => [
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Http \Middleware ;
4+
5+ use Closure ;
6+ use Illuminate \Http \Request ;
7+ use Symfony \Component \HttpFoundation \Response ;
8+
9+ class AddLlmsTxtHeader
10+ {
11+ public function handle (Request $ request , Closure $ next ): Response
12+ {
13+ $ response = $ next ($ request );
14+
15+ $ baseUrl = 'https://pestphp.com ' ;
16+
17+ $ response ->headers ->set ('X-Llms-Txt ' , "{$ baseUrl }/llms.txt " );
18+
19+ if (preg_match ('#^docs/([^/]+)$# ' , $ request ->path (), $ matches )) {
20+ $ page = $ matches [1 ];
21+ $ response ->headers ->set ('Link ' , "< {$ baseUrl }/docs/ {$ page }/llms.txt>; rel= \"alternate \"; type= \"text/plain \"" , false );
22+ } else {
23+ $ response ->headers ->set ('Link ' , "< {$ baseUrl }/llms.txt>; rel= \"llms-txt \"; type= \"text/plain \"" , false );
24+ }
25+
26+ return $ response ;
27+ }
28+ }
Original file line number Diff line number Diff line change 11User-agent: *
22Disallow:
3+
4+ # LLM-friendly documentation
5+ llms-txt : https://pestphp.com/llms.txt
Original file line number Diff line number Diff line change 2020 < meta property ="og:description " content ="Pest is a testing framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP. ">
2121 < meta property ="og:url " content ="https://pestphp.com ">
2222 < meta property ="og:image " content ="https://pestphp.com/assets/img/og-v4.jpg ">
23+ < meta name ="llms-txt " content ="https://pestphp.com/llms.txt ">
24+ < link rel ="alternate " type ="text/plain " href ="https://pestphp.com/llms.txt " title ="LLM-friendly documentation ">
2325 < link rel ="icon " href ="/www/favicon.svg " type ="image/svg+xml ">
2426 < link rel ="preconnect " href ="https://fonts.googleapis.com ">
2527 < link rel ="preconnect " href ="https://fonts.gstatic.com " crossorigin >
Original file line number Diff line number Diff line change 11<x-app-layout layout =" app" :title =" $matter['title']" :description =" $matter['description']" >
2+ <x-slot name =" head" >
3+ <link rel =" alternate" type =" text/plain" href =" {{ url (" /docs/{$page }/llms.txt" ) } }" title =" LLM-friendly version" >
4+ </x-slot >
5+
26 <main role =" main" class =" flex-auto overflow-hidden w-full" >
37 <section class =" documentation" >
48 <div class =" max-w-7xl sm:px-6 lg:flex lg:px-8 mx-auto" >
Original file line number Diff line number Diff line change 3333 <meta property =" og:image" content =" https://pestphp.com/assets/img/og-v4.jpg" >
3434 @endif
3535
36+ <meta name =" llms-txt" content =" {{ url (' /llms.txt' ) } }" >
37+
3638 <meta name =" csrf-token" content =" {{ csrf_token () } }" >
3739
3840 <link rel =" icon" href =" /www/favicon.svg" type =" image/svg+xml" >
Original file line number Diff line number Diff line change 2929 Route::get ('/docs/{page}.md ' , [LlmsTxtController::class, 'page ' ]);
3030 Route::get ('/docs/{page?} ' , DocsController::class)->name ('docs ' )->where ('page ' , '.* ' );
3131});
32-
You can’t perform that action at this time.
0 commit comments