Skip to content

Commit 313c007

Browse files
committed
Refactor SitemapController and SitemapServiceProvider to use a default filename for generating the sitemap, instead of relying on a filename parameter. This simplifies the code and ensures consistency in generating the sitemap.
1 parent b27782f commit 313c007

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Http/Controllers/SitemapController.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
class SitemapController extends BaseController
1616
{
1717
protected Sitemap $sitemap;
18+
protected $defaultFilename = 'sitemap.xml';
1819

1920
/**
2021
* SitemapController constructor.
@@ -31,9 +32,9 @@ public function __construct(Sitemap $sitemap)
3132
*
3233
* @throws FileNotFoundException
3334
*/
34-
public function __invoke(?string $filename): Response
35+
public function __invoke(): Response
3536
{
36-
$contents = $this->sitemap->getSitemapContents($filename);
37+
$contents = $this->sitemap->getSitemapContents($this->defaultFilename);
3738

3839
return response($contents, 200)
3940
->header('Content-Type', 'application/xml');

src/SitemapServiceProvider.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public function configurePackage(Package $package): void
3636
*/
3737
public function PackageRegistered(): void
3838
{
39-
Route::get('/{filename}', SitemapController::class)
40-
->where('filename', '.*\.xml$')
39+
Route::get('/sitemap.xml', SitemapController::class)
4140
->name('sitemap');
4241
}
4342
}

0 commit comments

Comments
 (0)