Skip to content

Commit e0f1e3f

Browse files
committedJun 5, 2020
Add users.
1 parent 68d40df commit e0f1e3f

File tree

13 files changed

+36
-11
lines changed

13 files changed

+36
-11
lines changed
 

‎.eleventy.js

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ module.exports = function(eleventyConfig) {
4747
return url.pathname.replace(/\/+$/, '');
4848
});
4949

50+
// Get post author by ID.
51+
eleventyConfig.addFilter('thisPostAuthor', (array, ID) => {
52+
return array.filter( user => {
53+
return user.id === ID;
54+
});
55+
});
56+
5057
// Get post comments by ID.
5158
eleventyConfig.addFilter('thisPostComments', (array, ID) => {
5259
return array.filter( item => {

‎src/css/main.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
@import "objects/animations.css";
5050
@import "objects/flow-spacing.css";
5151
@import "objects/helpers.css";
52+
@import "objects/icon.css";
5253
@import "objects/layouts.css";
5354
@import "objects/max-widths.css";
54-
@import "objects/svg.css";
5555

5656

5757
/*--------------------------------------------------------------

‎src/css/objects/svg.css ‎src/css/objects/icon.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.svg,
1+
.icon,
22
.wp-social-link svg {
33
display: inline-block;
44
fill: currentColor;

‎src/css/utilities/spacing.css

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
margin-bottom: var(--spacing-4x);
4343
}
4444

45+
.mr-4 {
46+
margin-right: var(--spacing-4x);
47+
}
48+
4549
.mt-0 {
4650
margin-top: 0;
4751
}

‎src/site/_data/icon.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"calendar": "<svg class='icon icon--user' aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path d='M400 64h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zm-6 400H54c-3.3 0-6-2.7-6-6V160h352v298c0 3.3-2.7 6-6 6z'/></svg>",
3+
"user": "<svg class='icon icon--user' aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><path d='M313.6 304c-28.7 0-42.5 16-89.6 16-47.1 0-60.8-16-89.6-16C60.2 304 0 364.2 0 438.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-25.6c0-74.2-60.2-134.4-134.4-134.4zM400 464H48v-25.6c0-47.6 38.8-86.4 86.4-86.4 14.6 0 38.3 16 89.6 16 51.7 0 74.9-16 89.6-16 47.6 0 86.4 38.8 86.4 86.4V464zM224 288c79.5 0 144-64.5 144-144S303.5 0 224 0 80 64.5 80 144s64.5 144 144 144zm0-240c52.9 0 96 43.1 96 96s-43.1 96-96 96-96-43.1-96-96 43.1-96 96-96z'/></svg>"
4+
}

‎src/site/_data/users.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const fetchData = require('../helpers/fetchData.js');
2+
3+
const endPoint = 'https://11ty.foxnet.fi/wp-json/wp/v2/users?per_page=10';
4+
5+
module.exports = async function fetchPages() {
6+
return fetchData('users', endPoint);
7+
};

‎src/site/_datacache/categories

+1-1
Large diffs are not rendered by default.

‎src/site/_datacache/comments

+1-1
Large diffs are not rendered by default.

‎src/site/_datacache/pages

+1-1
Large diffs are not rendered by default.

‎src/site/_datacache/posts

+1-1
Large diffs are not rendered by default.

‎src/site/_datacache/tags

+1-1
Large diffs are not rendered by default.

‎src/site/_datacache/users

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"2020-6-5":"1"},["2"],{"id":1,"name":"3","url":"4","description":"4","link":"5","slug":"6","avatar_urls":"7","meta":"8","_links":"9"},"Sami Keijonen","","https://11ty.foxnet.fi/author/sekeijon/","sekeijon",{"24":"10","48":"11","96":"12"},[],{"self":"13","collection":"14"},"https://secure.gravatar.com/avatar/5dd1cbc606af93bd2132ae5c6983e2b6?s=24&d=mm&r=g","https://secure.gravatar.com/avatar/5dd1cbc606af93bd2132ae5c6983e2b6?s=48&d=mm&r=g","https://secure.gravatar.com/avatar/5dd1cbc606af93bd2132ae5c6983e2b6?s=96&d=mm&r=g",["15"],["16"],{"href":"17"},{"href":"18"},"https://11ty.foxnet.fi/wp-json/wp/v2/users/1","https://11ty.foxnet.fi/wp-json/wp/v2/users"]

‎src/site/entries/blogposts.njk

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ permalink: blog/{{ blogpost.slug }}/index.html
1111
{% set title = blogpost.title.rendered %}
1212
{% set commentStatus = blogpost.comment_status %}
1313
{% set id = blogpost.id %}
14+
{% set author = users | thisPostAuthor(blogpost.author) %}
1415

1516
{% block byline %}
16-
<span class="entry__byline">
17-
<svg class="svg" aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M148 288h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm108-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 96v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96-260v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V112c0-26.5 21.5-48 48-48h48V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h128V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h48c26.5 0 48 21.5 48 48zm-48 346V160H48v298c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z"></path></svg>
18-
<time class="entry__date" datetime="{{ blogpost.date | htmlDateString }}">{{ blogpost.date | readableDate }}</time>
19-
</span>
17+
<p class="entry__byline mb-0">
18+
{{ icon.calendar | safe }}
19+
<time class="entry__date mr-4" datetime="{{ blogpost.date | htmlDateString }}">{{ blogpost.date | readableDate }}</time>
20+
{{ icon.user | safe }} <span class="screen-reader-text">Written by</span> {{ author[0].name }}
21+
</p>
2022
{% endblock %}
2123

2224
{% block pageTitle %}

0 commit comments

Comments
 (0)
Please sign in to comment.