Skip to content

Commit

Permalink
Update READM>ME According to Commit cfa3184 (#565)
Browse files Browse the repository at this point in the history
The project's documentation has been updated based on the changes made in commit `cfa3184`. These changes include various corrections and improvements that lead to clearer and more comprehensive documentation.
  • Loading branch information
mahdirezaei-dev authored Feb 5, 2025
1 parent e837313 commit eab5bcd
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Sitemap::create()

->add(Url::create('/home')
->setLastModificationDate(Carbon::yesterday())
->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
->setPriority(0.1))

->add(...)

Expand All @@ -40,8 +38,6 @@ SitemapGenerator::create('https://example.com')
->getSitemap()
->add(Url::create('/extra-page')
->setLastModificationDate(Carbon::yesterday())
->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
->setPriority(0.1))

->add(...)

Expand Down Expand Up @@ -84,9 +80,7 @@ class Post extends Model implements Sitemapable

// Return with fine-grained control:
return Url::create(route('blog.post.show', $this))
->setLastModificationDate(Carbon::create($this->updated_at))
->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
->setPriority(0.1);
->setLastModificationDate(Carbon::create($this->updated_at));
}
}
```
Expand Down Expand Up @@ -209,14 +203,10 @@ The generated sitemap will look similar to this:
<url>
<loc>https://example.com</loc>
<lastmod>2016-01-01T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://example.com/page</loc>
<lastmod>2016-01-01T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>

...
Expand Down Expand Up @@ -260,26 +250,6 @@ return [
];
```

#### Changing properties

To change the `lastmod`, `changefreq` and `priority` of the contact page:

```php
use Carbon\Carbon;
use Spatie\Sitemap\SitemapGenerator;
use Spatie\Sitemap\Tags\Url;

SitemapGenerator::create('https://example.com')
->hasCrawled(function (Url $url) {
if ($url->segment(1) === 'contact') {
$url->setPriority(0.9)
->setLastModificationDate(Carbon::create('2016', '1', '1'));
}

return $url;
})
->writeToFile($sitemapPath);
```

#### Leaving out some links

Expand Down Expand Up @@ -366,7 +336,6 @@ use Spatie\Sitemap\Tags\Url;
SitemapGenerator::create('https://example.com')
->getSitemap()
// here we add one extra link, but you can add as many as you'd like
->add(Url::create('/extra-page')->setPriority(0.5))
->writeToFile($sitemapPath);
```

Expand All @@ -381,7 +350,6 @@ use Spatie\Sitemap\Tags\Url;
SitemapGenerator::create('https://example.com')
->getSitemap()
// here we add one extra link, but you can add as many as you'd like
->add(Url::create('/extra-page')->setPriority(0.5)->addAlternate('/extra-pagina', 'nl'))
->writeToFile($sitemapPath);
```

Expand Down Expand Up @@ -559,6 +527,7 @@ protected function schedule(Schedule $schedule)
$schedule->command('sitemap:generate')->daily();
...
}

```

## Changelog
Expand Down

0 comments on commit eab5bcd

Please sign in to comment.