Skip to content

Commit 8ae31f9

Browse files
committed
Document the priority algorithm intentions
1 parent c5f6f3e commit 8ae31f9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/framework/src/Framework/Features/XmlGenerators/SitemapGenerator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,34 @@ protected function getLastModDate(string $file): string
6161
return date('c', @Filesystem::lastModified($file) ?: Carbon::now()->timestamp);
6262
}
6363

64+
/** Intelligently find a good priority for the given page based on assumptions about the site structure. */
6465
protected function getPriority(string $pageClass, string $identifier): string
6566
{
6667
// The default priority, unless we find a better match.
6768
$priority = 0.5;
6869

6970
if (in_array($pageClass, [BladePage::class, MarkdownPage::class])) {
71+
// These pages are usually high up in the site hierarchy, so they get a higher priority.
7072
$priority = 0.9;
7173

7274
if ($identifier === 'index') {
75+
// The homepage is the most important page, so it gets the highest priority.
7376
$priority = 1;
7477
}
7578
}
7679

7780
if ($pageClass === DocumentationPage::class) {
81+
// If a site has documentation pages, they are usually important as well.
7882
$priority = 0.9;
7983
}
8084

8185
if ($pageClass === MarkdownPost::class) {
86+
// Posts are usually less important than pages as there may be many of them.
8287
$priority = 0.75;
8388
}
8489

8590
if ($identifier === '404') {
91+
// 404 pages are rarely important to index, so they get a lower priority.
8692
$priority = 0.5;
8793
}
8894

0 commit comments

Comments
 (0)