{"id":15296308,"url":"https://github.com/vdlp/oc-sitemap-plugin","last_synced_at":"2025-04-13T20:01:36.140Z","repository":{"id":47291350,"uuid":"219693486","full_name":"vdlp/oc-sitemap-plugin","owner":"vdlp","description":"A sitemap.xml generator for October CMS","archived":false,"fork":false,"pushed_at":"2024-03-14T13:59:50.000Z","size":77,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-27T10:38:49.615Z","etag":null,"topics":["laravel","october-cms","octobercms","php","php7","sitemap-generator","sitemap-xml"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vdlp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-05T08:24:02.000Z","updated_at":"2023-05-25T11:34:57.000Z","dependencies_parsed_at":"2024-03-14T15:18:30.569Z","dependency_job_id":null,"html_url":"https://github.com/vdlp/oc-sitemap-plugin","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":"0.24137931034482762","last_synced_commit":"ede6ea56451d4e45092633c9d8020e14a9ddfaf9"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdlp%2Foc-sitemap-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdlp%2Foc-sitemap-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdlp%2Foc-sitemap-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdlp%2Foc-sitemap-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vdlp","download_url":"https://codeload.github.com/vdlp/oc-sitemap-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248774935,"owners_count":21159533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","october-cms","octobercms","php","php7","sitemap-generator","sitemap-xml"],"created_at":"2024-09-30T18:10:01.337Z","updated_at":"2025-04-13T20:01:36.077Z","avatar_url":"https://github.com/vdlp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003cimg height=\"60px\" width=\"60px\" src=\"https://plugins.vdlp.nl/octobercms/icons/Vdlp.Sitemap.svg\"\u003e\n\t\u003ch1 align=\"center\"\u003eVdlp.Sitemap\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cem\u003eThis plugin allows developers to create a sitemap.xml using a sitemap definition generator.\u003c/em\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://badgen.net/packagist/php/vdlp/oc-sitemap-plugin\"\u003e\n\t\u003cimg src=\"https://badgen.net/packagist/license/vdlp/oc-sitemap-plugin\"\u003e\n\t\u003cimg src=\"https://badgen.net/packagist/v/vdlp/oc-sitemap-plugin/latest\"\u003e\n\t\u003cimg src=\"https://badgen.net/badge/cms/October%20CMS\"\u003e\n\t\u003cimg src=\"https://badgen.net/badge/type/plugin\"\u003e\n\t\u003cimg src=\"https://plugins.vdlp.nl/octobercms/badge/installations.php?plugin=vdlp-sitemap\"\u003e\n\u003c/p\u003e\n\n## Requirements\n\n- PHP 8.0.2 or higher\n- Supports October CMS 3.x only\n\n## Usage\n\n### Sitemap definitions generator\n\nTo generate sitemap items you can create your own sitemap definition generator.\n\nExample:\n\n```php\nfinal class DefinitionGenerator implements Contracts\\DefinitionGenerator\n{\n    public function getDefinitions(): Definitions\n    {\n        $definitions = new Definitions();\n\n        for ($i = 0; $i \u003c 100; $i++) {\n            $definitions-\u003eaddItem(\n                (new Definition)-\u003esetModifiedAt(Carbon::now())\n                    -\u003esetPriority(1)\n                    -\u003esetUrl('example.com/page/' . $i)\n                    -\u003esetChangeFrequency(Definition::CHANGE_FREQUENCY_ALWAYS)\n            );\n        }\n\n        return $definitions;\n    }\n}\n```\n\nRegister your generator in the `boot` method of your plugin class:\n\n```php\nEvent::listen(Contracts\\SitemapGenerator::GENERATE_EVENT, static function(): DefinitionGenerator {\n    return new DefinitionGenerator();\n});\n```\n\nYou can also register multiple generators:\n\n```php\nEvent::listen(Contracts\\SitemapGenerator::GENERATE_EVENT, static function(): array {\n    return [\n        new DefinitionGeneratorOne(),\n        new DefinitionGeneratorTwo(),\n        // ..\n    ];\n});\n```\n\n### Invalidate sitemap cache\n\nYou can fire an event to invalidate the sitemap cache\n\n```php\nEvent::fire(Contracts\\SitemapGenerator::INVALIDATE_CACHE_EVENT);\n```\n\nOr resolve the generator instance and use the invalidate cache method\n\n```php\n/** @var SitemapGenerator $sitemapGenerator */\n$sitemapGenerator = resolve(Contracts\\SitemapGenerator::class);\n$sitemapGenerator-\u003einvalidateCache();\n```\n\n## Update / Add / Delete definitions in cache\n\nFirst resolve the sitemap generator\n\n```php\n/** @var SitemapGenerator $sitemapGenerator */\n$sitemapGenerator = resolve(Contracts\\SitemapGenerator::class);\n```\n\n### Add definitions\n\n```php\n$sitemapGenerator-\u003eaddDefinition(\n    (new Definition())\n        -\u003esetUrl('example.com/new-url')\n        -\u003esetModifiedAt(Carbon::now())\n        -\u003esetChangeFrequency(Definition::CHANGE_FREQUENCY_YEARLY)\n        -\u003esetPriority(5)\n);\n```\n\n### Update definitions\n\n\u003e Note, definitions are updated by their URL.\n\n```php\n$sitemapGenerator-\u003eupdateDefinition(\n    (new Definition())\n        -\u003esetUrl('example.com/page/1')\n        -\u003esetModifiedAt(Carbon::parse('1900-10-10'))\n        -\u003esetPriority(7)\n        -\u003esetChangeFrequency(Definition::CHANGE_FREQUENCY_HOURLY),\n    'example.com/page/0' // (optional) specify the url to update in cache, when old url is null the definition url will be used.\n);\n```\n\n### Update or add definitions\n\n```php\n$sitemapGenerator-\u003eupdateOrAddDefinition(\n    (new Definition())\n        -\u003esetUrl('example.com/create-or-add')\n        -\u003esetModifiedAt(Carbon::now())\n        -\u003esetChangeFrequency(Definition::CHANGE_FREQUENCY_YEARLY)\n        -\u003esetPriority(5),\n    null // (optional) specify the url to update in cache, when old url is null the definition url will be used.\n);\n```\n\n### Delete definitions\n\n```php\n$sitemapGenerator-\u003edeleteDefinition('example.com/new-url');\n```\n\n## Exclude URLs from sitemap\n\n```php\nEvent::listen(SitemapGenerator::EXCLUDE_URLS_EVENT, static function (): array {\n    return [\n        'example.com/page/1',\n    ];\n});\n```\n\n## Configuration\n\nAdd the plugin configuration to your config folder:\n\n```\nphp artisan vendor:publish --provider=\"Vdlp\\Sitemap\\ServiceProvider\" --tag=\"config\"\n```\n\nYou can change the amount of seconds the sitemap is cached in your `.env` file.\nYou can also cache the sitemap forever.\n\n ```dotenv\nVDLP_SITEMAP_CACHE_TIME=3600\nVDLP_SITEMAP_CACHE_FOREVER=false\n```\n\n### ConfigResolver\n\nOptionally you can override how the sitemap config should be resolved by giving your own ConfigResolver implementation in the config file.\nThis can be useful for multisite projects, where the sitemap should be cached per domain.\n\n```php\nuse Illuminate\\Contracts\\Config\\Repository;\nuse Illuminate\\Http\\Request;\nuse Vdlp\\Sitemap\\Classes\\Contracts\\ConfigResolver;\nuse Vdlp\\Sitemap\\Classes\\Dto\\SitemapConfig;\n\nfinal class MultisiteConfigResolver implements ConfigResolver\n{\n    public function __construct(private Repository $config, private Request $request)\n    {\n    }\n\n    public function getConfig(): SitemapConfig\n    {\n        $domain = $this-\u003erequest-\u003egetHost();\n\n        return new SitemapConfig(\n            'vdlp_sitemap_cache_' . $domain,\n            'vdlp_sitemap_definitions_' . $domain,\n            sprintf('vdlp/sitemap/sitemap_%s.xml', $domain),\n            (int) $this-\u003econfig-\u003eget('sitemap.cache_time', 3600),\n            (bool) $this-\u003econfig-\u003eget('sitemap.cache_forever', false)\n        );\n    }\n}\n```\n\n## Issues\n\nIf you have issues using this plugin. Please create an issue on GitHub or contact us at [octobercms@vdlp.nl]().\n\n## Contribution\n\nAny help is appreciated. Or feel free to create a Pull Request on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdlp%2Foc-sitemap-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvdlp%2Foc-sitemap-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdlp%2Foc-sitemap-plugin/lists"}