Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efba1910dc | ||
|
|
229ca43cdf | ||
|
|
01391a8ca5 | ||
|
|
3e3432b97e |
4 changed files with 1334 additions and 1039 deletions
37
app/Lib/CompleteSitemapWith.php
Normal file
37
app/Lib/CompleteSitemapWith.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib;
|
||||
|
||||
use App\Enums\Advices\AdviceTypeEnum;
|
||||
use App\Models\Advice;
|
||||
use App\Models\Product;
|
||||
use LDC\SitemapGenerator\Lib\Sitemap;
|
||||
|
||||
class CompleteSitemapWith
|
||||
{
|
||||
/**
|
||||
* Use this method to append a list of links to the sitemap
|
||||
*
|
||||
* * Please call $sitemap->mergeUrls to append url for any specific route name.
|
||||
*
|
||||
* @param \LDC\SitemapGenerator\Lib\Sitemap $sitemap
|
||||
* @return void
|
||||
*/
|
||||
public static function append(Sitemap $sitemap): void
|
||||
{
|
||||
// * Ajouts des éléments qui sont affichés en random
|
||||
$sitemap->mergeUrls(Product::query()->where('status', true)->pluck('slug')->transform(function (string $slug) {
|
||||
return \route('products.show', $slug);
|
||||
}));
|
||||
$sitemap->mergeUrls(Advice::query()
|
||||
->where('status', true)->where('type', AdviceTypeEnum::recipes())
|
||||
->pluck('slug')->transform(function (string $slug) {
|
||||
return \route('recipes.show', $slug);
|
||||
}));
|
||||
$sitemap->mergeUrls(Advice::query()
|
||||
->where('status', true)->where('type', AdviceTypeEnum::tips())
|
||||
->pluck('slug')->transform(function (string $slug) {
|
||||
return \route('tips.show', $slug);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -16,10 +16,10 @@
|
|||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"kaishiyoku/laravel-color-validation": "^1.6",
|
||||
"kwaadpepper/image-resizer": "^0.1.2",
|
||||
"kwaadpepper/refresh-sitemap": "^1.0",
|
||||
"laravel/framework": "^8.83",
|
||||
"laravel/tinker": "^2.5",
|
||||
"laravel/ui": "^3.4",
|
||||
"ldc/sitemap-generator": "^1.0",
|
||||
"ldc/web-admin-secure-laravel": "^1.0",
|
||||
"ldc/web-status-checker-laravel": "^1.0",
|
||||
"mews/purifier": "^3.3",
|
||||
|
|
@ -77,7 +77,8 @@
|
|||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"php-http/discovery": true
|
||||
},
|
||||
"gitlab-domains": [
|
||||
"lab.s-web.fr"
|
||||
|
|
|
|||
2249
composer.lock
generated
2249
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Range;
|
||||
use App\Lib\CompleteSitemapWith;
|
||||
use Spatie\Sitemap\Tags\Url;
|
||||
|
||||
return [
|
||||
|
|
@ -12,56 +12,30 @@ return [
|
|||
*
|
||||
* For example, if you want to ignore all routes
|
||||
* of the backoffice group
|
||||
* just add '/backoffice' into this table
|
||||
* just add 'bo' into this table
|
||||
*
|
||||
* * Note that this can take route names (both partially or full)
|
||||
* * You can use a wild card just as for routeIs method
|
||||
*/
|
||||
'ignoreRoutes' => [
|
||||
'/bo',
|
||||
'/produits/gamme/{range}/ajax'
|
||||
'back.*',
|
||||
'bo.*',
|
||||
'front.frame',
|
||||
'cspReportUri',
|
||||
],
|
||||
|
||||
/**
|
||||
* This table is needed to resolve models matching
|
||||
* routes
|
||||
* This should be filled using the command `php artisan sitemap:install-completer`
|
||||
*
|
||||
* it has to be filled like following
|
||||
* 'completeWith' => [CLASS, 'METHOD'],
|
||||
* eg : 'completeWith' => [CompleteSitemapWith::class, 'append'],
|
||||
*
|
||||
* 'products.meat-type' => [
|
||||
* 'slugMeatType' => [MeatTypes::class, 'slug']
|
||||
* ],
|
||||
* 'kitchen-side.health-nutrition.balanced-menu.menu' => [
|
||||
* 'type' => [BalancedMenuType::class, 'type']
|
||||
* ]
|
||||
* This should point to a static method which will be called with the folowing parameter
|
||||
* (LDC\SitemapGenerator\Lib\Sitemap $sitemap)
|
||||
*
|
||||
* The index is the complete route name, the array content is an array
|
||||
* within index is the argument name with its model class.
|
||||
* This will allow the generator to generate a route for each of the models
|
||||
* in this table
|
||||
* You may now use $sitemap->addLinks('route.myRouteName', string[] $links)
|
||||
*/
|
||||
'routesBinder' => [
|
||||
'products.range-products' => [
|
||||
'range' => [Range::class, 'slug']
|
||||
],
|
||||
],
|
||||
|
||||
/**
|
||||
* You can put route conditions here
|
||||
* These will be used to decide whether the route should appear
|
||||
* in the sitemap or not
|
||||
*
|
||||
* These are called in Eloquent where
|
||||
*
|
||||
* example
|
||||
*
|
||||
* 'queryConditions' => [
|
||||
* 'status' => true,
|
||||
* 'ocbStatus' => EleveurOcbStatus::yes()->value,
|
||||
* 'star_moment' => true
|
||||
* ]
|
||||
*
|
||||
*/
|
||||
'queryConditions' => [
|
||||
'status' => true,
|
||||
],
|
||||
'completeWith' => [CompleteSitemapWith::class, 'append'],
|
||||
|
||||
/**
|
||||
* The default route frequency to use with sitemap generator
|
||||
|
|
@ -80,13 +54,21 @@ return [
|
|||
* Frequencies for routes
|
||||
* use the full or partial route name as index
|
||||
* and a frequency within \Spatie\Sitemap\Tags\Url constants
|
||||
*
|
||||
* eg: 'engagments.*' => \Spatie\Sitemap\Tags\Url::CHANGE_FREQUENCY_HOURLY
|
||||
*/
|
||||
'routeFrequencies' => [],
|
||||
'routeFrequencies' => [
|
||||
'news.show' => Url::CHANGE_FREQUENCY_HOURLY
|
||||
],
|
||||
|
||||
/**
|
||||
* Priorities for routes
|
||||
* use the full or partial route name as index
|
||||
* and a priority number between 0 and 1
|
||||
* and a priority in 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, and 0.0.
|
||||
*
|
||||
* 1.0 is the Highest
|
||||
*
|
||||
* eg: 'engagments.*' => 1.0
|
||||
*/
|
||||
'routePriorities' => [],
|
||||
|
||||
|
|
@ -102,11 +84,19 @@ return [
|
|||
* instruction for when to schedule job
|
||||
* you can set this with a cron instruction
|
||||
* You can generate one using https://crontab.guru/
|
||||
* https://laravel.com/docs/8.x/scheduling#schedule-frequency-options
|
||||
*
|
||||
* schedule must be set to true
|
||||
*
|
||||
* Default is every day at 15:45
|
||||
*/
|
||||
'cron' => '45 15 * * *'
|
||||
'cron' => '45 15 * * *',
|
||||
|
||||
/**
|
||||
* The sitemap generator can execute JavaScript on each page so it will
|
||||
* discover links that are generated by your JS scripts. This feature
|
||||
* is powered by headless Chrome.
|
||||
*
|
||||
* ! This needs pupetter installed with npm : npm i puppeteer (not to put in dev dependencies)
|
||||
*/
|
||||
'executeJavascript' => false,
|
||||
];
|
||||
Loading…
Add table
Reference in a new issue