We have to lie Linkedin telling them there are not images there.

This commit is contained in:
sergiotarxz 2022-11-13 02:22:31 +01:00
parent 2040aa3583
commit 46c59e1c69
2 changed files with 12 additions and 0 deletions

View File

@ -120,6 +120,7 @@ sub post {
}
my $current_category = $categories->{ $post->{category} };
$self->stash(ogimage => 'https://burguillos.info/posts/'.$post->{slug}.'-preview.png');
$self->stash(useragent => $self->req->headers->user_agent);
$self->render( post => $post, current_category => $current_category );
}

View File

@ -10,7 +10,18 @@
% title $post->{title};
<div class="description">
<h2><%= $post->{title} %></h2>
% my $user_agent = stash 'useragent';
% if ($user_agent !~ /LinkedInBot/) {
<%== $post->{content} %>
% } else {
% my $content = $post->{content};
% my $dom = Mojo::DOM->new($content);
% my @images = $dom->find('img')->each;
% for my $image (@images) {
% $image->remove;
% }
<%== $dom->to_string() %>
% }
% my $date_article = DateTime::Format::ISO8601->parse_datetime($post->{date});
% $date_article->set_time_zone('Europe/Madrid');
<p>Escrito por <%= $post->{author} %> con fecha <%= $date_article %>.<p>