Sfoglia il codice sorgente

Fix #66: video/image sitemap usage

George S. Baugh 5 anni fa
parent
commit
79d9316060
1 ha cambiato i file con 15 aggiunte e 1 eliminazioni
  1. 15 1
      lib/Trog/Routes/HTML.pm

+ 15 - 1
lib/Trog/Routes/HTML.pm

@@ -798,7 +798,21 @@ sub sitemap ($query, $render_cb) {
                     changefreq => $changefreq,
                     changefreq => $changefreq,
                     priority   => 1.0,
                     priority   => 1.0,
                 );
                 );
-                #TODO add video & preview image if applicable
+
+                #add video & preview image if applicable
+                $data{images} = [{
+                    loc => "http://$query->{domain}$url->{href}",
+                    caption => $url->{data},
+                    title => $url->{title},
+                }] if $url->{is_image};
+
+                $data{videos} = [{
+                    content_loc   => "http://$query->{domain}$url->{href}",
+                    thumbnail_loc => "http://$query->{domain}$url->{preview}",
+                    title         => $url->{title},
+                    description   => $url->{data},
+                }] if $url->{is_video};
+
                 $sm->add(%data);
                 $sm->add(%data);
             }
             }
         }
         }