Skip to content

Commit

Permalink
better sub-categories
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadianriver committed Apr 3, 2016
1 parent 4ef5ba9 commit c1afa44
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 52 deletions.
6 changes: 4 additions & 2 deletions _includes/breadcrumb.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
if page.layout == 'page' %}
<li>{{ page.title }}</li>{%
elsif page.layout == 'post' %}{%
assign lastcat = page.categories | last %}{%
for cat in page.categories %}{%
capture urlstr %}{{ urlstr }}/{{ cat }}{% endcapture %}
<li style="text-transform: capitalize;"><a href="{{ site.baseurl }}{{ urlstr }}">{{ cat }}</a></li>{%
unless page.permalink and cat == lastcat %}{%
capture urlstr %}{{ urlstr }}/{{ cat }}{% endcapture %}
<li style="text-transform: capitalize;"><a href="{{ site.baseurl }}{{ urlstr }}">{{ cat }}</a></li>{% endunless %}{%
endfor %}
<li>{{ page.title }}</li>{%
endif %}
Expand Down
20 changes: 12 additions & 8 deletions _includes/fn_sortednav.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
{% comment %}
# Find this post in sorted_list and get back/next
# depends: sorted_list of posts
# depends: sorted_list of posts and idxperma, idxtitle, idxbutton of index
# include-params: posclass - indicates whether top or bottom style
# returns: displays navigation using included backnextnav.html
# Original idea:
# https://gist.github.com/budparr/3e637e575471401d01ec
{% endcomment
%}{% for post in sorted_list
%}{% if post.title == page.title
%}{% if post.url == page.url
%}{% unless forloop.first
%}{% assign prevbutton = '&lt; Back'
%}{% assign prevurl = prev.url
%}{% assign prevtitle = prev.title
%}{% elsif page.permalink
%}{% assign prevbutton = nil
%}{% assign prevurl = nil
%}{% assign prevtitle = nil
%}{% else
%}{% assign prevbutton = 'Index'
%}{% assign prevurl = perma | prepend: baseurl
%}{% assign prevtitle = 'Works Index'
%}{% assign prevbutton = idxbutton
%}{% assign prevurl = idxperma | prepend: baseurl
%}{% assign prevtitle = idxtitle
%}{% endunless
%}{% unless forloop.last
%}{% assign next = sorted_list[forloop.index]
%}{% assign nextbutton = 'Next &gt;'
%}{% assign nexturl = next.url
%}{% assign nexttitle = next.title
%}{% else
%}{% assign nextbutton = 'Index'
%}{% assign nexturl = perma | prepend: baseurl
%}{% assign nexttitle = 'Works Index'
%}{% assign nextbutton = idxbutton
%}{% assign nexturl = idxperma | prepend: baseurl
%}{% assign nexttitle = idxtitle
%}{% endunless
%}{% endif
%}{% assign prev = post
Expand Down
8 changes: 6 additions & 2 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
<div class="inner{% if page.options contains 'fullwidth' %} fullwidth{% endif %}">{%
unless site.navlinks == 'none'
%}{% if page.categories contains 'works'
%}{% assign perma = '/works/'
%}{% assign idxperma = '/works/'
%}{% assign idxtitle = 'Works Index'
%}{% assign idxbutton = 'Index'
%}{% include fn_groupsort_reverse.html unsorted=site.categories.works groupby='priority' sortby='date'
%}{% endif
%}{% if page.categories.first == 'topics' and page.categories.last != 'topics'
%}{% assign perma = page.categories | join: '/' | prepend: '/' | append: '/'
%}{% assign idxperma = page.categories | join: '/' | prepend: '/' | append: '/'
%}{% assign idxtitle = 'Start page'
%}{% assign idxbutton = 'Start'
%}{% assign sorted_list = site.empty_array
%}{% for topic in site.categories.topics
%}{% if topic.categories.last == page.categories.last
Expand Down
10 changes: 0 additions & 10 deletions _posts/3006-08-09-test-firstday.md

This file was deleted.

11 changes: 11 additions & 0 deletions _posts/3006-09-22-subcattest-topic1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: My Topic Group
excerpt: first topic in my neat grouping
permalink: /topics/my topic group/
categories:
- topics
- my topic group
date: 3006-09-22 00:00
---

Here we go.
10 changes: 10 additions & 0 deletions _posts/3006-09-22-subcattest-topic2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Test topic 2
excerpt: Second awesome topic in the group
categories:
- topics
- my topic group
date: 3006-09-22 00:01
---

Yada yada and more yada.
10 changes: 10 additions & 0 deletions _posts/3006-09-22-subcattest-topic3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Last topic in group
excerpt: last topic
categories:
- topics
- my topic group
date: 3006-09-22 00:02
---

This about sums it all up.
9 changes: 0 additions & 9 deletions _posts/3006-09-22-test-vienna.md

This file was deleted.

9 changes: 0 additions & 9 deletions _posts/3006-09-23-test-funfun.md

This file was deleted.

35 changes: 23 additions & 12 deletions _posts/3016-02-26-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ author: arkadianriver

### `categories`

_IF_ it's a post, the categories array is required with at least
_the first element_ set to the permalink name of its parent page
If it's a post, the categories array is required with at least
the first element set to the permalink name of its parent page
(so that breadcrumbs work).

{% highlight yaml %}
Expand All @@ -19,15 +19,10 @@ categories: topics ...

The two top-level categories with provided index pages are `topics` and `works`.

Advanced:
If you want back/next navigation within a subcategory:

{:.nobullet}
- The following settings will list the first topic in the subcategory
in the topics index and (soon) will create back/next links within the
subcategory.

{:.nobullet}
- To start, create a first post for the sub-category, but with a permalink.
- Create a first post for the sub-category, but with a permalink.
The category list can be space-delimited on one line or in a bulleted list.
Note that the category names must exactly match the permalink.

Expand All @@ -41,7 +36,17 @@ Advanced:
`/topics/my-great-vacation/index.html`

{:.nobullet}
- For topics within that sub-category, add the additional category and no
- If your subcategory contains spaces, specify categories as an array

{% highlight yaml %}
categories:
- topics
- my great vacation
permalink: /topics/my great vacation/
{% endhighlight %}

{:.nobullet}
- For subsequent topics in the sub-category, add the sub-category and no
permalink:

{% highlight yaml %}
Expand All @@ -52,7 +57,13 @@ Advanced:
- resulting in: `/topics/my-great-vacation/topic-title.html`

{:.nobullet}
- (coming soon) This creates back and next links.
- Topics in the sub-category are sorted by date (and time). Therefore, if they
all fall on the same day, specify the date in the post with a timestamp by
which to sort.

{% highlight yaml %}
date: 3009-09-22 00:00:03
{% endhighlight %}


### `excerpt`
Expand All @@ -68,7 +79,7 @@ excerpt: yada yada

### `permalink`

_IF_ it's a parent page, use a permalink for it's new category, but don't specify
If it's a parent page, use a permalink for it's new category, but don't specify
that new category for this parent page itself, because it becomes the index
that a breadcrumb link would pop up to, ie: `/new-category/index.html`. Also see
`categories`.
Expand Down

0 comments on commit c1afa44

Please sign in to comment.