Skip to content

Commit 30f75f2

Browse files
Update sitemap defaults (#15)
* 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. * Fix styling --------- Co-authored-by: thejmitchener <[email protected]>
1 parent b27782f commit 30f75f2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Http/Controllers/SitemapController.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class SitemapController extends BaseController
1616
{
1717
protected Sitemap $sitemap;
1818

19+
protected $defaultFilename = 'sitemap.xml';
20+
1921
/**
2022
* SitemapController constructor.
2123
*/
@@ -31,9 +33,9 @@ public function __construct(Sitemap $sitemap)
3133
*
3234
* @throws FileNotFoundException
3335
*/
34-
public function __invoke(?string $filename): Response
36+
public function __invoke(): Response
3537
{
36-
$contents = $this->sitemap->getSitemapContents($filename);
38+
$contents = $this->sitemap->getSitemapContents($this->defaultFilename);
3739

3840
return response($contents, 200)
3941
->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)