first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,150 @@
<?php
namespace Modules\Sitemap\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Sitemap\Interfaces\SitemapConfigInterface;
use Modules\Sitemap\Models\SitemapConfig;
use Yajra\DataTables\Facades\DataTables;
class SitemapConfigController extends Controller
{
public function __construct(private SitemapConfigInterface $sitemapConfig)
{
//
}
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$isEditing = $request->has("id");
$sitemapConfig = $isEditing ? $this->sitemapConfig->findById($request->id) : null;
if (request()->ajax()) {
$model = SitemapConfig::query()->latest();
return DataTables::eloquent($model)
->addIndexColumn()
->setRowClass('tableRow')
->editColumn('status', function (SitemapConfig $sitemapConfig) {
$status = $sitemapConfig->status ? 'Published' : 'Draft';
$color = $sitemapConfig->status ? 'text-success' : 'text-danger';
return "<p class='{$color}'>{$status}</p>";
})
->addColumn('action', 'sitemap::sitemapConfig.datatable.action')
->rawColumns(['action', 'status'])
->toJson();
}
return view('sitemap::sitemapConfig.index', [
'sitemapConfig' => $sitemapConfig,
'title' => $isEditing ? 'Edit Sitemap Config' : 'Add Sitemap Config',
]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$isEditing = $request->has('id');
if ($isEditing) {
$validated = $request->validate([
'title' => ['required', 'string', 'max:255', 'unique:sitemap_configs,title,' . $request->id],
'max_depth' => ['nullable', 'integer'],
'max_crawl_count' => ['nullable', 'integer'],
'sitemap_excludes' => ['nullable', 'string'],
"ignore_robot" => ['required', 'boolean'],
]);
$sitemapConfig = $this->sitemapConfig->update($request->id, $validated);
session()->flash("success", "Sitemap Config successfully updated.");
return to_route('sitemapConfig.index');
}
$maxOrder = SitemapConfig::max('order');
$order = $maxOrder ? ++$maxOrder : 1;
$request->mergeIfMissing([
'order' => $order
]);
$validated = $request->validate([
'title' => ['required', 'string', 'unique:sitemap_configs,title'],
'max_depth' => ['nullable', 'integer'],
'max_crawl_count' => ['nullable', 'integer'],
'sitemap_excludes' => ['nullable', 'string'],
"ignore_robot" => ['required', 'boolean'],
'order' => ['integer'],
]);
$sitemapConfig = $this->sitemapConfig->create($validated);
session()->flash("success", "Sitemap Config successfully created.");
return to_route('sitemapConfig.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
$sitemapConfig = $this->sitemapConfig->delete($id);
return response()->json([
'status' => 200,
'message' => "Sitemap Config successfully deleted."
], 200);
}
public function toggle($id)
{
$sitemapConfig = $this->sitemapConfig->findById($id);
$sitemapConfig->update([
'status' => !$sitemapConfig->status
]);
return response([
'status' => 200,
'message' => 'Sitemap Config successfully toggled.'
], 200);
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace Modules\Sitemap\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Spatie\Crawler\Crawler;
use Spatie\Sitemap\SitemapGenerator;
use Psr\Http\Message\UriInterface;
use Modules\Sitemap\Models\SitemapConfig;
class SitemapController extends Controller
{
public function index()
{
$path = public_path('sitemap.xml');
if (!file_exists($path)) {
return response('Sitemap not found.', 404);
}
return response()->file($path, [
'Content-Type' => 'application/xml',
]);
}
public function generate(Request $request)
{
$path = public_path('sitemap.xml');
$sitemapConfig = SitemapConfig::active()->latest()->first();
$sitemapExcludes = $sitemapConfig->sitemap_excludes;
$ignoreRobots = $sitemapConfig->ignore_robot;
if (is_string($sitemapExcludes)) {
$sitemapExcludes = array_map('trim', explode(',', $sitemapExcludes));
}
$generator = SitemapGenerator::create(config('app.url'))
->configureCrawler(function (Crawler $crawler) use ($ignoreRobots, $sitemapConfig) {
if ($ignoreRobots) {
$crawler->ignoreRobots();
}
if ($sitemapConfig->max_depth) {
$crawler->setMaximumDepth($sitemapConfig->max_depth);
}
})
->shouldCrawl(function (UriInterface $url) use ($sitemapExcludes) {
$path = $url->getPath();
foreach ($sitemapExcludes as $exclude) {
if (str_starts_with($path, $exclude)) {
return false;
}
}
return true;
});
if ($sitemapConfig->max_crawl_count) {
$generator->setMaximumCrawlCount($sitemapConfig->max_crawl_count);
}
$generator->writeToFile($path);
if (!file_exists($path)) {
return response('Failed to generate sitemap.', 404);
}
return response()->file($path, [
'Content-Type' => 'application/xml',
]);
}
}

View File

@@ -0,0 +1,92 @@
<?php
namespace Modules\Sitemap\Interfaces;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
interface ModelInterface
{
/**
* Retrieve all records with optional filtering, pagination, and custom query modifications.
*
* @param Request|null $request HTTP request containing filters or parameters
* @param callable|null $query Callback to modify the query (e.g., add joins or where clauses)
* @param bool $paginate Whether to paginate the results
* @param int|null $limit Number of records per page if paginated, null for no limit
* @return Collection|mixed
*/
public function findAll(?Request $request = null, ?callable $query = null, bool $paginate = false, ?int $limit = null);
/**
* Find a record by its ID with optional query callback.
*
* @param int $id
* @param callable|null $query
* @param array $columns
* @return Model|null
*/
public function findById(int $id, ?callable $query = null);
/**
* Create a new record.
*
* @param array $data
* @return Model
*/
public function create(array $data);
/**
* Update a record by ID.
*
* @param int $id
* @param array $data
* @return Model|null
*/
public function update(int $id, array $data);
/**
* Delete a record by ID.
*
* @param int $id
* @return bool
*/
public function delete(int $id);
/**
* Pluck values from a column, optionally keyed by another column.
*
* @param string $column
* @param string|null $key
* @param callable|null $query
* @return Collection
*/
public function pluck(string $column, string $key, ?callable $query = null);
// /**
// * Find the first record matching attributes or create it.
// *
// * @param array $attributes
// * @param array $values
// * @return Model
// */
// public function firstOrCreate(array $attributes, array $values = []);
// /**
// * Check if a record exists by ID.
// *
// * @param int|string $id
// * @return bool
// */
// public function exists(int|string $id): bool;
// /**
// * Count records matching a condition.
// *
// * @param array $conditions
// * @param callable|null $query
// * @return int
// */
// public function count(array $conditions = [], ?callable $query = null);
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Modules\Sitemap\Interfaces;
interface SitemapConfigInterface extends ModelInterface
{
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Modules\Sitemap\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Sitemap\Database\Factories\SitemapFactory;
class SitemapConfig extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
"title",
"sitemap_excludes",
"ignore_robot",
"max_depth",
"max_crawl_count",
"order",
"status"
];
protected function casts(): array {
return [
"ignore_robot" => "boolean",
];
}
public function scopeActive($builder) {
$builder->where("status", 1);
}
// protected static function newFactory(): SitemapFactory
// {
// // return SitemapFactory::new();
// }
}

View File

View File

@@ -0,0 +1,30 @@
<?php
namespace Modules\Sitemap\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event handler mappings for the application.
*
* @var array<string, array<int, string>>
*/
protected $listen = [];
/**
* Indicates if events should be discovered.
*
* @var bool
*/
protected static $shouldDiscoverEvents = true;
/**
* Configure the proper event listeners for email verification.
*/
protected function configureEmailVerification(): void
{
//
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Modules\Sitemap\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
protected string $name = 'Sitemap';
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*/
public function boot(): void
{
parent::boot();
}
/**
* Define the routes for the application.
*/
public function map(): void
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::middleware('web')->group(module_path($this->name, '/routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php'));
}
}

View File

@@ -0,0 +1,138 @@
<?php
namespace Modules\Sitemap\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Modules\Sitemap\Interfaces\SitemapConfigInterface;
use Modules\Sitemap\Repositories\SitemapConfigRepository;
use Nwidart\Modules\Traits\PathNamespace;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
class SitemapServiceProvider extends ServiceProvider
{
use PathNamespace;
protected string $name = 'Sitemap';
protected string $nameLower = 'sitemap';
/**
* Boot the application events.
*/
public function boot(): void
{
$this->registerCommands();
$this->registerCommandSchedules();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->name, 'database/migrations'));
}
/**
* Register the service provider.
*/
public function register(): void
{
$this->app->register(EventServiceProvider::class);
$this->app->register(RouteServiceProvider::class);
$this->app->bind(SitemapConfigInterface::class, SitemapConfigRepository::class);
}
/**
* Register commands in the format of Command::class
*/
protected function registerCommands(): void
{
// $this->commands([]);
}
/**
* Register command Schedules.
*/
protected function registerCommandSchedules(): void
{
// $this->app->booted(function () {
// $schedule = $this->app->make(Schedule::class);
// $schedule->command('inspire')->hourly();
// });
}
/**
* Register translations.
*/
public function registerTranslations(): void
{
$langPath = resource_path('lang/modules/'.$this->nameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->nameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower);
$this->loadJsonTranslationsFrom(module_path($this->name, 'lang'));
}
}
/**
* Register config.
*/
protected function registerConfig(): void
{
$relativeConfigPath = config('modules.paths.generator.config.path');
$configPath = module_path($this->name, $relativeConfigPath);
if (is_dir($configPath)) {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath));
foreach ($iterator as $file) {
if ($file->isFile() && $file->getExtension() === 'php') {
$relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname());
$configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath);
$key = ($relativePath === 'config.php') ? $this->nameLower : $configKey;
$this->publishes([$file->getPathname() => config_path($relativePath)], 'config');
$this->mergeConfigFrom($file->getPathname(), $key);
}
}
}
}
/**
* Register views.
*/
public function registerViews(): void
{
$viewPath = resource_path('views/modules/'.$this->nameLower);
$sourcePath = module_path($this->name, 'resources/views');
$this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower);
$componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path')));
Blade::componentNamespace($componentNamespace, $this->nameLower);
}
/**
* Get the services provided by the provider.
*/
public function provides(): array
{
return [];
}
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (config('view.paths') as $path) {
if (is_dir($path.'/modules/'.$this->nameLower)) {
$paths[] = $path.'/modules/'.$this->nameLower;
}
}
return $paths;
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace Modules\Sitemap\Repositories;
use Illuminate\Http\Request;
use Modules\Sitemap\Interfaces\SitemapConfigInterface;
use Modules\Sitemap\Models\SitemapConfig;
class SitemapConfigRepository implements SitemapConfigInterface
{
public function findAll(?Request $request = null, ?callable $query = null, bool $paginate = false, ?int $limit = 10)
{
$baseQuery = SitemapConfig::query();
if ($query) {
$query($baseQuery);
}
if ($paginate) {
return $baseQuery->paginate($limit);
}
return $baseQuery->latest()->get();
}
public function findById(int $id, ?callable $query = null)
{
$baseQuery = SitemapConfig::query();
if (is_callable($query)) {
$query($baseQuery);
}
return $baseQuery->whereId($id)->firstOrFail();
}
public function delete(int $id)
{
$sitemapConfig = $this->findById($id);
$sitemapConfig->delete();
return true;
}
public function create(array $data)
{
return SitemapConfig::create($data);
}
public function update(int $id, array $data)
{
return tap($this->findById($id), function ($sitemapConfig) use ($data) {
$sitemapConfig->update($data);
});
}
public function pluck(string $column, string $key, ?callable $query = null)
{
$baseQuery = SitemapConfig::query();
if (is_callable($query)) {
$query($baseQuery);
}
return $baseQuery->pluck($key, $column);
}
}

