+ special "unpublished" maturity level for Jekyll drafts

+ maturity labels are always bold
+ maturity.html can now filter what levels to render
This commit is contained in:
nicobo 2020-04-01 22:47:49 +02:00
parent 3f51d4135c
commit efc6e25043
No known key found for this signature in database
GPG key ID: 2581E71C5FA5285F
3 changed files with 40 additions and 4 deletions

View file

@ -1 +1,22 @@
<a href="{{ '/2016/Migrating-from-Drupal-to-Jekyll' | prepend: site.baseurl }}" title="Maturity of this article : draft > good > stable > deprecated&#xa;Click for the explanation.">Maturity : <span class="maturity-label maturity-{{ page.maturity }}">{{ page.maturity }}</span></a>
{% comment %}
'post' must be defined before including this template.
'show' may be defined before including this template : it should be a comma-separated list of the only maturity levels to render (others are simply not rendered).
If 'post.maturity' is not defined, this produces nothing, except for Jekyll drafts (see below).
If 'post' is a Jekyll draft, a special maturity of 'unpublished' is applied.
{% endcomment %}
{% if include.post %}
{% assign dir = include.post.path | split: "/" | first %}
{% if dir == "_drafts" %}
{% assign maturity = "unpublished" %}
{% else %}
{% assign maturity = include.post.maturity %}
{% endif %}
{% if include.show %}
{% assign show = include.show | split: "," %}
{% else %}
{% assign show = "unpublished,draft,good,stable,deprecated" | split: "," %}
{% endif %}
{% if show contains maturity %}
<span class="maturity-label maturity-{{ maturity }}" title="Maturity of this article : draft < good < stable or deprecated">{{ maturity }}</span>
{% endif %}
{% endif %}

View file

@ -17,9 +17,7 @@ layout: default
<span class="post-meta-separator"></span> by <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>
{% endif %}
<span class="post-meta-separator"></span> <span itemprop="read_time">{% include read_time.html %}</span>
{% if page.maturity %}
<span class="post-meta-separator"></span> <span itemprop="maturity">{% include maturity.html %}</span>
{% endif %}
<span class="post-meta-separator"></span> <span itemprop="maturity"><a href="{{ '/2016/Migrating-from-Drupal-to-Jekyll' | prepend: site.baseurl }}" title="Maturity of this article : draft < good < stable or deprecated&#xa;Click for the explanation.">Maturity : {% include maturity.html post=page %}</span></a>
</p>
</header>
<div class="post-content" itemprop="articleBody">

View file

@ -2,10 +2,12 @@ $maturity-draft-color: #f03;
$maturity-good-color: #f6f;
$maturity-stable-color: $secondary-color;
$maturity-deprecated-color: #AA8;
$maturity-unpublished-color: #30f;
/* A tag/label-like decoration to indicate the level of maturity of an article */
.maturity-label {
color: white;
font-weight: bold;
padding-left: 0.2em;
padding-right: 0.2em;
-webkit-border-radius: 5px;
@ -13,6 +15,21 @@ $maturity-deprecated-color: #AA8;
border-radius: 5px;
text-decoration: none;
}
/* When a maturity label is next to a post preview */
/* TODO ? Should go to layout.scss ? */
.post-item {
.maturity-label {
margin-left: 1em;
font-size: .8em;
}
}
/* The draft feature of Jekyll (articles in the _draft directory) */
.maturity-unpublished {
background: $maturity-unpublished-color;
}
/* When an article is just started or has a lot of issues and therefore that I don't endorse yet but thay may still be published if it has interesting content */
.maturity-draft {
background: $maturity-draft-color;