Replies: 1 comment
-
I attempted using a custom template. I copied the entire default theme and then added 'docs/' to all of the urls in the base and layout twig files. This worked as far as getting the page to load with all css and js from those files. Then I realized that many of the other files use different twig functions to build links/paths and decided this trying to update the theme probably isn't going to work. If there was a way to set the root dir for the output or tell it to append the build dir to it that would be great. For now, here is the solution I came up with for a Laravel app. Register a global middleware for all requests. This way if it's one of doctums files it will get redirected to a url with 'docs/' appended and everything seems to be working. namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class FixDocsUrls
{
public function handle(Request $request, Closure $next): Response
{
$path = $request->getRequestUri();
$subDirs = ['/js', '/css', '/fonts', '/App'];
$extensions = ['.js', '.xml', '.html'];
$exclusions = ['/rss.xml']; // example exclude
foreach ($subDirs as $dir) {
if(str_starts_with($path, $dir)) {
return redirect('docs' . $path, 301);
}
}
foreach ($extensions as $ext) {
if(str_ends_with($path, $ext) && !in_array($path, $exclusions)) {
return redirect('docs' . $path, 301);
}
}
return $next($request);
}
} |
Beta Was this translation helpful? Give feedback.
-
I am trying to place the generated docs inside my Laravel projects public directory in a docs directory.
http:://tickets-please.test/docs
You can see the repo HereThe docs generate, then I copy them over to public/docs. I made a route to load the index.html file.
The docs load but with no js or css because the links are all relative like js/file.js instead of docs/js/file.js
Is there a way to have all of the generated links include the parent 'docs/' ?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions