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;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
public/sitemap.xml
Normal file
23
public/sitemap.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
|
||||||
|
<url>
|
||||||
|
<loc>https://prices.soson.eu/</loc>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://prices.soson.eu/about/</loc>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>0.7</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://prices.soson.eu/exchange/</loc>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>0.5</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://prices.soson.eu/doc/</loc>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>
|
||||||
|
</urlset>
|
||||||
Reference in New Issue
Block a user