summaryrefslogtreecommitdiff
path: root/templates/blog-post.html
blob: d08ed2fd673f8f396a4390b9827288bf82bf74d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{% extends "base.html" %}

{% from "macros/blog.html" import render_blog_post %}

{% set pagefind_body = true %}

{% set features = namespace(trail=false) %}

{% for block in this.body.blocks %}
  {% if block._flowblock == "trail" %}
    {% set features.trail = true %}
  {% endif %}
{% endfor %}

{% set needs_trail_assets = features.trail %}
{% set latest_change = this.changelog.blocks | max(attribute="date") if this.changelog else none %}

{% block meta %}
  {{ super() }}
  <meta property="og:type" content="article">
  <meta property="article:author" content="https://dennisfink.me/about">
  {% if this.publication_date %}
    <meta property="article:published_time"
          content="{{ this.publication_date | dateformat('yyyy-MM-dd') }}"
          data-pagefind-meta="date[content]"
          data-pagefind-sort="date[content]">
  {% endif %}
  {% if latest_change %}
    <meta property="article:modified_time"
          content="{{ latest_change.date | dateformat('yyyy-MM-dd') }}">
  {% endif %}
  {% if this.category %}
    {% set category = site.get("/categories/" + this.category) %}
    <meta property="article:section"
          content="{{ category.name }}"
          data-pagefind-filter="category[content]">
  {% endif %}
  {% for t in this.tags %}
    <meta property="article:tag"
          content="{{ t }}"
          data-pagefind-filter="tag[content]">
  {% endfor %}
{% endblock %}

{% block json_ld %}
  {{ super() }}
  {% include "includes/blog-json-ld.html" %}
  {% if this.publication_date %}
    {% set post_url = this | url(absolute=True, external=True) %}
    {% set post_id = post_url ~ '#blogposting' %}
    {% set person_url = '/about' | url(absolute=True, external=True) %}
    {% set person_id = person_url ~ '#person' %}
    {% set blog_url = '/blog' | url(absolute=True, external=True) %}
    {% set blog_id = blog_url ~ '#blog' %}
    {% set modified_date = this.publication_date %}
    {% if latest_change %}
      {% set modified_date = latest_change.date %}
    {% endif %}
    {% set post_description = bag('blog.tagline') %}
    {% if this.description %}
      {% set post_description = this.description %}
    {% endif %}
    {% if this.category %}
      {% set category = site.get("/categories/" + this.category).name %}
    {% endif %}

    <script type="application/ld+json">
      {
        "@context": "https://schema.org",
        "@type": "BlogPosting",
        "@id": "{{ post_id }}",
        "mainEntityOfPage": "{{ post_url }}",
        "url": "{{ post_url }}",
        "isPartOf": {
          "@id": "{{ blog_id }}"
        },
        "headline": {{ this.title | tojson }},
        "name": {{ this.title | tojson }},
        "description": {{ post_description | tojson }},
        "datePublished": "{{ this.publication_date | dateformat('yyyy-MM-dd') }}",
        "dateModified": "{{ modified_date | dateformat('yyyy-MM-dd') }}",
        "inLanguage": "en",
        "author": {
          "@id": "{{ person_id }}"
        },
        "publisher": {
          "@id": "{{ person_id }}"
        },
        "keywords": {{ this.tags | join(', ') | tojson }},
        "articleSection": {{ category | tojson }}
      }
    </script>
  {% endif %}
{% endblock %}

{% block content %}
  {{ render_blog_post(this) }}
  {% set siblings = this.get_siblings() %}
  {% if siblings.next_page or siblings.prev_page %}
    <nav aria-label="Post navigation" data-pagefind-ignore>
      {% if siblings.next_page %}
        <a href="{{ siblings.next_page | url }}" rel="prev">
          <small>← Previous post</small>
          <span>{{ siblings.next_page.title }}</span>
        </a>
      {% endif %}
      {% if siblings.prev_page %}
        <a href="{{ siblings.prev_page | url }}" rel="next">
          <small>Next post →</small>
          <span>{{ siblings.prev_page.title }}</span>
        </a>
      {% endif %}
    </nav>
  {% endif %}
{% endblock %}