-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sitemap performance improvements (#167)
- Loading branch information
Showing
35 changed files
with
493 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Aerni\AdvancedSeo\Commands; | ||
|
||
use Aerni\AdvancedSeo\Facades\Sitemap; | ||
use Aerni\AdvancedSeo\Jobs\GenerateSitemapsJob; | ||
use Illuminate\Console\Command; | ||
use Statamic\Console\RunsInPlease; | ||
|
||
use function Laravel\Prompts\error; | ||
use function Laravel\Prompts\info; | ||
use function Laravel\Prompts\spin; | ||
use function Laravel\Prompts\warning; | ||
|
||
class GenerateSitemaps extends Command | ||
{ | ||
use RunsInPlease; | ||
|
||
protected $signature = 'seo:generate-sitemaps {--queue}'; | ||
|
||
protected $description = 'Generate the sitemaps'; | ||
|
||
protected bool $shouldQueue = false; | ||
|
||
public function handle() | ||
{ | ||
if (! config('advanced-seo.sitemap.enabled')) { | ||
return error('The sitemap feature is disabled. You need to enable it to generate the sitemaps.'); | ||
} | ||
|
||
$this->shouldQueue = $this->option('queue'); | ||
|
||
if ($this->shouldQueue && config('queue.default') === 'sync') { | ||
warning('The queue connection is set to "sync". Queueing will be disabled.'); | ||
$this->shouldQueue = false; | ||
} | ||
|
||
$sitemaps = collect([Sitemap::index()])->merge(Sitemap::all()); | ||
|
||
$this->shouldQueue | ||
? GenerateSitemapsJob::dispatch($sitemaps) | ||
: spin(fn () => GenerateSitemapsJob::dispatchSync($sitemaps), 'Generating sitemaps ...'); | ||
|
||
$this->shouldQueue | ||
? info('All requests to generate the sitemaps have been added to the queue.') | ||
: info('The sitemaps have been succesfully generated.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Aerni\AdvancedSeo\Contracts; | ||
|
||
interface SitemapFile | ||
{ | ||
public function filename(): string; | ||
|
||
public function file(): ?string; | ||
|
||
public function path(): string; | ||
|
||
public function save(): self; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Aerni\AdvancedSeo\Contracts; | ||
|
||
use Illuminate\Support\Collection; | ||
|
||
interface SitemapIndex | ||
{ | ||
public function add(Sitemap $sitemap): self; | ||
|
||
public function sitemaps(): Collection; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.