Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Books feature #41

Draft
wants to merge 4 commits into
base: gh-pages
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ collections:
output: true
recipes:
output: true
books:
output: true

exclude: ['Gemfile', 'Gemfile.lock', 'Rakefile', 'README.md']

Expand Down
8 changes: 8 additions & 0 deletions _data/people.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Store your people here
# eg:
#
# clarklab:
# name: Clark Wimberly
# twitter: @clarklab
# web: http://clarklab.com
#
32 changes: 32 additions & 0 deletions _includes/book-preview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% assign thisbook = include.book %}

<div class="col sm-col-12 md-col-12 lg-col-6 sm-p2" itemscope itemtype="http://schema.org/Book">
<meta itemprop="bookFormat" content="EBook"/>
<meta itemprop="genre" content="cooking"/>

<div class="col sm-col-12 md-col-2 lg-col-3">
<img src="/images/{{ thisbook.cover }}" itemprop="image" />
</div>

<div class="col sm-col-12 md-col-10 lg-col-9 px2">
<div class="">
<h3 class="h1 mt0" itemprop="name">{{ thisbook.title }}</h3>
{% if thisbook.author %}
{% assign author = site.data.people[thisbook.author] %}
<h4 class="gray h5">by {{ author.name }}</h4>
{% endif %}
<p class="italic" itemprop="description">{{ thisbook.description }}</p>
<p class="h5" itemprop="abstract">
{{ thisbook.covernotes }}
</p>

{% unless page.url == thisbook.url %}
<a class="button button-transparent blue" href="{{ thisbook.url }}">Read on...</a>
{% endunless %}
</div>
</div>

</div>

{% assign author = nil %}
{% assign thisbook = nil %}
7 changes: 7 additions & 0 deletions _includes/recipe-preview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% assign thisrecipe = include.recipe %}

<a class="col col-12 sm-col-4 md-col-4 lg-col-3 button button-transparent blue" href="{{ thisrecipe.url }}">
{{ thisrecipe.title }}
</a>

{% assign thisrecipe = nil %}
20 changes: 20 additions & 0 deletions _includes/related-books.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% assign thisRecipe = include.recipe %}
{% assign bookIds = thisRecipe.books %}

{% if thisRecipe.books %}
<aside class="books clearfix">
<div class="components bg-darken-2 p2 mt3 mb3 center">
This recipe appears in these books
</div>
{% for book in site.books %}
{% for thisRecipeBookId in thisRecipe.books %}
{% assign bookId = thisRecipeBookId | prepend: "/books/" %}
{% if book.id == bookId %}
{% include book-preview.html book=book %}
{% endif %}
{% endfor %}
{% endfor %}
</aside>
{% endif %}

{% assign booklist = nil %}
40 changes: 40 additions & 0 deletions _layouts/book.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
layout: default
---
{% assign pageAuthor = site.data.people[page.author] %}

<div class="container">
<article class="post-content px2 clearfix">
{{ content }}
</article>

<aside class="px2 clearfix">
<div class="components bg-darken-2 p2 mt3 mb3 center">
Recipes in this book
</div>
{% assign bookid = page.id | split: '/' | last %}
<div class="p2">
{% for recipe in site.recipes %}
{% if recipe.books contains bookid %}
{% include recipe-preview.html recipe=recipe %}
{% endif %}
{% endfor %}
</div>
</aside>

<aside class="px2 clearfix">
<div class="components bg-darken-2 p2 mt3 mb3 center">
Other books
{% if pageAuthor %}
by <span class="blue">{{ pageAuthor.name }}</span>
{% endif %}
</div>
<div class="p2">
{% for book in site.books %}
{% if book.author == page.author and book.id != page.id %}
{% include book-preview.html book=book %}
{% endif %}
{% endfor %}
</div>
</aside>
</div>
1 change: 1 addition & 0 deletions _layouts/recipe.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ <h4 class="blue regular xs-center">{{ site.translation[site.language].directions
<p class="clearfix">{{ site.translation[site.language].category }}: <span itemprop="recipeCategory">{{ category }}</span></p>
{% endfor %}

{% include related-books.html recipe=page %}
</article>

</div>
Expand Down
16 changes: 16 additions & 0 deletions books.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
layout: default
---

<div class="container">

<h1>Books</h1>
<p>Here's all the lovely books we have.</p>

<div class="clearfix">
{% for book in site.books %}
{% include book-preview.html book=book %}
{% endfor %}
</div>

</div>