Remove potential whitespaces through Liquid tags

This commit is contained in:
foo-dogsquared 2018-10-29 11:44:13 +08:00
parent 05c8a73839
commit e2f458cf04
4 changed files with 54 additions and 46 deletions

View File

@ -1,18 +1,18 @@
<ul class="pinned-posts"> <ul class="pinned-posts">
{% for posts in site.posts %} {%- for posts in site.posts -%}
{% for post in site.pinpost %} {%- for post in site.pinpost -%}
{% if posts.title == post %} {%- if posts.title == post -%}
<li style="margin-bottom: 1em"> <li style="margin-bottom: 1em">
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%} {%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
<span class="post-meta" title="{{ posts.date }}">{{ posts.date | date: date_format }}</span>
<h3 style="margin:0"> <h3 style="margin:0">
<a class="post-link" href="{{ posts.url | relative_url }}"> <a class="post-link" href="{{ posts.url | relative_url }}">
{{ posts.title | escape }} {{ posts.title | escape }}
</a> </a>
</h3> </h3>
{% endif %} {%- include post_meta.html page=posts include_link=true -%}
</li> </li>
{% endfor %} {%- endif -%}
{% endfor %} {%- endfor -%}
{%- endfor -%}
</ul> </ul>

View File

@ -7,12 +7,14 @@
<span title="{{ page.date }}">{{ page.date | date: date_format }}</span> <span title="{{ page.date }}">{{ page.date | date: date_format }}</span>
</time> </time>
<span class="reading-minutes" style="margin-left: 1.25em"> <span class="reading-minutes">
<img src="{{ 'assets/main/icons/time-clock.svg' | relative_url }}" class="post-meta-icons"><span class="no-of-mins">{{ page.content | number_of_words | divided_by: 225 }}</span> minutes <img src="{{ 'assets/main/icons/time-clock.svg' | relative_url }}" class="post-meta-icons">
{%- assign wpm = page.content | number_of_words | divided_by: 225 -%}{%- if wpm <= 0 -%}1{%- else -%}{{ wpm }}{%- endif -%}
<span> minute{%- if wpm > 1 -%}s{%- endif -%}</span>
</span> </span>
{%- if page.categories -%} {%- if page.categories -%}
<span class="post-category" style="margin-left: 1.25em"> <span class="post-category">
<img src="{{ 'assets/main/icons/categories.svg' | relative_url }}" class="post-meta-icons"> <img src="{{ 'assets/main/icons/categories.svg' | relative_url }}" class="post-meta-icons">
{%- if include_link -%}<a href="{{ site.baseurl }}/data/categories#{{ page.categories }}">{{ page.categories }}</a> {%- if include_link -%}<a href="{{ site.baseurl }}/data/categories#{{ page.categories }}">{{ page.categories }}</a>
{%- else -%}<span>{{ page.categories }}</span>{%- endif -%} {%- else -%}<span>{{ page.categories }}</span>{%- endif -%}
@ -20,6 +22,8 @@
{%- endif -%} {%- endif -%}
{%- if page.updatedOn -%} {%- if page.updatedOn -%}
<p class="dt-updated">Updated: <span>{{ page.updatedOn | escape }}</span></p> <span class="dt-updated">
<img src="{{ 'assets/main/icons/update.svg' | relative_url }}" class="post-meta-icons"><span>{{ page.updatedOn | escape }}</span>
</span>
{%- endif -%} {%- endif -%}
</p> </p>

View File

@ -2,6 +2,10 @@
layout: default layout: default
--- ---
{%- if page.title -%}
<h1>{{ page.title }}</h1>
{%- endif -%}
{%- if content -%} {%- if content -%}
{{ content }} {{ content }}
{%- endif -%} {%- endif -%}
@ -11,36 +15,36 @@ layout: default
https://codinfox.github.io/dev/2015/03/06/use-tags-and-categories-in-your-jekyll-based-github-pages/ https://codinfox.github.io/dev/2015/03/06/use-tags-and-categories-in-your-jekyll-based-github-pages/
--> -->
{%- if page.data -%} {%- if page.data -%}
{% assign page_data = page.data %} {%- assign page_data = page.data -%}
{% assign rawdata = "" %} {%- assign rawdata = "" -%}
{% for post in site.posts %} {%- for post in site.posts -%}
{% assign tdata = post[page_data] | join:'|' | append:'|' %} {%- assign tdata = post[page_data] | join:'|' | append:'|' -%}
{% assign rawdata = rawdata | append:tdata %} {%- assign rawdata = rawdata | append:tdata -%}
{% endfor %} {%- endfor -%}
{% assign rawdata = rawdata | split:'|' | sort %} {%- assign rawdata = rawdata | split:'|' | sort -%}
{% assign data = "" %} {%- assign data = "" -%}
{% for datum in rawdata %} {%- for datum in rawdata -%}
{% if datum != "" %} {%- if datum != "" -%}
{% if data == "" %} {%- if data == "" -%}
{% assign data = datum | split:'|' %} {% assign data = datum | split:'|' -%}
{% endif %} {%- endif -%}
{% unless data contains datum %} {%- unless data contains datum -%}
{% assign data = data | join:'|' | append:'|' | append:datum | split:'|' %} {%- assign data = data | join:'|' | append:'|' | append:datum | split:'|' -%}
{% endunless %} {%- endunless -%}
{% endif %} {%- endif -%}
{% endfor %} {%- endfor -%}
<div class="keyword__grid"> <div class="keyword__grid">
{% for datum in data %}<a class="keywords" href="#{{ datum | slugify }}"> {{ datum }} </a>{% endfor %} {%- for datum in data -%}<a class="keywords" href="#{{ datum | slugify }}"> {{ datum }} </a>{%- endfor -%}
</div> </div>
{% for datum in data %} {%- for datum in data -%}
<div class="datum__post_list"> <div class="datum__post_list">
<h2 id="{{ datum | slugify }}">{{ datum }}</h2> <h2 id="{{ datum | slugify }}">{{ datum }}</h2>
<ul> <ul>
{% for post in site.posts %} {%- for post in site.posts -%}
{% if post[page_data] contains datum %} {%- if post[page_data] contains datum -%}
<li> <li>
<h3> <h3>
<a href="{{site.url}}{{site.baseurl}}{{ post.url }}"> <a href="{{site.url}}{{site.baseurl}}{{ post.url }}">
@ -49,9 +53,9 @@ layout: default
<small>{{ post.date | date_to_string }}</small> <small>{{ post.date | date_to_string }}</small>
</h3> </h3>
</li> </li>
{% endif %} {%- endif -%}
{% endfor %} {%- endfor -%}
</ul> </ul>
</div> </div>
{% endfor %} {%- endfor -%}
{%- endif -%} {%- endif -%}

View File

@ -9,37 +9,37 @@ layout: default
{{ content }} {{ content }}
{% if site.pinpost %} {%- if site.pinpost -%}
<section id="pinned-section"> <section id="pinned-section">
<h3>Pinned Posts:</h3> <h3>Pinned Posts:</h3>
{%- include pinpost.html -%} {%- include pinpost.html -%}
</section> </section>
{% endif %} {%- endif -%}
{%- if site.posts.size > 0 -%} {%- if site.posts.size > 0 -%}
<h2 class="post-list-heading">{{ page.list_title | default: "Posts" }}</h2> <h2 class="post-list-heading">{{ page.list_title | default: "Posts" }}</h2>
<!-- Pagination links --> <!-- Pagination links -->
{% for post in paginator.posts %} {%- for post in paginator.posts -%}
<div class="home-post"> <div class="home-post">
<h2><a href="{{ post.url | relative_url }}" class="post-link">{{ post.title }}</a></h2> <h2><a href="{{ post.url | relative_url }}" class="post-link">{{ post.title }}</a></h2>
{%- include post_meta.html page=post include_link=true -%} {%- include post_meta.html page=post include_link=true -%}
</div> </div>
{% endfor %} {%- endfor -%}
<!-- Pagination links --> <!-- Pagination links -->
<div class="pagination"> <div class="pagination">
{% if paginator.previous_page %} {%- if paginator.previous_page -%}
<a href="{{ paginator.previous_page_path | relative_url }}" class="previous">Previous</a> <a href="{{ paginator.previous_page_path | relative_url }}" class="previous">Previous</a>
{% else %} {%- else -%}
<span class="previous disabled">Previous</span> <span class="previous disabled">Previous</span>
{% endif %} {%- endif -%}
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span> <span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
{% if paginator.next_page %} {%- if paginator.next_page -%}
<a href="{{ paginator.next_page_path | relative_url }}" class="next">Next</a> <a href="{{ paginator.next_page_path | relative_url }}" class="next">Next</a>
{% else %} {%- else -%}
<span class="next disabled">Next</span> <span class="next disabled">Next</span>
{% endif %} {%- endif -%}
</div> </div>
<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p> <p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>