-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
db0c362
commit 22a846f
Showing
5 changed files
with
103 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\User; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\Response; | ||
use Illuminate\Support\Facades\View; | ||
|
||
class SitemapController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$urls = Cache::remember('sitemap', now()->addDays(7), function() { | ||
$creators = User::getExploreCreatorQuery()->get()->map(function($user) { | ||
return [ | ||
'path' => route('creator.show', $user), | ||
'lastmod' => now()->firstOfMonth(), | ||
'changefreq' => 'weekly', | ||
'priority' => $user?->rating ?? '0.5' | ||
]; | ||
}); | ||
return collect([ | ||
[ | ||
'path' => url('/'), | ||
'lastmod' => now()->firstOfYear(), | ||
'changefreq' => 'yearly', | ||
'priority' => '1' | ||
], | ||
[ | ||
'path' => url('thank-you'), | ||
'lastmod' => now()->firstOfYear(), | ||
'changefreq' => 'yearly', | ||
'priority' => '0.9' | ||
], | ||
[ | ||
'path' => route('explore'), | ||
'lastmod' => now()->firstOfMonth(), | ||
'changefreq' => 'weekly', | ||
'priority' => '0.9' | ||
], | ||
[ | ||
'path' => route('login'), | ||
'lastmod' => now()->firstOfYear(), | ||
'changefreq' => 'yearly', | ||
'priority' => '0.9' | ||
], | ||
[ | ||
'path' => route('register'), | ||
'lastmod' => now()->firstOfYear(), | ||
'changefreq' => 'yearly', | ||
'priority' => '0.9' | ||
], | ||
[ | ||
'path' => route('terms.show'), | ||
'lastmod' => now()->firstOfMonth(), | ||
'changefreq' => 'monthly', | ||
'priority' => '0.9' | ||
], | ||
[ | ||
'path' => url('privacy-policy'), | ||
'lastmod' => now()->firstOfMonth(), | ||
'changefreq' => 'monthly', | ||
'priority' => '0.9' | ||
] | ||
])->concat($creators); | ||
}); | ||
$content = View::make('sitemap.index', ['urls' => $urls]); | ||
$response = Response::make($content); | ||
return $response->withHeaders(['Content-Type' => 'application/xml']); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
@foreach($urls as $url) | ||
<url> | ||
|
||
<loc>{{ $url['path'] }}</loc> | ||
|
||
<lastmod>{{ $url['lastmod'] ?? now() }}</lastmod> | ||
|
||
<changefreq>{{ $url['changefreq'] ?? 'weekly' }}</changefreq> | ||
|
||
<priority>{{ $url['priority'] ?? '0.8' }}</priority> | ||
|
||
</url> | ||
@endforeach | ||
</urlset> |
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