Quellcode durchsuchen

Move Postman collection link to sidebar + make links work on laravel and static

shalvah vor 5 Jahren
Ursprung
Commit
98c039ab59

+ 3 - 0
resources/views/partials/frontmatter.blade.php

@@ -10,4 +10,7 @@ includes:
 logo: {{ $settings['logo'] ?? false }}
 
 toc_footers:
+@if($showPostmanCollectionButton)
+- <a href="{{ $postmanCollectionLink }}">Get Postman Collection</a>
+@endif
 - <a href='http://github.com/knuckleswtf/pastel'>Documentation powered by Pastel</a>

+ 0 - 3
resources/views/partials/info.blade.php

@@ -1,6 +1,3 @@
 # Info
 
 Welcome to the generated API reference.
-@if($showPostmanCollectionButton)
-[Get Postman Collection]({{url($outputPath.'/collection.json')}})
-@endif

+ 6 - 4
src/Writing/Writer.php

@@ -96,9 +96,7 @@ class Writer
         $targetFile = $this->sourceOutputPath . '/source/index.md';
         $compareFile = $this->sourceOutputPath . '/source/.compare.md';
 
-        $infoText = view('apidoc::partials.info')
-            ->with('outputPath', 'docs')
-            ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection);
+        $infoText = view('apidoc::partials.info');
 
         $settings = [
             'languages' => $this->config->get('example_languages'),
@@ -108,6 +106,10 @@ class Writer
         $parsedRouteOutput = $this->generateMarkdownOutputForEachRoute($parsedRoutes, $settings);
 
         $frontmatter = view('apidoc::partials.frontmatter')
+            ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection)
+             // This path is wrong for laravel type but will be replaced in post
+            ->with('postmanCollectionLink', './collection.json')
+            ->with('outputPath', 'docs')
             ->with('settings', $settings);
 
         /*
@@ -266,7 +268,7 @@ class Writer
             $contents = str_replace('href="css/style.css"', 'href="/docs/css/style.css"', $contents);
             $contents = str_replace('src="js/all.js"', 'src="/docs/js/all.js"', $contents);
             $contents = str_replace('src="images/', 'src="/docs/images/', $contents);
-            $contents = preg_replace('#href="https?://.+?/docs/collection.json"#', 'href="{{ route("apidoc.json") }}"', $contents);
+            $contents = preg_replace('#href="./collection.json"#', 'href="{{ route("apidoc.json") }}"', $contents);
             file_put_contents("$this->outputPath/index.blade.php", $contents);
     }