Skip to content

Commit f1d913f

Browse files
committed
fix(sitemap): make sitemap work by setting up an actual route
1 parent 34e2a81 commit f1d913f

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

app/Console/Commands/SitemapGenerate.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class SitemapGenerate extends Command
1212
{
13-
const EXCLUDE = [
13+
public const EXCLUDE = [
1414
'_dusk',
1515
'api',
1616
'sanctum',
@@ -43,6 +43,8 @@ public function handle()
4343
return $route->uri;
4444
}, (array) Route::getRoutes()->getIterator());
4545

46+
asort($routes);
47+
4648
$sitemap = Sitemap::create();
4749

4850
foreach ($routes as $route) {
@@ -55,7 +57,7 @@ public function handle()
5557
}
5658
}
5759

58-
$sitemap->writeToFile(public_path('sitemap.xml'));
60+
$sitemap->writeToFile(public_path('sitemap/sitemap.xml'));
5961

6062
return Command::SUCCESS;
6163
}

app/Http/Controllers/HomeController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ public function terms()
2929

3030
return view('terms', compact('termsOfService'));
3131
}
32+
33+
public function sitemap()
34+
{
35+
$xml = file_get_contents(public_path('sitemap/sitemap.xml'));
36+
37+
return response(content: $xml, headers:['Content-Type' => 'application/xml']);
38+
}
3239
}
Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,72 @@
66
<priority>1.0</priority>
77
</url>
88
<url>
9-
<loc>https://www.mapmarker.io/license</loc>
9+
<loc>https://www.mapmarker.io/changelog</loc>
1010
<changefreq>always</changefreq>
1111
<priority>1.0</priority>
1212
</url>
1313
<url>
14-
<loc>https://www.mapmarker.io/privacy</loc>
14+
<loc>https://www.mapmarker.io/documentation</loc>
1515
<changefreq>always</changefreq>
1616
<priority>1.0</priority>
1717
</url>
1818
<url>
19-
<loc>https://www.mapmarker.io/terms</loc>
19+
<loc>https://www.mapmarker.io/documentation/font-awesome</loc>
2020
<changefreq>always</changefreq>
2121
<priority>1.0</priority>
2222
</url>
2323
<url>
24-
<loc>https://www.mapmarker.io/changelog</loc>
24+
<loc>https://www.mapmarker.io/documentation/font-awesome/v4</loc>
2525
<changefreq>always</changefreq>
2626
<priority>1.0</priority>
2727
</url>
2828
<url>
29-
<loc>https://www.mapmarker.io/editor</loc>
29+
<loc>https://www.mapmarker.io/documentation/font-awesome/v4/icon-stacks</loc>
3030
<changefreq>always</changefreq>
3131
<priority>1.0</priority>
3232
</url>
3333
<url>
34-
<loc>https://www.mapmarker.io/documentation</loc>
34+
<loc>https://www.mapmarker.io/documentation/font-awesome/v4/icons</loc>
3535
<changefreq>always</changefreq>
3636
<priority>1.0</priority>
3737
</url>
3838
<url>
39-
<loc>https://www.mapmarker.io/documentation/versions</loc>
39+
<loc>https://www.mapmarker.io/documentation/font-awesome/v4/pins</loc>
4040
<changefreq>always</changefreq>
4141
<priority>1.0</priority>
4242
</url>
4343
<url>
44-
<loc>https://www.mapmarker.io/documentation/integrations</loc>
44+
<loc>https://www.mapmarker.io/documentation/font-awesome/v5</loc>
4545
<changefreq>always</changefreq>
4646
<priority>1.0</priority>
4747
</url>
4848
<url>
49-
<loc>https://www.mapmarker.io/documentation/integrations/bing-maps</loc>
49+
<loc>https://www.mapmarker.io/documentation/font-awesome/v5/icon-stacks</loc>
5050
<changefreq>always</changefreq>
5151
<priority>1.0</priority>
5252
</url>
5353
<url>
54-
<loc>https://www.mapmarker.io/documentation/integrations/google-maps</loc>
54+
<loc>https://www.mapmarker.io/documentation/font-awesome/v5/icons</loc>
5555
<changefreq>always</changefreq>
5656
<priority>1.0</priority>
5757
</url>
5858
<url>
59-
<loc>https://www.mapmarker.io/documentation/integrations/mapbox</loc>
59+
<loc>https://www.mapmarker.io/documentation/font-awesome/v5/pins</loc>
6060
<changefreq>always</changefreq>
6161
<priority>1.0</priority>
6262
</url>
6363
<url>
64-
<loc>https://www.mapmarker.io/documentation/font-awesome</loc>
64+
<loc>https://www.mapmarker.io/documentation/font-awesome/v6</loc>
6565
<changefreq>always</changefreq>
6666
<priority>1.0</priority>
6767
</url>
6868
<url>
69-
<loc>https://www.mapmarker.io/documentation/font-awesome/v6</loc>
69+
<loc>https://www.mapmarker.io/documentation/font-awesome/v6/icon-stacks</loc>
70+
<changefreq>always</changefreq>
71+
<priority>1.0</priority>
72+
</url>
73+
<url>
74+
<loc>https://www.mapmarker.io/documentation/font-awesome/v6/icons</loc>
7075
<changefreq>always</changefreq>
7176
<priority>1.0</priority>
7277
</url>
@@ -76,52 +81,52 @@
7681
<priority>1.0</priority>
7782
</url>
7883
<url>
79-
<loc>https://www.mapmarker.io/documentation/font-awesome/v6/icons</loc>
84+
<loc>https://www.mapmarker.io/documentation/integrations</loc>
8085
<changefreq>always</changefreq>
8186
<priority>1.0</priority>
8287
</url>
8388
<url>
84-
<loc>https://www.mapmarker.io/documentation/font-awesome/v6/icon-stacks</loc>
89+
<loc>https://www.mapmarker.io/documentation/integrations/bing-maps</loc>
8590
<changefreq>always</changefreq>
8691
<priority>1.0</priority>
8792
</url>
8893
<url>
89-
<loc>https://www.mapmarker.io/documentation/font-awesome/v5</loc>
94+
<loc>https://www.mapmarker.io/documentation/integrations/google-maps</loc>
9095
<changefreq>always</changefreq>
9196
<priority>1.0</priority>
9297
</url>
9398
<url>
94-
<loc>https://www.mapmarker.io/documentation/font-awesome/v5/pins</loc>
99+
<loc>https://www.mapmarker.io/documentation/integrations/mapbox</loc>
95100
<changefreq>always</changefreq>
96101
<priority>1.0</priority>
97102
</url>
98103
<url>
99-
<loc>https://www.mapmarker.io/documentation/font-awesome/v5/icons</loc>
104+
<loc>https://www.mapmarker.io/documentation/versions</loc>
100105
<changefreq>always</changefreq>
101106
<priority>1.0</priority>
102107
</url>
103108
<url>
104-
<loc>https://www.mapmarker.io/documentation/font-awesome/v5/icon-stacks</loc>
109+
<loc>https://www.mapmarker.io/editor</loc>
105110
<changefreq>always</changefreq>
106111
<priority>1.0</priority>
107112
</url>
108113
<url>
109-
<loc>https://www.mapmarker.io/documentation/font-awesome/v4</loc>
114+
<loc>https://www.mapmarker.io/license</loc>
110115
<changefreq>always</changefreq>
111116
<priority>1.0</priority>
112117
</url>
113118
<url>
114-
<loc>https://www.mapmarker.io/documentation/font-awesome/v4/pins</loc>
119+
<loc>https://www.mapmarker.io/privacy</loc>
115120
<changefreq>always</changefreq>
116121
<priority>1.0</priority>
117122
</url>
118123
<url>
119-
<loc>https://www.mapmarker.io/documentation/font-awesome/v4/icons</loc>
124+
<loc>https://www.mapmarker.io/sitemap.xml</loc>
120125
<changefreq>always</changefreq>
121126
<priority>1.0</priority>
122127
</url>
123128
<url>
124-
<loc>https://www.mapmarker.io/documentation/font-awesome/v4/icon-stacks</loc>
129+
<loc>https://www.mapmarker.io/terms</loc>
125130
<changefreq>always</changefreq>
126131
<priority>1.0</priority>
127132
</url>

routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
Route::get('/', [HomeController::class, 'index']);
21+
Route::get('/sitemap.xml', [HomeController::class, 'sitemap']);
2122
Route::get('/license', [HomeController::class, 'license']);
2223
Route::get('/privacy', [HomeController::class, 'privacy']);
2324
Route::get('/terms', [HomeController::class, 'terms']);

0 commit comments

Comments
 (0)