Sitemap generator with default sitemap
This commit is contained in:
45
app/Console/Commands/IkeaSitemap.php
Normal file
45
app/Console/Commands/IkeaSitemap.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Spatie\Sitemap\SitemapGenerator;
|
||||
use Spatie\Crawler\Crawler;
|
||||
use Spatie\Sitemap\Tags\Url;
|
||||
|
||||
class IkeaSitemap extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ikea:sitemap {path}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$path = $this->argument('path');
|
||||
SitemapGenerator::create('https://prices.soson.eu')
|
||||
->configureCrawler(function (Crawler $crawler) {
|
||||
$crawler->ignoreRobots();
|
||||
})
|
||||
->getSitemap()
|
||||
->add(Url::create('https://prices.soson.eu/about/')->setPriority(0.7))
|
||||
->add(Url::create('https://prices.soson.eu/exchange/')->setPriority(0.5))
|
||||
->add(Url::create('https://prices.soson.eu/doc/')->setPriority(0.8))
|
||||
->writeToFile($path);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user