Jelajahi Sumber

Fix #66: video/image sitemap usage

George S. Baugh 5 tahun lalu
induk
melakukan
79d9316060
1 mengubah file dengan 15 tambahan dan 1 penghapusan
  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,
                     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);
             }
         }