Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

Commit f165f61

Browse files
committed
Fixed array concatenation in sitemap gen script
Also set sitemap output to be formatted for easier reading. Updated example sitemap. For #4
1 parent ca7296a commit f165f61

File tree

2 files changed

+177
-297
lines changed

2 files changed

+177
-297
lines changed

Diff for: php-generate-sitemap/generate-sitemap.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@
6868
}, $pages);
6969

7070
// Gather all our endpoints
71-
$allEndpoints = $additionalEndpoints
72-
+ $pageEndpoints
73-
+ $chapterEndpoints
74-
+ $bookEndpoints
75-
+ $shelfEndpoints;
71+
$allEndpoints = array_merge(
72+
$additionalEndpoints,
73+
$pageEndpoints,
74+
$chapterEndpoints,
75+
$bookEndpoints,
76+
$shelfEndpoints
77+
);
7678

7779
// Fetch our sitemap XML
7880
$xmlSitemap = generateSitemapXml($allEndpoints);
@@ -87,6 +89,7 @@ function generateSitemapXml(array $endpoints): string
8789
{
8890
global $baseUrl;
8991
$doc = new DOMDocument("1.0", "UTF-8");
92+
$doc->formatOutput = true;
9093
$urlset = $doc->createElement('urlset');
9194
$urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
9295

0 commit comments

Comments
 (0)