View File

@@ -0,0 +1,30 @@
{
"name": "nwidart/sitemap",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Sitemap\\": "app/",
"Modules\\Sitemap\\Database\\Factories\\": "database/factories/",
"Modules\\Sitemap\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Modules\\Sitemap\\Tests\\": "tests/"
}
}
}

View File

View File

@@ -0,0 +1,5 @@
<?php
return [
'name' => 'Sitemap',
];

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('sitemap_configs', function (Blueprint $table) {
$table->id();
$table->string("title");
$table->mediumText("sitemap_excludes")->nullable();
$table->boolean("ignore_robot")->default(false);
$table->unsignedBigInteger("max_depth")->nullable();
$table->unsignedBigInteger("max_crawl_count")->nullable();
$table->integer("status")->default(1);
$table->integer("order")->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sitemap_configs');
}
};

View File

@@ -0,0 +1,16 @@
<?php
namespace Modules\Sitemap\Database\Seeders;
use Illuminate\Database\Seeder;
class SitemapDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// $this->call([]);
}
}

View File

@@ -0,0 +1,11 @@
{
"name": "Sitemap",
"alias": "sitemap",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Sitemap\\Providers\\SitemapServiceProvider"
],
"files": []
}

View File

@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"sass": "^1.69.5",
"postcss": "^8.3.7",
"vite": "^4.0.0"
}
}

