From f906138c7d143901d5caddd0a413695917476a4f Mon Sep 17 00:00:00 2001 From: Michael Deck Date: Wed, 12 Aug 2020 13:43:28 -0400 Subject: [PATCH] Use output_folder location for determining the asset path placed in the blade file --- src/Writing/Writer.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Writing/Writer.php b/src/Writing/Writer.php index 4c03f2f7..1c3bae64 100644 --- a/src/Writing/Writer.php +++ b/src/Writing/Writer.php @@ -278,6 +278,8 @@ protected function moveOutputFromSourceFolderToTargetFolder(): void // Move output (index.html, css/style.css and js/all.js) to public/docs rename("{$this->sourceOutputPath}/index.html", "{$this->outputPath}/index.html"); } else { + $assetPath = str_replace('public', '', $this->config->get('output_folder')); + // Move output to resources/views if (! is_dir($this->outputPath)) { mkdir($this->outputPath); @@ -285,9 +287,9 @@ protected function moveOutputFromSourceFolderToTargetFolder(): void rename("{$this->sourceOutputPath}/index.html", "$this->outputPath/index.blade.php"); $contents = file_get_contents("$this->outputPath/index.blade.php"); // - $contents = str_replace('href="css/style.css"', 'href="{{ asset(\'/docs/css/style.css\') }}"', $contents); - $contents = str_replace('src="js/all.js"', 'src="{{ asset(\'/docs/js/all.js\') }}"', $contents); - $contents = str_replace('src="images/', 'src="/docs/images/', $contents); + $contents = str_replace('href="css/style.css"', "href=\"{{ asset('{$assetPath}/css/style.css') }}\"", $contents); + $contents = str_replace('src="js/all.js"', "src=\"{{ asset('{$assetPath}/js/all.js') }}\"", $contents); + $contents = str_replace('src="images/', "src=\"{$assetPath}/images/", $contents); $contents = preg_replace('#href="https?://.+?/docs/collection.json"#', 'href="{{ route("apidoc.json") }}"', $contents); file_put_contents("$this->outputPath/index.blade.php", $contents); }