start of eleventy-base-blog that pairs with 0.2.8

This commit is contained in:
Zach Leatherman
2018-01-22 08:17:48 -06:00
parent 283df5ef4c
commit b9c0d87306
13 changed files with 193 additions and 87 deletions

View File

@ -3,24 +3,28 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title>
<title>{{ title or metadata.title }}</title>
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/posts/posts.css">
<link rel="alternate" href="/feed/" type="application/atom+xml" title="{{ title }}">
</head>
<body>
<header>
<a href="/"><img src="/img/logo.png" class="logo"></a>
<h1 class="home"><a href="/">{{ metadata.title }}</a></h1>
<ul class="nav">
{%- for nav in collections.nav | reverse -%}
<li class="nav-item"><a href="{{ nav.url | url }}">{{ nav.data.navtitle }}</a></li>
<li class="nav-item{% if nav.url == page.url %} nav-item-active{% endif %}"><a href="{{ nav.url | url }}">{{ nav.data.navtitle }}</a></li>
{%- endfor -%}
</ul>
</header>
{{ layoutContent | safe }}
<main>
{{ layoutContent | safe }}
</main>
<footer>
<p><em>Current page: <code>{{ page.url | url }}</code></em></p>
</footer>
<!-- Current page: {{ page.url | url }} -->
</body>
</html>

View File

@ -2,6 +2,4 @@
layout: layouts/base.njk
templateClass: tmpl-home
---
<h1>My Blog</h1>
{{ layoutContent | safe }}

View File

@ -5,8 +5,3 @@ templateClass: tmpl-post
<h1>{{ title }}</h1>
{{ layoutContent | safe }}
<h2>Posts: </h2>
{% import "postlist.njk" as postsm %}
{{ postsm.list(collections.post, page.url) }}

View File

@ -1,13 +0,0 @@
{% macro list(posts, url) %}
<ul>
{%- for post in posts -%}
<li{% if post.url == url %} class="post-active"{% endif %}>
<a href="{{ post.url | url }}">{{ post.data.title }}</a>
Tags: {{ post.data.tags | join(", ") }}
{%- if post.url == url %}
(You are here)
{% endif -%}
</li>
{%- endfor -%}
</ul>
{% endmacro %}

9
_includes/postslist.njk Normal file
View File

@ -0,0 +1,9 @@
<ol class="postlist" style="counter-reset: start-from {{ postslist.length + 1 }}">
{% for post in postslist | reverse %}
<li class="postlist-item{% if post.url == url %} postlist-item-active{% endif %}">
<a href="{{ post.url | url }}" class="postlist-link">{{ post.data.title }}</a>
<span class="postlist-date">{{ post.date | readableDate }}</span>
{% for tag in post.data.tags %}{% if tag != "post" %}<span class="tag">{{ tag }}</span>{% endif %}{% endfor %}
</li>
{% endfor %}
</ol>