forked from utopigstudio/octobercms-plugin-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.php
More file actions
38 lines (29 loc) · 1.1 KB
/
routes.php
File metadata and controls
38 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
use Cms\Classes\Theme;
use Cms\Classes\Controller;
use Utopigs\Seo\Models\Sitemap;
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFound;
Route::get('sitemap.xml', function()
{
$themeActive = Theme::getActiveTheme()->getDirName();
try {
$definition = Sitemap::where('theme', $themeActive)->firstOrFail();
} catch (ModelNotFound $e) {
Log::info(trans('utopigs.seo::lang.sitemap.not_found'));
return App::make(Controller::class)->setStatusCode(404)->run('/404');
}
return Response::make($definition->generateSitemap())
->header("Content-Type", "application/xml");
});
Route::get('sitemap-debug.xml', function()
{
$themeActive = Theme::getActiveTheme()->getDirName();
try {
$definition = Sitemap::where('theme', $themeActive)->firstOrFail();
} catch (ModelNotFound $e) {
Log::info(trans('utopigs.seo::lang.sitemap.not_found'));
return App::make(Controller::class)->setStatusCode(404)->run('/404');
}
return Response::make($definition->generateSitemap('https'))
->header("Content-Type", "application/xml");
});