View File

View File

@@ -0,0 +1,7 @@
@extends('sitemap::layouts.master')
@section('content')
<h1>Hello World</h1>
<p>Module: {!! config('sitemap.name') !!}</p>
@endsection

View File

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Sitemap Module - {{ config('app.name', 'Laravel') }}</title>
<meta name="description" content="{{ $description ?? '' }}">
<meta name="keywords" content="{{ $keywords ?? '' }}">
<meta name="author" content="{{ $author ?? '' }}">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
{{-- Vite CSS --}}
{{-- {{ module_vite('build-sitemap', 'resources/assets/sass/app.scss', storage_path('vite.hot')) }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-sitemap', 'resources/assets/js/app.js', storage_path('vite.hot')) }} --}}
</body>

View File

@@ -0,0 +1,41 @@
{{ html()->form('POST', route('sitemapConfig.store'))->class('needs-validation')->attributes(['novalidate'])->open() }}
@isset($sitemapConfig)
{{ html()->hidden('id', $sitemapConfig->id) }}
@endisset
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="mb-3">
{{ html()->label('Config Name')->for('title') }}
{{ html()->span('*')->class('text-danger') }}
{{ html()->text('title')->value($sitemapConfig->title ?? old('title'))->class('form-control')->placeholder('Enter Config Name')->required() }}
{{ html()->div('Please enter a title.')->class('invalid-feedback') }}
</div>
<div class="mb-3">
{{ html()->label('Max depth')->class('form-label')->for('max_depth') }}
{{ html()->number('max_depth')->class('form-control')->value($sitemapConfig->max_depth ?? old('max_depth'))->placeholder('Max Depth') }}
</div>
<div class="mb-3">
{{ html()->label('Max crawl count')->class('form-label')->for('max_count') }}
{{ html()->number('max_crawl_count')->class('form-control')->value($sitemapConfig->max_crawl_count ?? old('max_crawl_count'))->placeholder('Page Crawl Count') }}
</div>
<div class="mb-3">
{{ html()->label('Ignore crawler')->class('form-label')->for('sitemap_excludes') }}
{{ html()->textarea('sitemap_excludes')->class('form-control')->value($sitemapConfig->sitemap_excludes ?? old('sitemap_excludes'))->placeholder('CSV Format') }}
</div>
<div class="mb-3">
{{ html()->label('Ignore robots')->class('form-label')->for('ignore_robot') }}
{{ html()->select('ignore_robot', ['0' => 'Disable', '1' => 'Enable'])->value($sitemapConfig->ignore_robot ?? old('ignore_robot'))->class('form-select choices-select') }}
</div>
</div>
<x-form-buttons :href="route('sitemapConfig.index')" :label="isset($sitemapConfig) ? 'Update' : 'Create'" />
</div>
</div>
{{ html()->form()->close() }}

View File

@@ -0,0 +1,12 @@
<div class="hstack flex-wrap gap-3">
<a href="{{ route('sitemapConfig.index', ['id' => $id]) }}" class="link-success fs-15 edit-item-btn"><i
class="ri-edit-2-line"></i></a>
<a data-link="{{ route('sitemapConfig.toggle', $id) }}" data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Toggle" data-status="{{ $status == 1 ? 'Draft' : 'Published' }}"
class="link-info fs-15 toggle-item"><i class="{{ $status == 1 ? 'ri-toggle-line' : 'ri-toggle-fill' }}"></i></a>
<a href="javascript:void(0);" data-link="{{ route('sitemapConfig.destroy', $id) }}"
class="link-danger fs-15 remove-item"><i class="ri-delete-bin-line"></i>
</a>
</div>

View File

@@ -0,0 +1,51 @@
@extends('layouts.app')
@section('content')
<div class="container-fluid">
<x-dashboard.breadcumb :title="$title" />
@if ($errors->any())
<x-flash-message type="danger" :messages="$errors->all()" />
@endif
<div class="row">
<div class="col-lg-4 col-xl-3">
<div class="card profile-card">
@include('sitemap::sitemapConfig.add-sitemap-config-form')
</div>
</div>
<div class="col-lg-xl-8 col-lg-9">
<div class="card">
<div class="card-body">
@php
$columns = [
[
'title' => 'S.N',
'data' => 'DT_RowIndex',
'name' => 'DT_RowIndex',
'orderable' => false,
'searchable' => false,
'sortable' => false,
],
['title' => 'Name', 'data' => 'title', 'name' => 'title'],
['title' => 'Status', 'data' => 'status', 'name' => 'status'],
[
'title' => 'Action',
'data' => 'action',
'orderable' => false,
'searchable' => false,
],
];
@endphp
<x-data-table-script :route="route('sitemapConfig.index')" :reorder="null" :columns="$columns" />
</div>
</div>
</div>
</div>
</div>
@endsection
@push('js')
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush

View File

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Sitemap\Http\Controllers\SitemapController;
/*
*--------------------------------------------------------------------------
* API Routes
*--------------------------------------------------------------------------
*
* Here is where you can register API routes for your application. These
* routes are loaded by the RouteServiceProvider within a group which
* is assigned the "api" middleware group. Enjoy building your API!
*
*/
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
Route::apiResource('sitemap', SitemapController::class)->names('sitemap');
});

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Sitemap\Http\Controllers\SitemapController;
use Modules\Sitemap\Http\Controllers\SitemapConfigController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/sitemap.xml', [SitemapController::class, 'index'])->name('sitemap.index');
Route::group(['middleware' => ['web', 'auth', 'permission'], 'prefix' => 'admin/'], function () {
Route::get('/sitemap/generate', [SitemapController::class, 'generate'])->name('sitemap.generate');
Route::post('/sitemap-config/toggle', [SitemapConfigController::class, 'toggle'])->name('sitemapConfig.toggle');
Route::resource('sitemap-config', SitemapConfigController::class)->names('sitemapConfig');
});

View File

@@ -0,0 +1,57 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { readdirSync, statSync } from 'fs';
import { join,relative,dirname } from 'path';
import { fileURLToPath } from 'url';
export default defineConfig({
build: {
outDir: '../../public/build-sitemap',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-sitemap',
input: [
__dirname + '/resources/assets/sass/app.scss',
__dirname + '/resources/assets/js/app.js'
],
refresh: true,
}),
],
});
// Scen all resources for assets file. Return array
//function getFilePaths(dir) {
// const filePaths = [];
//
// function walkDirectory(currentPath) {
// const files = readdirSync(currentPath);
// for (const file of files) {
// const filePath = join(currentPath, file);
// const stats = statSync(filePath);
// if (stats.isFile() && !file.startsWith('.')) {
// const relativePath = 'Modules/Sitemap/'+relative(__dirname, filePath);
// filePaths.push(relativePath);
// } else if (stats.isDirectory()) {
// walkDirectory(filePath);
// }
// }
// }
//
// walkDirectory(dir);
// return filePaths;
//}
//const __filename = fileURLToPath(import.meta.url);
//const __dirname = dirname(__filename);
//const assetsDir = join(__dirname, 'resources/assets');
//export const paths = getFilePaths(assetsDir);
//export const paths = [
// 'Modules/Sitemap/resources/assets/sass/app.scss',
// 'Modules/Sitemap/resources/assets/js/app.js',
//];