Skip to content

Commit

Permalink
feat(sitemap): add sitemap generation command and configuration
Browse files Browse the repository at this point in the history
Introduced a new command `sitemap:generate` to create a sitemap XML. Added necessary configurations for sitemap generation using the Spatie Laravel Sitemap package. Updated dependencies in composer to include required packages.
  • Loading branch information
frederic moras committed Dec 31, 2024
1 parent cce7f9c commit e1f18b8
Show file tree
Hide file tree
Showing 4 changed files with 478 additions and 1 deletion.
29 changes: 29 additions & 0 deletions app/Console/Commands/GenerateSitemap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Spatie\Sitemap\Sitemap;
use Spatie\Sitemap\Tags\Url;

class GenerateSitemap extends Command
{
protected $signature = 'sitemap:generate';
protected $description = 'Générer le sitemap XML pour le site';

public function handle()
{
Sitemap::create()
->add(Url::create('/')->setPriority(1.0)->setChangeFrequency('yearly'))
->add(Url::create('/products/portes-fenetres-chassis')->setPriority(0.9)->setChangeFrequency('yearly'))
->add(Url::create('/products/chassis/kind/alu')->setPriority(0.9)->setChangeFrequency('yearly'))
->add(Url::create('/products/chassis/kind/pvc')->setPriority(0.9)->setChangeFrequency('yearly'))
->add(Url::create('/products/pergolas')->setPriority(0.9)->setChangeFrequency('yearly'))
->add(Url::create('/products/porte-de-garage')->setPriority(0.9)->setChangeFrequency('yearly'))
->add(Url::create('/products/moustiquaire')->setPriority(0.9)->setChangeFrequency('yearly'))
->add(Url::create('/contact')->setPriority(0.8)->setChangeFrequency('yearly'))
->writeToFile(public_path('sitemap.xml'));

$this->info('Sitemap généré avec succès!');
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"league/csv": "^9.18",
"sendinblue/api-v3-sdk": "^8.4",
"spatie/laravel-medialibrary": "^11.10",
"spatie/laravel-sitemap": "^7.3",
"spatie/ray": "^1.41"
},
"require-dev": {
Expand Down
Loading

0 comments on commit e1f18b8

Please sign in to comment.