Set Priority While Using Models #412
-
Hi, use Spatie\Sitemap\Sitemap;
Sitemap::create()
->add($post)
->add(Post::all()); How can we setup the priority of the Post ? Is there any property that we need to add to the model ? Sorry if i haven't been able to spot that on the readme. Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
HassanZahirnia
Oct 12, 2021
Replies: 1 comment
-
Any news on this ? Edit: Actually few minutes after posting this, I found the solution and it was pretty simple. 😄 public function toSitemapTag(): Url | string | array
{
return Url::create( route('blog.post.show', $this) )
->setPriority(0.7);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
freekmurze
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any news on this ?
Edit: Actually few minutes after posting this, I found the solution and it was pretty simple. 😄
In the model instead of returning a string, just return the Url object like so: