-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
{{ xml_header }} | ||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
{{ sites }} | ||
<sitemap> | ||
<loc>{{ permalink | ensure_right('/') }}sitemap.xml</loc> | ||
</sitemap> | ||
{{ /sites }} | ||
</sitemapindex> | ||
{{ unless seo:use_sitemap }} | ||
{{ 404 }} | ||
{{ else }} | ||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
{{ sites }} | ||
<sitemap> | ||
<loc>{{ permalink | ensure_right('/') }}sitemap.xml</loc> | ||
</sitemap> | ||
{{ /sites }} | ||
</sitemapindex> | ||
{{ /unless }} |
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 |
---|---|---|
@@ -1,47 +1,26 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Statamic\Exceptions\NotFoundHttpException; | ||
use Statamic\Facades\GlobalSet; | ||
use Statamic\Facades\Site; | ||
use Statamic\Facades\URL; | ||
|
||
// The Sitemap Index route for listing sitemaps of all (multi)sites. | ||
Route::statamic('/sitemaps.xml', 'statamic-peak-seo::sitemap/sitemaps', function () { | ||
if (! GlobalSet::findByHandle('seo')?->inDefaultSite()?->get('use_sitemap')) { | ||
throw new NotFoundHttpException; | ||
} | ||
|
||
return [ | ||
'layout' => null, | ||
'content_type' => 'application/xml', | ||
]; | ||
}); | ||
|
||
// Register routes for each site. | ||
Site::all()->each(function (\Statamic\Sites\Site $site) { | ||
$relativeSiteUrl = URL::makeRelative($site->url()); | ||
|
||
// The Sitemap route. | ||
Route::statamic(URL::tidy($relativeSiteUrl.'/sitemap.xml'), 'statamic-peak-seo::sitemap/sitemap', function () { | ||
if (! GlobalSet::findByHandle('seo')?->inDefaultSite()?->get('use_sitemap')) { | ||
throw new NotFoundHttpException; | ||
} | ||
|
||
return [ | ||
'layout' => null, | ||
'content_type' => 'application/xml', | ||
]; | ||
}); | ||
|
||
// The Social Image route to generate social images. | ||
Route::statamic(URL::tidy($relativeSiteUrl.'/social-images/{id}'), 'statamic-peak-seo::social_images', function ($id) { | ||
if (! GlobalSet::findByHandle('seo')?->inDefaultSite()?->get('use_social_image_generation')) { | ||
throw new NotFoundHttpException; | ||
} | ||
|
||
return [ | ||
'layout' => null, | ||
]; | ||
}); | ||
}); | ||
Route::statamic(URL::tidy('/sitemaps.xml'), 'statamic-peak-seo::sitemap/sitemaps', [ | ||
'layout' => null, | ||
'content_type' => 'application/xml', | ||
]); | ||
|
||
// The Sitemap routes. | ||
Route::statamic(URL::tidy('sitemap.xml'), 'statamic-peak-seo::sitemap/sitemap', [ | ||
'layout' => null, | ||
'content_type' => 'application/xml', | ||
]); | ||
|
||
Route::statamic(URL::tidy('{current_site}/sitemap.xml'), 'statamic-peak-seo::sitemap/sitemap', [ | ||
'layout' => null, | ||
'content_type' => 'application/xml', | ||
]); | ||
|
||
// The Social Image route to generate social images. | ||
Route::statamic(URL::tidy('{current_site}/social-images/{id}'), 'statamic-peak-seo::social_images', [ | ||
'layout' => null, | ||
]); |