Adding better previews for telegram and more elaborated descriptions.

This commit is contained in:
sergiotarxz 2023-05-03 17:17:54 +02:00
parent 47f1bc43a1
commit d5d7093cbe
4 changed files with 25 additions and 9 deletions

View File

@ -1,23 +1,32 @@
<!DOCTYPE html>
% my $categories = stash 'categories';
% my $current_category_slug = stash 'current_category_slug';
% my $description_og = stash 'description_og';
% $description_og = substr $description_og, 0, 300;
% $description_og =~ s/\s\S+$//;
% $description_og.='...';
% my $base_url = config 'base_url';
<html lang="es">
<head>
<script src="/js/index.js"></script>
% my $css_version = config 'css_version';
<link rel="stylesheet" href="/css/styles.css?v=<%=$css_version%>"/>
<title><%= title %></title>
<meta name="description" content="Lee más sobre: <%= title %>"/>
<meta name="description" content="<%=defined $description_og ? $description_og : 'Lee más sobre: ' . title %>" />
<meta property="og:title" content="<%= title %>"/>
<meta property="og:site_name" content="Burguillos.info" />
<meta property="og:site_name" content="burguillos.info" />
% my $ogimage = stash 'ogimage';
% my $user_agent = stash 'useragent';
% if (defined $ogimage && $user_agent !~ /TelegramBot/) {
<meta name="image" property="og:image" content="<%= $ogimage %>?v=3"/>
% if (defined $ogimage) {
<meta name="image" property="og:image" content="<%= $ogimage %>?v=3"/>
<meta name="twitter:image" content="<%=$ogimage%>" />
% } else {
<meta name="image" property="og:image" content="https://burguillos.info/img/burguillos.png?v=4">
<meta name="image" property="og:image" content="<%=$base_url%>/img/burguillos.png?v=4">
<meta name="twitter:image" content="<%=$base_url%>/img/burguillos.png?v=4">
% }
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="twitter:card" content="<%=defined $description_og ? $description_og : 'Lee más sobre: ' . title %>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div class="site-wrapper">

View File

@ -8,8 +8,10 @@
%
% my $category = stash 'category';
% my $attribute = stash 'attribute';
% my $description_og = '<div>'.$attribute->{description}.'</div>';
% $description_og = Mojo::DOM->new($description_og)->all_text;
% my $posts = stash 'posts';
% layout 'default', current_category_slug => $category->{slug};
% layout 'default', current_category_slug => $category->{slug}, description_og => $description_og;
% title $attribute->{title};
<div class="description">
<h1><%= $attribute->{title} %></h1>

View File

@ -1,12 +1,15 @@
% use Data::Dumper;
% use DateTime::Format::ISO8601;
% use Mojo::DOM;
%
% use Mojo::DOM;
% use Mojo::Util;
%
% use BurguillosInfo::Posts;
%
% layout 'default', current_category_slug => $current_category->{slug};
% my $description_og = '<div>'.$current_category->{description}.'</div>';
% $description_og = Mojo::DOM->new($description_og)->all_text;
% layout 'default', current_category_slug => $current_category->{slug}, description_og => $description_og;
% title $current_category->{title};
<div class="description">
<h1><%= $current_category->{title} %></h1>

View File

@ -6,7 +6,9 @@
% use BurguillosInfo::Posts;
% use BurguillosInfo::Categories;
% my $categories = BurguillosInfo::Categories->new->Retrieve;
% layout 'default', current_category_slug => $current_category->{slug}, categories => $categories;
% my $description_og = '<div>'.$post->{content}.'</div>';
% $description_og = Mojo::DOM->new($description_og)->all_text;
% layout 'default', current_category_slug => $current_category->{slug}, categories => $categories, description_og => $description_og;
% title $post->{title};
<div class="description">
<h1><%= $post->{title} %></h1>