forked from laravel/laravel.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add sitemaps * Remove published vendor files * Remove published sitemap config * Remove unused imports
- Loading branch information
Showing
5 changed files
with
972 additions
and
331 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/node_modules | ||
/public/hot | ||
/public/storage | ||
/public/sitemap*.xml | ||
/storage/*.key | ||
/vendor | ||
.DS_Store | ||
|
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,62 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Str; | ||
use Psr\Http\Message\UriInterface; | ||
use Spatie\Sitemap\SitemapGenerator; | ||
use Spatie\Sitemap\SitemapIndex; | ||
use Spatie\Sitemap\Tags\Url; | ||
|
||
class GenerateSitemap extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'sitemap:generate'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Generate the sitemap.'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
SitemapGenerator::create(config('app.url')) | ||
->shouldCrawl(function (UriInterface $url) { | ||
// Crawl everything without "docs" in the path, as we'll crawl the docs separately... | ||
return ! Str::contains($url->getPath(), 'docs'); | ||
}) | ||
->hasCrawled(function (Url $url) { | ||
if ($url->segment(1) === 'team') { | ||
$url->setPriority(0.5); | ||
} | ||
|
||
return $url; | ||
}) | ||
->writeToFile(public_path('sitemap_pages.xml')); | ||
|
||
SitemapGenerator::create(config('app.url').'/docs/'.DEFAULT_VERSION) | ||
->shouldCrawl(function (UriInterface $url) { | ||
return Str::contains($url->getPath(), 'docs'); | ||
}) | ||
->writeToFile(public_path('sitemap_docs.xml')); | ||
|
||
SitemapIndex::create() | ||
->add('sitemap_pages.xml') | ||
->add('sitemap_docs.xml') | ||
->writeToFile(public_path('sitemap.xml')); | ||
|
||
return 0; | ||
} | ||
} |
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
Oops, something went wrong.