diff --git a/src/Lib/Sitemap.php b/src/Lib/Sitemap.php index 311f8fc..f30f194 100644 --- a/src/Lib/Sitemap.php +++ b/src/Lib/Sitemap.php @@ -4,6 +4,7 @@ namespace LDC\SitemapGenerator\Lib; use Illuminate\Support\Collection; use LDC\SitemapGenerator\Exceptions\SitemapResolveUrlException; +use Spatie\Sitemap\Sitemap as SpatieSitemap; use Spatie\Sitemap\Tags\Url; use Symfony\Component\Mime\MimeTypes; @@ -40,11 +41,17 @@ class Sitemap $queries = \collect(\parse_url($tag->getUrl(), \PHP_URL_QUERY))->filter(); // ! Ignore null from previous or tags with urls that have Queries. if (!$tag or $queries->count()) { - return null; + return false; } - return $tag; + return true; }); $this->assignPrioritiesAndFrequencies(); + + // *Assign new sitemap + $this->sitemap = SpatieSitemap::create(); + $this->tagList->each(function (Tag $tag) { + $this->sitemap->add($tag); + }); } /**