Skip to content

Commit

Permalink
Merge branch 'release/1.4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
werner-freytag committed May 17, 2023
2 parents c532489 + 9499607 commit cfe9f53
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Pecotamic\Sitemap;

use Statamic\Facades\Site;
use Statamic\Facades\URL;
use Statamic\Providers\AddonServiceProvider;
use Statamic\StaticSite\SSG;

class ServiceProvider extends AddonServiceProvider
{
Expand Down Expand Up @@ -33,4 +36,31 @@ protected function bootConfig(): self

return $this;
}

protected function bootRoutes(): self
{
parent::bootRoutes();

$this->addRoutesToSSG();

return $this;
}

protected function addRoutesToSSG(): void
{
if (!class_exists(SSG::class)) {
return;
}

SSG::addUrls(static function () {
return Site::all()
->map(function ($site) {
return URL::makeRelative($site->url());
})
->unique()
->map(function ($sitePrefix) {
return $sitePrefix . '/' . config('pecotamic.sitemap.url');
});
});
}
}

0 comments on commit cfe9f53

Please sign in to comment.