OpenGraph pro jednotlivé recepty
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Emil Miler 2023-11-09 10:20:04 +01:00
parent 21bbc12ffc
commit 5cdc5cb846
3 changed files with 20 additions and 9 deletions

View File

@ -7,6 +7,7 @@
<title>{% block title %}{{ config.title }}{% endblock title %}</title> <title>{% block title %}{{ config.title }}{% endblock title %}</title>
<link rel="stylesheet" href="{{ get_url(path="/style.css") }}" type="text/css"> <link rel="stylesheet" href="{{ get_url(path="/style.css") }}" type="text/css">
<link rel="stylesheet" href="{{ get_url(path="/icons.css") }}" type="text/css"> <link rel="stylesheet" href="{{ get_url(path="/icons.css") }}" type="text/css">
{% block head_extra %}{% endblock head_extra %}
</head> </head>
<body> <body>
<nav> <nav>

View File

@ -10,21 +10,25 @@
{% endif %} {% endif %}
> >
<a href="{{ recipe.permalink }}"> <a href="{{ recipe.permalink }}">
{% set_global image = "../static/temp.jpg" %} <div class="image" style="background-image: url('{{ macro::recipe_preview_image(recipe=recipe) }}')"></div>
{% for asset in recipe.assets %}
{% if asset is matching("[img.](jpg|png)$") %}
{% set_global image = asset %}
{% break %}
{% endif %}
{% endfor %}
{% set image = resize_image(path=image, width=300, height=300, op="fill") %}
<div class="image" style="background-image: url('{{ image.url }}')"></div>
<div class="title">{{ recipe.title }}</div> <div class="title">{{ recipe.title }}</div>
{% if recipe.date %}<span class="date">{{ recipe.date | date(format="%d.%m.%Y") }}</span>{% endif %} {% if recipe.date %}<span class="date">{{ recipe.date | date(format="%d.%m.%Y") }}</span>{% endif %}
</a> </a>
</article> </article>
{% endmacro print_recipe %} {% endmacro print_recipe %}
{% macro recipe_preview_image(recipe) %}
{% set_global image = "../static/temp.jpg" %}
{% for asset in recipe.assets %}
{% if asset is matching("[img.](jpg|png)$") %}
{% set_global image = asset %}
{% break %}
{% endif %}
{% endfor %}
{% set image = resize_image(path=image, width=300, height=300, op="fill") %}
{{ image.url }}
{% endmacro recipe_preview_image %}
{% macro pagination() %} {% macro pagination() %}
{% if paginator.previous %} {% if paginator.previous %}
<a href="{{ paginator.previous }}"><span class="icon icon-arrow-left2"></span></a> <a href="{{ paginator.previous }}"><span class="icon icon-arrow-left2"></span></a>

View File

@ -1,6 +1,12 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}{{ config.title }} &mdash; {{ page.title }}{% endblock title %} {% block title %}{{ config.title }} &mdash; {{ page.title }}{% endblock title %}
{% block head_extra %}
<meta property="og:title" content="{{ page.title }}">
<meta property="og:url" content="{{ config.base_url }}">
<meta property="og:image" content="{{ macro::recipe_preview_image(recipe=page) }}">
<meta property="og:type" content="article">
{% endblock head_extra %}
{% block content %} {% block content %}
<main class="recipe"> <main class="recipe">