From c014a3cdbe00b0de1db0601d9411a661ffd5c3b7 Mon Sep 17 00:00:00 2001 From: Pat Dryburgh Date: Wed, 8 Aug 2018 21:55:15 -0700 Subject: [PATCH] add pagination support --- _includes/back-link.html | 3 + _layouts/home.html | 128 +++++++++++++++++++++++++++------------ _layouts/post.html | 4 +- _sass/_base.scss | 29 --------- _sass/_post-list.scss | 48 +++++++++++++++ assets/css/main.scss | 1 + index.md => index.html | 0 7 files changed, 141 insertions(+), 72 deletions(-) create mode 100644 _includes/back-link.html create mode 100644 _sass/_post-list.scss rename index.md => index.html (100%) diff --git a/_includes/back-link.html b/_includes/back-link.html new file mode 100644 index 0000000..c1fb034 --- /dev/null +++ b/_includes/back-link.html @@ -0,0 +1,3 @@ + + ❮ Home + \ No newline at end of file diff --git a/_layouts/home.html b/_layouts/home.html index b26b5dd..c67eade 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -4,51 +4,99 @@ layout: default {% assign menu = site.data.menu %} -
- {% if site.title %} -

- {{ site.title }} -

- {% endif %} - {% if site.title %} -

- {{ site.description }} -

- {% endif %} - {% if menu %} - - {% endif %} -
+{% if site.paginate and site.paginate_path and paginator.page > 1 %} + {% include back-link.html %} +{% else %} +
+ {% if site.title %} +

+ {{ site.title }} +

+ {% endif %} + {% if site.title %} +

+ {{ site.description }} +

+ {% endif %} + {% if menu %} + + {% endif %} +
+{% endif %}

- Contents + {% if site.paginate and site.paginate_path and paginator.page > 1 %} + Page {{ paginator.page }} + {% else %} + Contents + {% endif %}

- + {% if site.paginate and site.paginate_path %} + + + + {% if paginator.page > 1 %} + +
+ {% if paginator.next_page %} + ⟨ Older + {% else %} +   + {% endif %} + {{ paginator.page }} of {{ paginator.total_pages }} + {% if paginator.previous_page %} + Newer ⟩ + {% else %} +   + {% endif %} +
+ + {% endif %} + + {% else %} + + + + {% endif %} +
\ No newline at end of file diff --git a/_layouts/post.html b/_layouts/post.html index 046657e..ba23ec3 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -2,9 +2,7 @@ layout: default --- - - ❮ Home - +{% include back-link.html %}
diff --git a/_sass/_base.scss b/_sass/_base.scss index a0c47fc..8600842 100644 --- a/_sass/_base.scss +++ b/_sass/_base.scss @@ -87,35 +87,6 @@ hr { text-align: center; } -.post-list { - margin: 1em 0; - list-style: none; -} - -.post-link { - color: $text-color; - display: flex; - flex-direction: column-reverse; - text-decoration: none; - padding: .25em 0; - .post-title { - display: block; - padding: .25em 0; - } - &:hover .post-title, - &:focus .post-title { - text-decoration: underline; - } - @media (min-width: $on-tablet) { - display: flex; - flex-direction: row; - justify-content: space-between; - .post-title { - margin-right: 4em; - } - } -} - .post-date { color: $muted-text-color; display: block; diff --git a/_sass/_post-list.scss b/_sass/_post-list.scss new file mode 100644 index 0000000..b1c0b33 --- /dev/null +++ b/_sass/_post-list.scss @@ -0,0 +1,48 @@ +.post-list { + margin: 1em 0; + list-style: none; +} + +.post-link { + color: $text-color; + display: flex; + flex-direction: column-reverse; + text-decoration: none; + padding: .25em 0; + .post-title { + display: block; + padding: .25em 0; + } + &:hover .post-title, + &:focus .post-title { + text-decoration: underline; + } + @media (min-width: $on-tablet) { + display: flex; + flex-direction: row; + justify-content: space-between; + .post-title { + margin-right: 4em; + } + } +} + +.post-pagination { + margin-top: 4rem; + font-size: .75em; + display: flex; + flex-direction: row; + justify-content: space-between; + * > { + flex-grow: 1; + flex-basis: 0; + } + a { + text-decoration: none; + text-transform: uppercase; + &:hover, + &:focus { + text-decoration: underline; + } + } +} \ No newline at end of file diff --git a/assets/css/main.scss b/assets/css/main.scss index c24f98e..e173ab3 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -13,5 +13,6 @@ $asset_url: '{{ '/assets' | absolute_url }}'; "font", "base", "masthead", + "post-list", "article" ; \ No newline at end of file diff --git a/index.md b/index.html similarity index 100% rename from index.md rename to index.html