From c490d2aff1158c3fc82b37e34498aef5f73107c2 Mon Sep 17 00:00:00 2001 From: rizkikadafi Date: Wed, 10 Apr 2024 23:04:00 +0700 Subject: [PATCH] add archives feature --- Gemfile | 3 ++ Gemfile.lock | 3 ++ _config.yml | 2 +- _data/blog-navigation.yml | 6 +-- _layouts/archive.html | 56 ++++++++++++++++++++ _layouts/post.html | 4 +- blog/archives.html | 31 +++++++++++ blog/categories.html | 3 +- blog/index.html | 3 +- blog/math/_posts/2020-05-11-eigen-value.md | 15 ++++++ blog/programming/_posts/2023-11-11-b-tree.md | 15 ++++++ blog/tags.html | 1 + 12 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 _layouts/archive.html create mode 100644 blog/archives.html create mode 100644 blog/math/_posts/2020-05-11-eigen-value.md create mode 100644 blog/programming/_posts/2023-11-11-b-tree.md diff --git a/Gemfile b/Gemfile index 55ead4f..ffd9f46 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,6 @@ source 'https://rubygems.org' gem 'jekyll' gem 'jekyll-postcss' gem 'webrick' +group :jekyll_plugins do + gem 'jekyll-archives' +end diff --git a/Gemfile.lock b/Gemfile.lock index 61ef8a4..26a6d4c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,6 +36,8 @@ GEM safe_yaml (~> 1.0) terminal-table (>= 1.8, < 4.0) webrick (~> 1.7) + jekyll-archives (2.2.1) + jekyll (>= 3.6, < 5.0) jekyll-postcss (0.5.0) jekyll-sass-converter (3.0.0) sass-embedded (~> 1.54) @@ -112,6 +114,7 @@ PLATFORMS DEPENDENCIES jekyll + jekyll-archives jekyll-postcss webrick diff --git a/_config.yml b/_config.yml index 30e50ce..03c8812 100644 --- a/_config.yml +++ b/_config.yml @@ -1,4 +1,4 @@ -baseurl: "" +baseurl: "https://rizkikadafi.github.io" url: "" defaults: - scope: diff --git a/_data/blog-navigation.yml b/_data/blog-navigation.yml index 3ebd228..e95024b 100644 --- a/_data/blog-navigation.yml +++ b/_data/blog-navigation.yml @@ -3,7 +3,7 @@ - name: Category link: "/blog/categories" - name: Recent Post - link: "/blog/#recent" -- name: Archive - link: /blog/archive + link: "/blog#recent" +- name: Archives + link: /blog/archives diff --git a/_layouts/archive.html b/_layouts/archive.html new file mode 100644 index 0000000..4c0ba98 --- /dev/null +++ b/_layouts/archive.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + Kadafi's Blog {% if page.title %} | {{page.title}} {% endif %} + + + + + {% include blog-modal-navigation.html %} + + +
+ {{content}} +
+ + + + + + + + + diff --git a/_layouts/post.html b/_layouts/post.html index 3335c02..77807f8 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -25,12 +25,12 @@ {% endif %}
+ class="prose prose-sm sm:prose-base dark:prose-invert prose-h1:mb-2 prose-h1:text-2xl sm:prose-h1:text-3xl max-w-none px-2 md:px-0 text-slate-800 dark:text-white mt-5">

{{page.title}}

{% for tag in page.tags %} {{tag}} + class="inline-block mr-2 my-1 w-fit text-sm bg-slate-500/70 backdrop-blur-md rounded-xl px-4 py-[2px] dark:text-slate-200">{{tag}} {% endfor %}
{{ content }} diff --git a/blog/archives.html b/blog/archives.html new file mode 100644 index 0000000..8ff6c3b --- /dev/null +++ b/blog/archives.html @@ -0,0 +1,31 @@ +--- +layout: archive +premalink: /blog/archives +title: archives +--- +{% for post in site.posts %} + +{% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %} +{% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %} + + {% if forloop.first %} +

{{this_year}}

+ + {% else %} + {% if this_year != next_year %} + +

{{next_year}}

+