File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99use Illuminate \Console \Command ;
1010use Spatie \Sitemap \Sitemap ;
1111use Spatie \Sitemap \Tags \Url ;
12- use Spatie \Tags \Tag ;
1312
1413final class SitemapGenerateCommand extends Command
1514{
@@ -41,50 +40,8 @@ public function handle(): void
4140 ->add (Url::create (route ('posts.index ' ))->setPriority (0.8 )->setChangeFrequency (Url::CHANGE_FREQUENCY_WEEKLY ))
4241 ->add (Post::query ()->wherePublished ()->get ())
4342 ->add (Project::query ()->get ())
44- ->add ($ this ->createUrlPostTags ())
45- ->add ($ this ->createUrlProjectTags ())
4643 ->writeToDisk ('r2 ' , 'sitemap.xml ' , true );
4744
4845 $ this ->info ('Sitemap generated and uploaded to R2 successfully. ' );
4946 }
50-
51- private function createUrlPostTags (): array
52- {
53- $ urls = [];
54-
55- Post::query ()
56- ->with ('tags ' )
57- ->wherePublished ()
58- ->get ()
59- ->pluck ('tags ' )
60- ->flatten ()
61- ->unique ('id ' )
62- ->map (function (Tag $ tag ) use (&$ urls ): void {
63- $ urls [] = Url::create (route ('posts.index ' , ['tag ' => $ tag ->slug ]))
64- ->setPriority (0.1 )
65- ->setChangeFrequency (Url::CHANGE_FREQUENCY_MONTHLY );
66- });
67-
68- return $ urls ;
69- }
70-
71- private function createUrlProjectTags (): array
72- {
73- $ urls = [];
74-
75- Project::query ()
76- ->with ('tags ' )
77- ->wherePublished ()
78- ->get ()
79- ->pluck ('tags ' )
80- ->flatten ()
81- ->unique ('id ' )
82- ->map (function (Tag $ tag ) use (&$ urls ): void {
83- $ urls [] = Url::create (route ('projects.index ' , ['tag ' => $ tag ->slug ]))
84- ->setPriority (0.1 )
85- ->setChangeFrequency (Url::CHANGE_FREQUENCY_MONTHLY );
86- });
87-
88- return $ urls ;
89- }
9047}
You can’t perform that action at this time.
0 commit comments