Skip to content

Commit

Permalink
#14 add author pages
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMit committed Sep 2, 2019
1 parent 7692c90 commit b81aa6e
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 6 deletions.
24 changes: 24 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addFilter("take", (array, n) => array.slice(0,n));


// custom collections
eleventyConfig.addCollection("authors", function(collection) {
var authors = collection.items[0].data.authorlist.map(author => {
var allPosts = collection.getAll()
var authorName = author.name
var authorPosts = allPosts.filter(col => col.data.authors && col.data.authors.includes(authorName))
return {
name: authorName,
posts: authorPosts
}
})
let object = {};

for (let item of authors) {
// destructure to split up name and everything else
let {name, posts} = item
object[name] = posts;
}


return object;
});


// set markdown defaults (inline so we can extend)
let markdownIt = require("markdown-it");
let options = {
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"Sharepoint",
"ahsfiles",
"aspnet",
"destructure",
"frontmatter",
"lifecycle",
"linkify",
Expand All @@ -36,6 +37,7 @@
"signup",
"slugify",
"taglist",
"vdhwebapps"
"vdhwebapps",
"walkthroughs"
]
}
5 changes: 5 additions & 0 deletions src/_data/authorlist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{"name": "Kyle", "description": "Likes .NET Development, JavaScript, and Cats"},
{"name": "Brian", "description": "Automation champion, pottery hobbyist, and volleyball enthusiast"},
{"name": "Sandra", "description": "Swiss army knife developer, and early morning script powerhouse"}
]
2 changes: 1 addition & 1 deletion src/_data/taglist.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{"name": "workforce", "description": "For posts about workforce development, onboarding, hiring, training, and managing professional talent"},
{"name": "overview", "description": "An overview of products, services, technologies, or domain specific knowledge"},
{"name": "team", "description": "Posts relating to a particular team, and their internal structure, prioritization, and process management"},
{"name": "how-to", "description": "Step by step instructions on how to install an application, configure your machine, or any other walk-throughs"},
{"name": "how-to", "description": "Step by step instructions on how to install an application, configure your machine, or any other walkthroughs"},
{"name": "process", "description": "Detailing our current process workflows for planning, prioritizing, development, and maintenance"}
]
9 changes: 9 additions & 0 deletions src/_includes/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,15 @@ a.tag-badge::before {
padding: 0px 5px;
}

/* authors */
.author-description {
margin-bottom: 1.5rem;
}
.author a {
font-weight: bold;
font-size: 1.2em;
}

/* media queries */
@media (max-width: 500px) {
.brand {
Expand Down
19 changes: 19 additions & 0 deletions src/authors-list.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
layout: default.njk
title_word: Authors
title: Authors
permalink: /authors/index.html
---

<h1 class="page-title">Author list</h1>

<ol class="authorlist list-unstyled">
{% for author in authorlist | sort(false, false, "name") %}
{% set tagCount = collections.authors[author.name].length %}
<li class="author">
<a href="/authors/{{author.name}}">{{ author.name }}</a>
<span class="tag-count"{{tagCount}}</span>
<div class="author-description">{{ author.description }}</div>
</li>
{% endfor %}
</ol>
23 changes: 23 additions & 0 deletions src/authors.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
layout: default.njk
pagination:
data: authorlist
size: 1
alias: author
permalink: /authors/{{ author.name }}/
renderData:
title: Posts from {{ author.name }}
title_word: '{{author.name}}'
---

<h2><a href="/authors/"> {% include "images/icons/arrow-left.svg" %} All Authors</a></h2>

<h1 class="page-title">Posts from {{ author.name }}</h1>

<section class="intro">
{{ author.description }}
</section>


{% set postList = collections.authors[author.name] %}
{% include "_partials/postList.njk" %}
4 changes: 2 additions & 2 deletions src/tags-list.njk
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
layout: default.njk
title_word: Taxonomy
title_word: Tags
title: Tag list
permalink: /tags/index.html
---

<h1>Tag list</h1>
<h1 class="page-title">Tag list</h1>

<ol class="taglist">
{% for tag in taglist | sort(false, false, "name") %}
Expand Down
2 changes: 0 additions & 2 deletions src/tags.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ renderData:
title: Tagged "{{ tag.name }}"
title_word: '{{tag.name}}'
---
{% set title = "Tagged" + tag.name %}

<h2><a href="/tags/"> {% include "images/icons/arrow-left.svg" %} All Tags</a></h2>

<h1>Tagged “{{ tag.name }}”</h1>
Expand Down

0 comments on commit b81aa6e

Please sign in to comment.