Skip to content

Commit

Permalink
Merge pull request #226 from quantcdn/feature/sitemap-fixes
Browse files Browse the repository at this point in the history
Updated Simple Sitemap logic to avoid errors.
  • Loading branch information
kepol authored Feb 28, 2024
2 parents de5a9e6 + b29660d commit 11d6868
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
24 changes: 19 additions & 5 deletions modules/quant_sitemap/src/SitemapManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,27 @@ protected function getSitemapManager() {
* A list of sitemap items.
*/
protected function getSimpleSitemaps() : array {
$items = ['/sitemap.xml', '/sitemap_generator/default/sitemap.xsl'];
foreach ($this->getSitemapManager()->getAllBundleSettings() as $variant => $def) {
if ($variant == "default") {
continue;

// Gather XML and XSL files.
$items = [];
foreach ($this->getSitemapManager()->getSitemaps() as $id => $sitemap) {

// Only add enabled sitemaps with content.
if ($sitemap->isEnabled() && $sitemap->contentStatus()) {

// Note, creating an options array with 'absolute' => FALSE does not
// generate a relative URL, so we have to extract it.
$items[] = parse_url($sitemap->toUrl()->toString())['path'];

// Figure out the XSL file for this sitemap.
$pluginId = $sitemap->getType()->getSitemapGenerator()->getPluginId();
$items[] = '/sitemap_generator/' . $pluginId . '/sitemap.xsl';
}
$items[] = "/$variant/sitemap.xml";
}

// Remove duplicate XSL files.
$items = array_unique($items);

return $items;
}

Expand Down
1 change: 1 addition & 0 deletions src/Commands/QuantDrushCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public function prepare($options = ['reset' => 'true']) {
'file_paths',
'file_paths_textarea',
'robots',
'export_sitemap',
'lunr',
];

Expand Down

0 comments on commit 11d6868

Please sign in to comment.