Skip to content

Commit

Permalink
Merge pull request #616 from hydephp/skip-sitemap-generation-when-the…
Browse files Browse the repository at this point in the history
…re-is-no-valid-base-url

Skip sitemap generation when there is no valid base URL
  • Loading branch information
caendesilva authored Apr 13, 2024
2 parents 5788348 + 2221476 commit d23128c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Framework/Actions/PostBuildTasks/GenerateSitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class GenerateSitemap extends PostBuildTask

public function handle(): void
{
if (blank(Hyde::url()) || str_starts_with(Hyde::url(), 'http://localhost')) {
$this->skip('Cannot generate sitemap without a valid base URL');
}

$this->path = Hyde::sitePath('sitemap.xml');

$this->needsParentDirectory($this->path);
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Services/BuildTaskServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class BuildTaskServiceTest extends TestCase
*/
public function testBuildCommandCanRunBuildTasks()
{
config(['hyde.url' => 'https://example.com']);

$this->artisan('build')
->expectsOutputToContain('Removing all files from build directory')
->expectsOutputToContain('Generating sitemap')
Expand Down

0 comments on commit d23128c

Please sign in to comment.