File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 11{% assign page = include.page %}
2- {% assign author = site.data.authors[page.author] %}
32
43< h1 >
54{% if include.isPermalink %}
1211< p class ="meta ">
1312 {{ page.date | date: "%B %e, %Y" }}
1413 by
15- {% if author.url %}
16- < a href ="{{author.url}} "> {{ author.name }}</ a >
14+ {% if page. author.url %}
15+ < a href ="{{page. author.url}} "> {{ page. author.name }}</ a >
1716 {% else %}
18- {{ author.name }}
17+ {{ page. author.name }}
1918 {% endif %}
2019</ p >
2120
Original file line number Diff line number Diff line change 1+ # This transforms the data associated with each post, specifically the author.
2+ # We store our author information in a yaml file and specify the keys in The
3+ # post front matter. Instead of looking up the complete data each time we need
4+ # it, we'll just look it up here and assign. This plays nicely with tools like
5+ # jekyll-feed which expect post.author to be in a specific format.
6+ module Authors
7+ class Generator < Jekyll ::Generator
8+ def generate ( site )
9+ site . posts . each do |post |
10+ post . data [ 'author' ] = site . data [ 'authors' ] [ post [ 'author' ] ]
11+ end
12+ end
13+ end
14+ end
Original file line number Diff line number Diff line change 99 < div class ="inner-content ">
1010 < h1 > All Posts</ h1 >
1111 {% for page in site.posts %}
12- {% assign author = site.data.authors[page.author] %}
13- < p > < strong > < a href ="/react{{ page.url }} "> {{ page.title }}</ a > </ strong > on {{ page.date | date: "%B %e, %Y" }} by {{ author.name }}</ p >
12+ < p > < strong > < a href ="/react{{ page.url }} "> {{ page.title }}</ a > </ strong > on {{ page.date | date: "%B %e, %Y" }} by {{ page.author.name }}</ p >
1413 {% endfor %}
1514 </ div >
1615</ section >
You can’t perform that action at this time.
0 commit comments