Skip to content

Commit

Permalink
🎨 Set a deployed_at cache timestamp for sitemap and hashing images
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Feb 1, 2024
1 parent 0335743 commit ebab59f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class SitemapController extends Controller
*/
public function index(Request $request)
{
$lastModified = cache()->rememberForever('docs.lastmod', fn () => now()->toAtomString());
$lastModified = cache()->rememberForever('deployed_at', fn () => now());

$pages = [
'url' => route('home'),
'lastmod' => $lastModified,
'lastmod' => $lastModified->toAtomString(),
];

$pages = [...[$pages], ...Docs::all()->map(fn ($page) => [
'url' => $page->url,
'lastmod' => $lastModified,
'lastmod' => $lastModified->toAtomString(),
])];

return response()
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Middleware/AddSeoDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class AddSeoDefaults
*/
public function handle(Request $request, Closure $next): Response
{
$timestamp = cache()->rememberForever('deployed_at', fn () => now());

seo()->charset();
seo()->viewport();

Expand Down Expand Up @@ -81,7 +83,7 @@ public function handle(Request $request, Closure $next): Response

Twitter::make()
->name('image')
->content(asset('/social.png')),
->content(asset("/social.png?{$timestamp->timestamp}")),
]);

return $next($request);
Expand Down

0 comments on commit ebab59f

Please sign in to comment.