Add (custom crawl profile)
This commit is contained in:
28
app/Helpers/FirstParty/SitemapCrawler/CustomCrawlProfile.php
Normal file
28
app/Helpers/FirstParty/SitemapCrawler/CustomCrawlProfile.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers\FirstParty\SitemapCrawler;
|
||||
|
||||
use Spatie\Crawler\CrawlProfiles\CrawlProfile;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
class CustomCrawlProfile extends CrawlProfile
|
||||
{
|
||||
/** @var callable */
|
||||
protected $callback;
|
||||
|
||||
public function shouldCrawlCallback(callable $callback): void
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function shouldCrawl(UriInterface $url): bool
|
||||
{
|
||||
if ($url->getQuery() !== '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return ($this->callback)($url);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\FirstParty\SitemapCrawler\CustomCrawlProfile;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use Spatie\Sitemap\Crawler\Profile;
|
||||
|
||||
@@ -52,6 +53,6 @@
|
||||
* The sitemap generator uses a CrawlProfile implementation to determine
|
||||
* which urls should be crawled for the sitemap.
|
||||
*/
|
||||
'crawl_profile' => Profile::class,
|
||||
'crawl_profile' => CustomCrawlProfile::class,
|
||||
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user