feat(article): added microdata to the article.

MR !7
This commit is contained in:
2022-01-31 13:04:14 +09:30
parent b9529feaba
commit 3ef36f49e8
4 changed files with 46 additions and 14 deletions

View File

@ -1,8 +1,27 @@
{% extends "base.html" %}
{% block content %}
<h1>{{ page.title }}</h1>
{% include "partials/article_metadata.html" %}
<hr>
{{ page.content }}
<span itemscope itemtype="https://schema.org/CreativeWork">
{% if page.meta.type == "blog" %}
<span itemprop="hasPart" itemscope itemtype="https://schema.org/BlogPosting">
{% elif page.meta.type == "article" %}
<span itemprop="hasPart" itemscope itemtype="https://schema.org/Article">
{% endif %}
<h1 itemprop="name">{{ page.title }}</h1>
{% include "partials/article_metadata.html" %}
<hr>
<span itemprop="text">{{ page.content }}</span>
<span itemprop="publisher" itemscope itemtype="https://schema.org/Organization" style="font-size: 10px;">
Published by: <span itemprop="name">{{ config.site_name }}</span>, <span itemprop="url">{{ config.site_url }}</span>
</span>
{% if page.meta.copyrightHolder %}
<br>
<span itemprop="copyrightHolder" itemscope itemtype="https://schema.org/Person" style="font-size: 10px;">
Copyright <span itemprop="name">{{ page.meta.copyrightHolder }}</span>
</span>
{% endif %}
{% if page.meta.type %}</span>{% endif %}
</span>
{% endblock %}

View File

@ -9,9 +9,14 @@
{{ article_posts.append( page ) or "" }}
{% endif %}
{% endfor %}
<span itemscope itemtype="https://schema.org/CreativeWork">
{% for page in (article_posts|sort(attribute="meta.date", reverse=True))[:config.extra.blog.list_length] %}
<h2><a href="{{ page.url|url }}">{{ page.title }}</a></h2>
{% if page.meta.type == "blog" %}
<span itemprop="hasPart" itemscope itemtype="https://schema.org/BlogPosting">
{% elif page.meta.type == "article" %}
<span itemprop="hasPart" itemscope itemtype="https://schema.org/Article">
{% endif %}
<h2 itemprop="name"><a href="{{ page.url|url }}" itemprop="url">{{ page.title }}</a></h2>
<hr>
{% include "partials/article_metadata.html" %}
<p>
@ -27,5 +32,7 @@
<hr>
</a>
{% endif %}
{% if page.meta.type %}</span>{% endif %}
{% endfor %}
</span>
{% endblock %}

View File

@ -13,11 +13,17 @@
<div class="container">
<div class="row" >
<div itemprop="hasPart" itemscope itemtype="https://schema.org/Blog" class="column">
<div itemprop="hasPart" itemscope itemtype="https://schema.org/CreativeWork" class="column">
<a itemprop="url" href="articles/index.html"><h2 itemprop="name">Articles</h2></a>
<ul>
{% for page in (article_posts|sort(attribute="meta.date", reverse=True))[:config.extra.blog.list_length] %}
<li itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
{% if page.meta.type == "blog" %}
<li itemprop="hasPart" itemscope itemtype="https://schema.org/BlogPosting">
{% elif page.meta.type == "article" %}
<li itemprop="hasPart" itemscope itemtype="https://schema.org/Article">
{% else %}
<li>
{% endif %}
<p>
<h3><a itemprop="url" href="{{ page.url|url }}"><span itemprop="name">{{ page.title }}</span></a></h3>
<aside class="mdx-author">

View File

@ -5,9 +5,9 @@
</p>
{% endif %}
<p>
<span>
<span itemprop="author" itemscope itemtype="https://schema.org/Person">
{% if config.extra.blog.author %}
<strong>{{ config.extra.blog.author }}</strong>
<strong itemprop="name">{{ config.extra.blog.author }}</strong>
·
{% endif %}
{% include "partials/article_social.html" %}
@ -16,17 +16,17 @@
<span class="twemoji">
{% include ".icons/octicons/calendar-24.svg" %}
</span>
{{ page.meta.date.strftime("%Y-%m-%d") }} ·
{% if page.meta.git_revision_date_localized %}Updated {{ page.meta.git_revision_date_localized.replace("\n", "").replace("\r", "") }} <br>{% endif %}
<span itemprop="dateCreated">{{ page.meta.date.strftime("%Y-%m-%d") }}</span> ·
{% if page.meta.git_revision_date_localized %}Updated <span itemprop="dateModified">{{ page.meta.git_revision_date_localized.replace("\n", "").replace("\r", "") }}</span> <br>{% endif %}
<span class="twemoji">
{% include ".icons/octicons/clock-24.svg" %}
</span>
</span>
<!--Min reading time is 1 minute-->
{% set read_time = page.content | wordcount // config.extra.blog.words_read_per_minute|default(300, true) %}
{% if read_time == 0 %}
{% set read_time = 1 %}
{% endif %}
{{ read_time }} min read
<span itemprop="timeRequired">{{ read_time }} min </span>read
</span>
</p>
</aside>