From 8dd6aac2e6c926223ea06f05d5fb36dd166f0ea5 Mon Sep 17 00:00:00 2001 From: "tyler :3" Date: Sun, 7 Apr 2024 22:31:25 +0100 Subject: [PATCH] Implement pagination and auto-sitemap --- Gemfile | 3 ++- Gemfile.lock | 6 ++++++ _config.yml | 11 +++++++---- _layouts/post.html | 4 ++-- _layouts/shr4pnel.html | 22 ++++++++++++++-------- assets/css/index.css | 1 + assets/js/get-correct-path.js | 8 ++++++++ index.html | 9 +++++++++ index.markdown | 4 ---- 9 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 assets/js/get-correct-path.js create mode 100644 index.html delete mode 100644 index.markdown diff --git a/Gemfile b/Gemfile index bc1ca86..a11cc27 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,10 @@ source "https://rubygems.org" gem "jekyll", "~> 4.3.3" group :jekyll_plugins do gem "jekyll-feed", "~> 0.12" + gem "jekyll-paginate-v2" + gem "jekyll-sitemap" end - platforms :mingw, :x64_mingw, :mswin, :jruby do gem "tzinfo", ">= 1", "< 3" gem "tzinfo-data" diff --git a/Gemfile.lock b/Gemfile.lock index bb0ca08..3bba44b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,8 +44,12 @@ GEM webrick (~> 1.7) jekyll-feed (0.17.0) jekyll (>= 3.7, < 5.0) + jekyll-paginate-v2 (3.0.0) + jekyll (>= 3.0, < 5.0) jekyll-sass-converter (3.0.0) sass-embedded (~> 1.54) + jekyll-sitemap (1.4.0) + jekyll (>= 3.7, < 5.0) jekyll-watch (2.2.1) listen (~> 3.0) kramdown (2.4.0) @@ -147,6 +151,8 @@ DEPENDENCIES http_parser.rb (~> 0.6.0) jekyll (~> 4.3.3) jekyll-feed (~> 0.12) + jekyll-paginate-v2 + jekyll-sitemap tzinfo (>= 1, < 3) tzinfo-data wdm (~> 0.1.1) diff --git a/_config.yml b/_config.yml index 524cf0c..cb8b6d3 100644 --- a/_config.yml +++ b/_config.yml @@ -1,8 +1,11 @@ title: shr4pnelblog !! description: Ruminations on music, the world and whatever rubbish pops into my head delivered straight to you. -url: blog.shr4pnel.com +url: https://blog.shr4pnel.com author: tyler! -plugins: - - jekyll-feed exclude: - - .idea \ No newline at end of file + - .idea +pagination: + enabled: true + per_page: 5 + sort_reverse: true + permalink: /page/:num/ \ No newline at end of file diff --git a/_layouts/post.html b/_layouts/post.html index 83a2376..ae2a587 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -30,9 +30,9 @@ {{ content }} - back home! + back home! - + \ No newline at end of file diff --git a/_layouts/shr4pnel.html b/_layouts/shr4pnel.html index fd1fb03..220b915 100644 --- a/_layouts/shr4pnel.html +++ b/_layouts/shr4pnel.html @@ -19,15 +19,21 @@

article

- {% for post in site.posts %} - + {% for post in paginator.posts %} +
+ little face with sunglasses + {{ post.title }} +

{{ post.date | date: "%d/%m/%y" }}

+
{% endfor %} +
+ {% if paginator.previous_page %} + Previous page + {% endif %} + {% if paginator.next_page %} + Next page + {% endif %} +

or uhh just play minesweeper :3

little animated cats in a line
diff --git a/assets/css/index.css b/assets/css/index.css index 43732ef..6e2314c 100644 --- a/assets/css/index.css +++ b/assets/css/index.css @@ -85,6 +85,7 @@ p > img { flex-direction: row; align-items: center; margin-bottom: 10px; + min-width: 880px; } .card > a { diff --git a/assets/js/get-correct-path.js b/assets/js/get-correct-path.js new file mode 100644 index 0000000..32f4c12 --- /dev/null +++ b/assets/js/get-correct-path.js @@ -0,0 +1,8 @@ +// this puts you back on the page you came from +const referrer = document.referrer +let anchor = document.getElementById("generate-path") +if (referrer.includes("blog.shr4pnel.com") || referrer.includes("localhost:4000")) { + anchor.href = referrer +} else { + anchor.href = "/" +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..b1682a9 --- /dev/null +++ b/index.html @@ -0,0 +1,9 @@ +--- +layout: shr4pnel +title: shr4pnelblog!! +pagination: + enabled: true +per_page: 5 +debug: true +sort_reverse: true +--- \ No newline at end of file diff --git a/index.markdown b/index.markdown deleted file mode 100644 index e8882c9..0000000 --- a/index.markdown +++ /dev/null @@ -1,4 +0,0 @@ ---- -layout: shr4pnel -title: shr4pnelblog!! ----