sitemap.xml: calculate priority from path names
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 17 Oct 2019 00:59:47 +0000 (02:59 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 17 Oct 2019 01:00:36 +0000 (03:00 +0200)
sitemap.xml/index.php

index 7d288152ff9bce59f6aaedf6bf10ec140d70df90..f0f928bd5c4db75e9e4fdfb2d9187a0b8a14afdc 100644 (file)
@@ -12,6 +12,14 @@ foreach ($search->files() as $link) {
        $article = new ArchiveArticle($link);
        print '<url>';
        print "<loc>$siteref/{$article->link}</loc>";
+       $score = 10;
+       if ($article->link) {
+               $score -= substr_count($article->link, '/') + 1;  # -10% per subdir
+               $age = time() - strtotime($article->dateiso);
+               $age /= 3600 * 24 * 365;  # years
+               if ($age > .1) $score -= $age / 10 + .1;  # -1% per year
+       }
+       printf('<priority>%.2f</priority>', $score / 10);
        if ($article->last) {
                print "<lastmod>{$article->lastiso}</lastmod>";
        }