common: format page attribute "image" as og header
[sheet.git] / common.inc.plp
index 2976cbe37cd07615b1f9073d9fc332b403e19e24..6295de7ef2ad0653fc436d9636831349742ee832 100644 (file)
@@ -147,6 +147,14 @@ sub Html {
                '<link rel="stylesheet" type="text/css" media="monochrome" href="/mono.css?1.11" title="light">',
        );
 
+       if (my $img = $meta->{image}) {
+               my $proto = sprintf('http%s://', !!$ENV{HTTPS} && 's');
+               my $url = "$proto$ENV{HTTP_HOST}/$img";
+               push @{ $meta->{raw} }, (
+                       qq(<meta property="og:image" content="$url" />),
+               );
+       }
+
        my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x;
 
        PLP_START {