Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Simple Sitemap logic to avoid errors. #226

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading