move cmd to nunjucks & update hexo to 6.0.0
Other changes: * minor fix to the display for code blocks * remove floating when hover on cards * replace the list of tags and categories to the index page one * small change on the title of tags' and categories' pages
This commit is contained in:
parent
4abb723445
commit
781759d545
23 changed files with 440 additions and 547 deletions
24
themes/cmd/layout/includes/cards.njk
Normal file
24
themes/cmd/layout/includes/cards.njk
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
|
||||
{% macro Me(name, email, description) %}
|
||||
<div class="card">
|
||||
<div class="row" style="margin-bottom: 0">
|
||||
<div class="col" style="padding: 12px; padding-left: 20px;">
|
||||
<img class="circle responsive-img" src="{{ gravatar(email if email else 'example@foo.bar') }}"/>
|
||||
</div>
|
||||
<div class="col" style="padding-top: 12px; padding-left: 12px">
|
||||
{% if name %}
|
||||
<div class="row" style="margin-bottom: 0">
|
||||
<h6>{{ name }}</h6>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row" style="margin-bottom: 0">
|
||||
<p>
|
||||
{% if description %}
|
||||
{{ description }}{% else %}Nothing to say.{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
132
themes/cmd/layout/includes/layout.njk
Normal file
132
themes/cmd/layout/includes/layout.njk
Normal file
|
@ -0,0 +1,132 @@
|
|||
{% set pageTitle = page.title or config.subtitle or '' %}
|
||||
|
||||
{% if is_archive() %}
|
||||
{% set pageTitle = 'Archives' %}
|
||||
{% elif is_tag() %}
|
||||
{% set pageTitle = 'Tag: ' + page.tag %}
|
||||
{% elif is_category() %}
|
||||
{% set pageTitle = 'Category: ' + page.category %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_month() %}
|
||||
{% set pageTitle = pageTitle + ': ' + page.month + '/' + page.year %}
|
||||
{% elif is_year() %}
|
||||
{% set pageTitle = pageTitle + ': ' + page.year %}
|
||||
{% endif %}
|
||||
|
||||
{% if pageTitle == '' %}
|
||||
{% set pageTitle = config.title %}
|
||||
{% endif %}
|
||||
|
||||
<!doctype html>
|
||||
<html lang="{{ config.language }}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ pageTitle }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
{% if theme.stylesheets !== undefined and theme.stylesheets.length > 0 %}
|
||||
{# stylesheet list from _config.yml #}
|
||||
{% for url in theme.stylesheets %}
|
||||
<link rel="stylesheet" href="{{ url }}" media="print" onload="this.media='all'; this.onload=null;">
|
||||
<noscript><link rel="stylesheet" href="{{ url }}"></noscript>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="{{url_for('/materialize/css/materialize.css')}}"/>
|
||||
{% block add_head %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ul id="nav-mobile" class="sidenav">
|
||||
{% if site.data.theme.menu %}
|
||||
{% for key, path in site.data.theme.menu %}
|
||||
<li>
|
||||
<a href="{{ path }}">{{ key }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for key, path in theme.menu %}
|
||||
<li>
|
||||
<a href="{{ path }}">{{ key }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
<nav class="light-blue lighten-1" role="navigation">
|
||||
<a href="#" data-target="nav-mobile" class="sidenav-trigger">
|
||||
<div class="mdi mdi-menu"></div>
|
||||
</a>
|
||||
<div class="nav-wrapper">
|
||||
<ul class="right hide-on-med-and-down">
|
||||
{% if site.data.theme.menu %}
|
||||
{% for key, path in site.data.theme.menu %}
|
||||
<li>
|
||||
<a href="{{ path }}">{{ key }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for key, path in theme.menu %}
|
||||
<li>
|
||||
<a href="{{ path }}">{{ key }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main id="content" class="container xscontainer">
|
||||
{% block body %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer class="page-footer light-blue darken-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{% if site.data.theme.about_this_blog %}
|
||||
<div class="col s12 m4">
|
||||
<h5 class="white-text">About {{ config.title }}</h5>
|
||||
<p>{{ site.data.theme.about_this_blog }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if site.data.theme.footer_links %}
|
||||
<div class="col s6 m4">
|
||||
<h5 class="white-text">
|
||||
Links
|
||||
</h5>
|
||||
<ul>
|
||||
{% for name, link in site.data.theme.footer_links %}
|
||||
<li>
|
||||
<a class="grey-text text-lighten-3" href="{{ link }}">{{ name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% if theme.my_mastodon %}
|
||||
<li>
|
||||
<a class="grey-text text-lighten-3" rel="me" href="{{ site.data.theme.my_mastodon }}">My Mastodon</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if theme.theme_self_claim %}
|
||||
<div class="col s6 m4">
|
||||
<p>This blog uses Classical Material Design theme.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-copyright">
|
||||
<div class="container truncate">
|
||||
© Copyright {{ site.data.theme.copyright_year_string }}
|
||||
{{ config.author }}.
|
||||
{{ site.data.theme.copyright_addtional }}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
{% if theme.scripts !== undefined and theme.scripts.length > 0 %}
|
||||
{# scripts list from config.yml #}
|
||||
{% for url in theme.scripts %}
|
||||
<script src="{{ url }}"></script>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% block add_scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
|
@ -1,135 +0,0 @@
|
|||
|
||||
{% set pageTitle = page.title || config.subtitle || '' %}
|
||||
|
||||
{% if is_archive() %}
|
||||
{% set pageTitle = 'Archives' %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_tag() %}
|
||||
{% set pageTitle = 'Tag: ' + page.tag %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_category() %}
|
||||
{% set pageTitle = 'Category: ' + page.category %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_month() %}
|
||||
{% set pageTitle = pageTitle + ': ' + page.month + '/' + page.year %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_year() %}
|
||||
{% set pageTitle = pageTitle + ': ' + page.year %}
|
||||
{% endif %}
|
||||
|
||||
{% if pageTitle == '' %}
|
||||
{% set pageTitle = config.title %}
|
||||
{% endif %}
|
||||
|
||||
<!doctype html>
|
||||
<html lang="{{ config.language }}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ pageTitle }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
{% if theme.stylesheets !== undefined && theme.stylesheets.length > 0 %}
|
||||
{# stylesheet list from _config.yml #}
|
||||
{% for url in theme.stylesheets %}
|
||||
<link rel="stylesheet" href="{{ url }}" media="print" onload="this.media='all'; this.onload=null;">
|
||||
<noscript><link rel="stylesheet" href="{{ url }}"></noscript>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="/materialize/css/materialize.css">
|
||||
|
||||
{% if site.data.theme.site_rss %}
|
||||
{% if site.data.theme.site_rss.rss %}
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ config.title }}" href="{{ full_url_for(site.data.theme.site_rss.rss) }}" />
|
||||
{% endif %}
|
||||
{% if site.data.theme.site_rss.atom %}
|
||||
<link rel="alternate" type="application/atom+xml" title="{{ config.title }}" href="{{ full_url_for(site.data.theme.site_rss.atom) }}" />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% block add_head %}{% endblock %}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<ul id="nav-mobile" class="sidenav">
|
||||
{% if site.data.theme.menu %}
|
||||
{% for key in Object.keys(site.data.theme.menu) %}
|
||||
<li><a href="{{ site.data.theme.menu[key] }}">{{ key }}</a></li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for key in Object.keys(theme.menu) %}
|
||||
<li><a href="{{ theme.menu[key] }}">{{ key }}</a></li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
<nav class="light-blue lighten-1" role="navigation">
|
||||
<a href="#" data-target="nav-mobile" class="sidenav-trigger"><div class="mdi mdi-menu"></div></a>
|
||||
<div class="nav-wrapper">
|
||||
<ul class="right hide-on-med-and-down">
|
||||
{% if site.data.theme.menu %}
|
||||
{% for key in Object.keys(site.data.theme.menu) %}
|
||||
<li><a href="{{ site.data.theme.menu[key] }}">{{ key }}</a></li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for key in Object.keys(theme.menu) %}
|
||||
<li><a href="{{ theme.menu[key] }}">{{ key }}</a></li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main id="content" class="container xscontainer">
|
||||
{% block body %}{% endblock %}
|
||||
</main>
|
||||
|
||||
|
||||
<footer class="page-footer light-blue darken-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{% if site.data.theme.about_this_blog %}
|
||||
<div class="col s12 m4">
|
||||
<h5 class="white-text">About {{config.title}}</h5>
|
||||
<p>{{site.data.theme.about_this_blog}}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if site.data.theme.footer_links %}
|
||||
<div class="col s6 m4">
|
||||
<h5 class="white-text"> Links </h5>
|
||||
<ul>
|
||||
{% for name in Object.keys(site.data.theme.footer_links) %}
|
||||
<li><a class="grey-text text-lighten-3" href="{{site.data.theme.footer_links[name]}}">{{name}}</a></li>
|
||||
{% endfor %}
|
||||
{% if theme.my_mastodon %}
|
||||
<li><a class="grey-text text-lighten-3" rel="me" href="{{site.data.theme.my_mastodon}}">My Mastodon</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if theme.theme_self_claim %}
|
||||
<div class="col s6 m4">
|
||||
<p>This blog uses Classical Material Design theme.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-copyright">
|
||||
<div class="container truncate">
|
||||
© Copyright {{ site.data.theme.copyright_year_string }} {{ config.author }}. {{ site.data.theme.copyright_addtional }}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{% if theme.scripts !== undefined && theme.scripts.length > 0 %}
|
||||
{# scripts list from config.yml #}
|
||||
{% for url in theme.scripts %}
|
||||
<script src="{{ url }}"></script>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% block add_scripts %}{% endblock %}
|
||||
|
||||
</body>
|
||||
</html>
|
23
themes/cmd/layout/includes/paginator.njk
Normal file
23
themes/cmd/layout/includes/paginator.njk
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% macro Paginiation() %}
|
||||
<ul class="pagination center">
|
||||
{% if page.prev %}
|
||||
<li class="waves-effect">
|
||||
<a href="{{ page.prev_link }}">
|
||||
<i class="mdi mdi-chevron-left"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for n in range(1, page.total, 1) %}
|
||||
<li class="{{ 'active' if page.current == n else 'waves-effect' }}">
|
||||
<a href="{{ url_for('page/'+n+'/') }}">{{ n }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% if page.next %}
|
||||
<li class="waves-effect">
|
||||
<a href="{{ page.next_link }}">
|
||||
<i class="mdi mdi-chevron-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endmacro %}
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
{% macro Paginiation() %}
|
||||
<ul class="pagination center">
|
||||
<li class="{% if page.current == 1 %}disabled{% else %}waves-effect{% endif %}"><a href="{% if (page.current-1) == 1 %}{{url_for('/')}}{% else %}{{ page.prev_link }}{% endif %}"><i class="mdi mdi-chevron-left"></i></a></li>
|
||||
<li class="{% if page.current == 1 %}active{% else %}waves-effect{% endif %}"><a href="{{ url_for('/') }}">1</a></li>
|
||||
{% for n in range(2, page.total, 1) %}
|
||||
<li class="{% if page.current == n %}active{% else %}waves-effect{% endif %}"><a href="{{ url_for('page/'+n+'/') }}">{{n}}</a></li>
|
||||
{% endfor %}
|
||||
<li class="{% if page.current == page.total %}disabled{% else %}waves-effect{% endif %}"><a href="{{ page.next_link }}"><i class="mdi mdi-chevron-right"></i></a></li>
|
||||
</ul>
|
||||
{% endmacro %}
|
43
themes/cmd/layout/includes/postlist.njk
Normal file
43
themes/cmd/layout/includes/postlist.njk
Normal file
|
@ -0,0 +1,43 @@
|
|||
|
||||
{%from 'includes/tags.njk' import PostTags with context%}
|
||||
|
||||
{% macro PostList(posts) %}
|
||||
<ul class="collection">
|
||||
{% for post in posts %}
|
||||
<li class="collection-item no-padding">
|
||||
<div class="card z-depth-0 card-small-margin">
|
||||
{% if post.photos and post.photos.length > 0 %}
|
||||
<a href="{{ url_for(post.path) }}">
|
||||
<div class="card-image">
|
||||
<img class="responsive-img" src="{{ post.photos[0] }}"/>
|
||||
<span class="card-title">{{ post.title }}</span>
|
||||
</div>
|
||||
</a>
|
||||
{% if (post.tags.length > 0) or post.excerpt != "" %}
|
||||
<div class="card-content">
|
||||
{{ PostTags(post) }}
|
||||
{% if post.excerpt != "" %}
|
||||
<p class="entry">{{ post.excerpt }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="card-content">
|
||||
<a href="{{ post.link if post.link else url_for(post.path) }}" {% if post.link %} target="_blank" {% endif %}>
|
||||
<span class="card-title">
|
||||
{% if (post.title != '' and post.title !== null and post.title !== undefined) %}
|
||||
{{ post.title }}
|
||||
{% else %}
|
||||
{{ post.path }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</a>
|
||||
<p class="entry">{{ post.excerpt }}</p>
|
||||
{{ PostTags(post) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endmacro %}
|
9
themes/cmd/layout/includes/tags.njk
Normal file
9
themes/cmd/layout/includes/tags.njk
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% macro PostTags(post) %}
|
||||
<div>
|
||||
{% for tag in post.tags.data %}
|
||||
<a href="{{ url_for(tag.path) }}"><div class="chip">
|
||||
{{tag.name}}
|
||||
</div></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
|
@ -1,9 +0,0 @@
|
|||
{% macro PostTags(post) %}
|
||||
<div>
|
||||
{% for k in Object.keys(post.tags.data) %}
|
||||
<a href="{{ url_for(post.tags.data[k].path)}}"><div class="chip">
|
||||
{{post.tags.data[k].name}}
|
||||
</div></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
Loading…
Add table
Add a link
Reference in a new issue