Skip to content

Commit

Permalink
Add OpenGraph metadata etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson authored Sep 30, 2021
1 parent a511b8e commit a7cab41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
{{ encore_entry_link_tags('app') }}
{% block stylesheets %}{% endblock %}
<link rel="alternate" type="application/rss+xml" title="RSS" href="{{ path('rss') }}"/>
<meta property="og:site_name" content="{{ settings.siteName }}" />
{% block head %}{% endblock %}
</head>
<body>
<header>
Expand Down
26 changes: 22 additions & 4 deletions templates/post/view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,27 @@
{{ encore_entry_script_tags('map') }}
{% endblock %}

{% block head %}
<meta property="og:type" content="article" />
{% if post.title %}
<meta property="og:title" content="{{ post.title }}" />
{% endif %}
{% if post.url %}
<meta property="og:url" content="{{ post.url }}" />
{% else %}
<meta property="og:url" content="{{ url('post_view', {id:post.id}) }}" />
{% endif %}
{% if post.file %}
<meta property="og:image" content="{{ url('file', {id:post.id, size:'D', ext:'jpg'}) }}" />
{% endif %}
{% for tag in post.tags %}
<meta property="article:tag" content="{{ tag.title }}" />
{% endfor %}
{% endblock %}

{% block body %}

<article class="h-entry">
<article class="h-entry" itemscope itemtype="https://schema.org/CreativeWork">

{% if post.inReplyTo %}
<p>
Expand All @@ -28,15 +46,15 @@
</p>
{% endif %}

<h1 class="p-name">{{ post.title }}</h1>
<p class="meta">
<h1 class="p-name" itemprop="name">{{ post.title }}</h1>
<p class="meta" itemprop="author">
By
{% if post.author.homepage %}<a href="{{ post.author.homepage }}" rel="author" class="p-url">{% endif %}{#
#}<span class="p-name">{{ post.author.name }}</span>{#
#}{% if post.author.homepage %}</a>{% endif %}{#
#}.
<a href="{{ path('month', {year:post.date.format('Y'), month: post.date.format('m') }) }}">
<time datetime="{{ post.date.format('Y-m-d\\TH:i:s\\Z') }}" class="dt-published">
<time datetime="{{ post.date.format('Y-m-d\\TH:i:s\\Z') }}" class="dt-published" itemprop="datePublished">
{{ post.date.format('Y F j (l), g:iA') }}
</time>
</a>
Expand Down

0 comments on commit a7cab41

Please sign in to comment.