From 2d94ac1c169fc93fff7a54807b5597c6b1c229fc Mon Sep 17 00:00:00 2001 From: Mat Manna <91392083+matmanna@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:26:59 +0000 Subject: [PATCH] :sparkles: Add related posts/projects --- _config.yml | 4 + _drafts/_pages/about.md | 3 +- _drafts/_pages/index.md | 2 +- _drafts/_posts/2025-06-02-second.md | 1 + _drafts/_projects/competition.md | 1 + _drafts/_projects/thesis.md | 3 +- _includes/post-card.html | 60 +++++++++++++ _includes/related.html | 129 ++++++++++++++++++++++++++++ _includes/toc-card.html | 14 +-- _layouts/post.html | 5 ++ _layouts/project.html | 37 +++----- _pages/about.md | 3 +- _pages/blog.html | 19 +--- _pages/index.md | 2 +- _pages/projects.html | 13 +-- _posts/2025-06-02-second.md | 1 + _projects/competition.md | 1 + _projects/thesis.md | 3 +- jekyll-theme-doctored.gemspec | 2 +- 19 files changed, 236 insertions(+), 67 deletions(-) create mode 100644 _includes/post-card.html create mode 100644 _includes/related.html diff --git a/_config.yml b/_config.yml index 019b648..e3606fe 100644 --- a/_config.yml +++ b/_config.yml @@ -25,6 +25,10 @@ tag_page_dir: tag tag_feed_layout: tag_feed tag_feed_dir: tag +related_from: posts projects +related_by: tags categories +related_template: post-card.html + collections: projects: output: true diff --git a/_drafts/_pages/about.md b/_drafts/_pages/about.md index 50b9f8b..a22c909 100644 --- a/_drafts/_pages/about.md +++ b/_drafts/_pages/about.md @@ -40,10 +40,11 @@ Doctored is very much still a WIP. Feel free to monitor or contribute to the sta - [x] anchor/external link icons - [x] page TOC section progressrings - [x] post tags + - [x] related posts/projects +- [ ] newsletter integrations - [ ] project posts - [ ] i18n ui - [ ] post series - - [ ] related posts - [ ] post search (simple or advanced) - [ ] link previews? - [ ] local time diff --git a/_drafts/_pages/index.md b/_drafts/_pages/index.md index 762ec79..6c00dc4 100644 --- a/_drafts/_pages/index.md +++ b/_drafts/_pages/index.md @@ -9,7 +9,7 @@ a couple of _the_ most common questionsThese are also some of the most co ## What? -- A blog theme which prioritizes uniqueness, technical complexity, and sophisticationWhile this could be redundant, it describes the the theme's vibe. +- A jekyll theme which prioritizes uniqueness, technical complexity, and sophisticationWhile this could be redundant, it describes the the theme's vibe. - **For a full list of features, see [/about]({{ '/about' | relative_url }}).** - **For code, usage instructions, and (limited) docs, see [:github]({{ site.github }}).** diff --git a/_drafts/_posts/2025-06-02-second.md b/_drafts/_posts/2025-06-02-second.md index f599347..2b81c90 100644 --- a/_drafts/_posts/2025-06-02-second.md +++ b/_drafts/_posts/2025-06-02-second.md @@ -5,5 +5,6 @@ author: matmanna description: The first post footnotes: false project: thesis +tags: dev sql --- The very second post for the Doctored theme blog! diff --git a/_drafts/_projects/competition.md b/_drafts/_projects/competition.md index cc2d4db..45ddfe1 100644 --- a/_drafts/_projects/competition.md +++ b/_drafts/_projects/competition.md @@ -11,6 +11,7 @@ skills: - name: Coffee icon: fas fa-mug-hot description: A competition I won with a team +tags: golang react sql --- This was super cool. diff --git a/_drafts/_projects/thesis.md b/_drafts/_projects/thesis.md index 29359ec..15b3c34 100644 --- a/_drafts/_projects/thesis.md +++ b/_drafts/_projects/thesis.md @@ -1,9 +1,10 @@ --- layout: project title: Research Thesis -collaborators: matmanna +authors: matmanna website: https://example.com description: The final work for my degree +tags: academic skills: - name: Statistical Analysis - name: Quantum Mechanics diff --git a/_includes/post-card.html b/_includes/post-card.html new file mode 100644 index 0000000..79eb759 --- /dev/null +++ b/_includes/post-card.html @@ -0,0 +1,60 @@ +{%- comment -%} +Make this include generic: accepts `include.entry` (or falls back to `post`, `project`, or `item`). +`kind` is inferred from `include.kind` or `entry.collection` when available. Icon and metadata +adjust based on kind so the same template can render posts, projects, pages, etc. +{%- endcomment -%} + +{%- assign entry = include.entry | default: post | default: project | default: item -%} +{%- assign kind_raw = include.kind | default: entry.collection | default: entry.type | default: 'post' -%} +{%- assign kind = kind_raw | downcase -%} + +{%- assign icon_class = 'fa-solid fa-file-lines' -%} +{%- if kind == 'post' or kind == 'posts' -%} +{%- assign icon_class = 'fa-solid fa-feather-pointed' -%} +{%- elsif kind == 'project' or kind == 'projects' -%} +{%- assign icon_class = 'fa-solid fa-shapes' -%} +{%- elsif kind == 'page' or kind == 'pages' -%} +{%- assign icon_class = 'fa-solid fa-file' -%} +{%- endif -%} + +
  • +
    +

    + + {{ entry.title }} +

    + + {%- if kind == 'post' or kind == 'posts' -%} +

    + {{ entry.date | date: "%m-%d-%Y" }} +

    + {%- endif -%} +
    + +
    +
    + + {{ entry.description }} + {% for tag in entry.tags %} + +
    + {{ tag }} +
    +
    + {% endfor %} +
    + + {%- if kind == 'post' or kind == 'posts' -%} + Keep reading... + {%- elsif kind == 'project' or kind == 'projects' -%} + View more + {%- else -%} + Open + {%- endif -%} +
    +
  • \ No newline at end of file diff --git a/_includes/related.html b/_includes/related.html new file mode 100644 index 0000000..a2d2f8e --- /dev/null +++ b/_includes/related.html @@ -0,0 +1,129 @@ +{% comment %} + +{% endcomment %} + +{% assign related_by_raw = page.related_by | default: site.related_by | default: "default" %} +{%- comment -%} normalize to an array of tokens {% endcomment -%} +{% assign related_by = related_by_raw | split: " " %} +{% assign related_limit = page.related_limit | default: site.related_limit | default: 4 %} +{% assign related_from = page.related_from | default: site.related_from | default: documents %} +{% comment %} Build a pool of documents based on related_from (supports 'posts' and collection names) {% endcomment %} +{% comment %} Ensure related_from is an array of names (split on whitespace) {% endcomment %} +{% assign source_names = related_from | split: " " %} +{% assign pool = "" | split: " " %} +{% for name in source_names %} + {% assign name = name | strip | downcase %} + {% if name == "posts" %} + {% assign pool = pool | concat: site.posts %} + {% elsif site[name] %} + {% assign pool = pool | concat: site[name] %} + {% elsif site.collections[name] %} + {% assign pool = pool | concat: site.collections[name].docs %} + {% endif %} +{% endfor %} +{% assign related_categories = page.related_categories | default: site.related_categories | default: 1 %} +{% assign related_tags = page.related_tags | default: site.related_tags | default: 1 %} +{% assign related_template = page.related_template | default: site.related_template | default: "related-post.html" %} +{% assign related_layout = page.related_layout | default: site.related_layout | default: "list" %} + +{% comment %}{% endcomment %} +{% if related_by contains "random" %} +{% comment %}{% endcomment %} +{% assign related_limit = related_limit | plus: 1 %} +{% assign related_posts = pool | sample: related_limit %} +{% assign related_limit = related_limit | minus: 1 %} + +{% comment %}{% endcomment %} +{% elsif related_by contains "categories" or related_by contains "tags" %} +{% assign related_posts = "" | split: " " %} + + +{% for doc in pool %} +{% if doc.id == page.id %} +{% continue %} +{% elsif related_from == "posts" and doc.collection != "posts" %} +{% continue %} +{% elsif related_from == "collection" and doc.collection != page.collection %} +{% continue %} +{% endif %} + +{% assign related_category_count = 0 %} +{% if related_by contains "categories" %} +{% for cat in doc.categories %} +{% if page.categories contains cat %} +{% assign related_category_count = related_category_count | plus: 1 %} +{% endif %} +{% endfor %} +{% endif %} + +{% assign related_tag_count = 0 %} +{% if related_by contains "tags" %} +{% for tag in doc.tags %} +{% if page.tags contains tag %} +{% assign related_tag_count = related_tag_count | plus: 1 %} +{% endif %} +{% endfor %} +{% endif %} + +{% if related_by contains "categories" and related_by contains "tags" %} +{% if related_by contains "or" %} +{% if related_category_count >= related_categories or related_tag_count >= related_tags %} +{% assign related_posts = related_posts | push: doc %} +{% endif %} +{% else %} +{% if related_category_count >= related_categories and related_tag_count >= related_tags %} +{% assign related_posts = related_posts | push: doc %} +{% endif %} +{% endif %} +{% elsif related_by contains "categories" and related_category_count >= related_categories %} +{% assign related_posts = related_posts | push: doc %} +{% elsif related_by contains "tags" and related_tag_count >= related_tags %} +{% assign related_posts = related_posts | push: doc %} +{% endif %} +{% endfor %} + +{% assign related_posts = related_posts | sample: related_limit %} + +{% comment %} If no matches found by tags/categories, fall back to the pool so "See also" isn't empty {% endcomment %} +{% if related_posts == empty %} +{% assign related_posts = pool | sample: related_limit %} +{% endif %} + +{% comment %}{% endcomment %} +{% elsif site.related_posts.size > 0 %} +{% assign related_posts = site.related_posts %} + +{% comment %}{% endcomment %} +{% else %} +{% assign related_posts = pool %} +{% endif %} + +{% for post in related_posts limit:related_limit %} +{% if post.id == page.id %} +{% continue %} +{% endif %} + +{% include {{ related_template }} type=related_layout %} +{% endfor %} \ No newline at end of file diff --git a/_includes/toc-card.html b/_includes/toc-card.html index e9c2a08..9dabbc6 100644 --- a/_includes/toc-card.html +++ b/_includes/toc-card.html @@ -11,16 +11,16 @@
    TLDR {{ page.description}} +
    -
  • Published {{ page.date | date_to_string }}

    -
  • +
  • Time {% capture words %} @@ -31,8 +31,8 @@ {% endunless %}
  • - {% if page.authors.size > 0 %} + {% if page.authors.size > 0 %}
  • @@ -101,7 +101,7 @@ {%if page.toc %} -

    Table of Contents

    +

    Table of Contents

    {% endif %} {% include toc.html html=content anchor_class="toc-link" %} @@ -145,7 +145,7 @@ function updateOriginalPosition() { toc.style.position = 'static'; - toc.querySelector('h4').style.display = 'none'; + // toc.querySelector('h4').style.display = 'none'; // toc.querySelectorAll('h4')[1].style.display = 'block'; toc.style.transform = 'none'; @@ -230,8 +230,8 @@ toc.style.left = ''; toc.style.width = ''; toc.style.maxWidth = ''; - toc.querySelector('h4').style.display = 'none'; - toc.querySelectorAll('h4')[1].style.display = 'block'; + // toc.querySelector('h4').style.display = 'none'; + // toc.querySelectorAll('h4')[1].style.display = 'block'; toc.style.borderTopLeftRadius = ''; toc.style.borderTopRightRadius = ''; diff --git a/_layouts/post.html b/_layouts/post.html index 63ea398..c546d47 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -15,4 +15,9 @@ layout: default {{ content }}
    +
    +

    See also

    + {% include related.html %} +
    + \ No newline at end of file diff --git a/_layouts/project.html b/_layouts/project.html index e6801f5..048795a 100644 --- a/_layouts/project.html +++ b/_layouts/project.html @@ -4,6 +4,13 @@ layout: default

    {{ page.title }}

    {{ page.description }}

    + +
    + {% if page.toc != false %} + {% include toc-card.html html=content %} + {% endif %} +
    +
    • @@ -30,26 +37,10 @@ layout: default
    -{{ content }} - \ No newline at end of file +
    + {{ content }} +
    +
    +

    See also

    + {% include related.html %} +
    \ No newline at end of file diff --git a/_pages/about.md b/_pages/about.md index 60aee4d..2c3290d 100644 --- a/_pages/about.md +++ b/_pages/about.md @@ -42,10 +42,11 @@ Doctored is very much still a WIP. Feel free to monitor or contribute to the sta - [x] anchor/external link icons - [x] page TOC section progressrings - [x] post tags + - [x] related posts/projects +- [ ] newsletter integrations - [ ] project posts - [ ] i18n ui - [ ] post series - - [ ] related posts - [ ] post search (simple or advanced) - [ ] link previews? - [ ] local time diff --git a/_pages/blog.html b/_pages/blog.html index b19ec8f..054551a 100644 --- a/_pages/blog.html +++ b/_pages/blog.html @@ -8,23 +8,6 @@ description: A collection of the latest posts and articles \ No newline at end of file diff --git a/_pages/index.md b/_pages/index.md index be88062..79f3f1f 100644 --- a/_pages/index.md +++ b/_pages/index.md @@ -11,7 +11,7 @@ a couple of _the_ most common questionsThese are also some of the most co ## What? -- A blog theme which prioritizes uniqueness, technical complexity, and sophisticationWhile this could be redundant, it describes the the theme's vibe.[^2] +- A jekyll theme which prioritizes uniqueness, technical complexity, and sophisticationWhile this could be redundant, it describes the the theme's vibe.[^2] - **For a full list of features, see [/about]({{ '/about' | relative_url }}).** - **For code, usage instructions, and (limited) docs, see [:github]({{ site.github }}).** diff --git a/_pages/projects.html b/_pages/projects.html index 08ea9ec..13faf70 100644 --- a/_pages/projects.html +++ b/_pages/projects.html @@ -8,18 +8,7 @@ description: My proudest projects and achievements
      {% for project in site.projects %} -
    • -
      -

      - - {{ project.title }} -

      + {% include post-card.html post=post %} -
      -
      - {{ project.description }} -
      -
    • {% endfor %}
    \ No newline at end of file diff --git a/_posts/2025-06-02-second.md b/_posts/2025-06-02-second.md index 9b43d60..af3ef08 100644 --- a/_posts/2025-06-02-second.md +++ b/_posts/2025-06-02-second.md @@ -5,6 +5,7 @@ author: matmanna description: The first post footnotes: false project: thesis +tags: dev sql --- diff --git a/_projects/competition.md b/_projects/competition.md index cfcd798..cbdde70 100644 --- a/_projects/competition.md +++ b/_projects/competition.md @@ -11,6 +11,7 @@ skills: - name: Coffee icon: fas fa-mug-hot description: A competition I won with a team +tags: golang react sql --- diff --git a/_projects/thesis.md b/_projects/thesis.md index fdc84e1..a5feb74 100644 --- a/_projects/thesis.md +++ b/_projects/thesis.md @@ -1,9 +1,10 @@ --- layout: project title: Research Thesis -collaborators: matmanna +authors: matmanna website: https://example.com description: The final work for my degree +tags: dev skills: - name: Statistical Analysis - name: Quantum Mechanics diff --git a/jekyll-theme-doctored.gemspec b/jekyll-theme-doctored.gemspec index 77d4ae0..86e5760 100644 --- a/jekyll-theme-doctored.gemspec +++ b/jekyll-theme-doctored.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |spec| spec.email = [""] spec.license = "MIT" - spec.summary = "🎩 A blog theme prioritizing uniqueness, complexity, and sophistication. " + spec.summary = "🎩 A jekyll theme prioritizing uniqueness, complexity, and sophistication. " spec.description = " Doctored is a jekyll theme built with tailwind CSS which enables the ceration of static, yet highly advanced, blogs, digital gardens, documentation, and portfolio websites." spec.homepage = "https://matmanna.github.io/doctored" -- 2.51.2