Skip to content

Commit

Permalink
Layout and config file updates
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcanhelp committed Feb 3, 2020
1 parent 34db0fd commit 6c4a0b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = function(eleventyConfig) {

const postLayouts = [ 'post', 'link', 'quote', 'gallery', 'status' ];

eleventyConfig.addLayoutAlias('gallery', 'layouts/gallery.njk');
eleventyConfig.addLayoutAlias('link', 'layouts/link.njk');
eleventyConfig.addLayoutAlias('page', 'layouts/page.njk');
Expand All @@ -9,6 +11,13 @@ module.exports = function(eleventyConfig) {

eleventyConfig.setUseGitIgnore(false);

eleventyConfig.addCollection('postsCollection', function(collection) {
const tmpCollection = collection.getAllSorted();
return tmpCollection.reverse().filter(function(tpl) {
if ( tpl.data.permalink && postLayouts.includes(tpl.data.layout) ) return tpl;
});
});

return {
dir: {
input: "content",
Expand Down
11 changes: 5 additions & 6 deletions content/_includes/layouts/all.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
<main>
{{ content | safe }}
<ul>
{%- for post in collections.all | reverse -%}
{%- if post.data.layout in [ 'post', 'link', 'quote', 'gallery', 'status' ] -%}
{%- if post.data.permalink -%}
{%- for post in collections.postsCollection -%}
<li>
<a href="{{ post.url | safe }}">{{ post.data.title | safe }}</a><br>
<em>{{ post.date }}</em> {{ post.data.excerpt | safe }}
<em>{{ post.date }}</em> {{ post.data.excerpt | safe }}<br>
{%- if post.data.featured_img -%}
<img src="{{ post.data.featured_img | safe }}">
{%- endif -%}
</li>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
</ul>
</main>
Expand Down

0 comments on commit 6c4a0b1

Please sign in to comment.