ldc-sitemap-generator/README.md

1.2 KiB

Refresh Sitemap

Creates sitemap.xml and refresh using a config file

Handle i18n routes with codezero/laravel-localized-routes packages.

Installation

Via Composer

composer require uwil/sitemap-generator

Usage

  1. php artisan vendor:publish --tag=sitemap-generator

  2. Change configuration in config/sitemap-generator.php

  3. You can test your configuration using php artisan sitemap:refresh --dry-run

Model implementation

Add :

use Spatie\Sitemap\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;
use Uwil\SitemapGenerator\Lib\SitemapHelper;

Model must implement :

implements Sitemapable

And an toSitemapTag method ex :

/**
 * toSitemapTag method
 *
 * @return Url|string|array
 */
public function toSitemapTag(): Url | string | array
{
    $model  = $this->loadMissing('range');
    $route  = 'product.show';
    $params = ['range' => $model->range, 'publishedProduct' => $model];
    return SitemapHelper::generateUrl($route, $params, $model);
}

Change log

Please see the changelog for more information on what has changed recently.

Security

If you discover any security related issues, please email equipe.web@ldc.fr instead of using the issue tracker.