|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Archives |
| 4 | +--- |
| 5 | + |
| 6 | +<div class="max-w-6xl mx-auto px-4 sm:px-6 md:px-8 py-4 md:py-12"> |
| 7 | + <div class="flex flex-col lg:flex-row gap-8 lg:items-start"> |
| 8 | + <!-- Main Content --> |
| 9 | + <main class="lg:w-0 lg:flex-1"> |
| 10 | + <!-- Header --> |
| 11 | + <header class="mb-12 pb-8 border-b border-gray-200"> |
| 12 | + <h1 class="text-3xl md:text-4xl font-bold text-gray-900 mb-4">Archives</h1> |
| 13 | + <p class="text-gray-600 text-xl leading-relaxed"> |
| 14 | + Browse blog posts by month |
| 15 | + </p> |
| 16 | + </header> |
| 17 | + <div data-pagination="archives"> |
| 18 | + <!-- Filtered content will be shown/hidden by JavaScript --> |
| 19 | + <div id="filtered-view" style="display: none;"> |
| 20 | + <div class="mb-6"> |
| 21 | + <h2 id="filtered-title" class="text-2xl font-bold text-gray-900"></h2> |
| 22 | + <p class="text-gray-600 mt-2"> |
| 23 | + <a href="{{ site.baseurl }}/archives" class="text-blue-600 hover:text-blue-800">← Back to all archives</a> |
| 24 | + </p> |
| 25 | + </div> |
| 26 | + <div id="filtered-posts" class="space-y-6"></div> |
| 27 | + </div> |
| 28 | + |
| 29 | + <!-- Show all months --> |
| 30 | + <div id="all-content"> |
| 31 | + {% assign posts_by_year = site.posts | group_by_exp: "post", "post.date | date: '%Y'" %} |
| 32 | + {% for year in posts_by_year %} |
| 33 | + <div class="mb-12"> |
| 34 | + <h2 class="text-2xl font-bold text-gray-900 mb-6">{{ year.name }}</h2> |
| 35 | + |
| 36 | + {% assign posts_by_month = year.items | group_by_exp: "post", "post.date | date: '%B %Y'" %} |
| 37 | + {% for month in posts_by_month %} |
| 38 | + <div class="mb-8 month-section" id="{{ month.name | slugify }}" data-month="{{ month.name }}"> |
| 39 | + <h3 class="text-xl font-semibold text-gray-800 mb-4"> |
| 40 | + <a href="{{ site.baseurl }}/archives?month={{ month.name | url_encode }}" |
| 41 | + class="text-gray-800 hover:text-blue-600 transition-colors"> |
| 42 | + {{ month.name }} |
| 43 | + </a> |
| 44 | + </h3> |
| 45 | + |
| 46 | + <div class="space-y-6"> |
| 47 | + {% for post in month.items %} |
| 48 | + <article class="border-b border-gray-100 pb-6 last:border-b-0 last:pb-0"> |
| 49 | + <div class="flex flex-col md:flex-row gap-6"> |
| 50 | + <div class="md:w-1/3 flex-shrink-0"> |
| 51 | + {%- if post.image -%} |
| 52 | + <div class="aspect-video bg-gray-50 rounded-lg overflow-hidden"> |
| 53 | + <img src="{{ post.image | relative_url }}" alt="{{ post.title | escape }}" class="w-full h-full object-contain p-2"> |
| 54 | + </div> |
| 55 | + {%- else -%} |
| 56 | + <div class="aspect-video bg-gradient-to-br from-blue-50 to-indigo-100 rounded-lg flex items-center justify-center"> |
| 57 | + <svg class="w-12 h-12 text-blue-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 58 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9.5a2 2 0 00-2-2h-1"/> |
| 59 | + </svg> |
| 60 | + </div> |
| 61 | + {%- endif -%} |
| 62 | + </div> |
| 63 | + <div class="flex-1"> |
| 64 | + <header class="mb-4"> |
| 65 | + <h4 class="text-lg md:text-xl font-bold text-gray-900 mb-2"> |
| 66 | + <a href="{{ post.url | relative_url }}" class="text-gray-900 hover:text-blue-600 transition-colors"> |
| 67 | + {{ post.title }} |
| 68 | + </a> |
| 69 | + </h4> |
| 70 | + <div class="flex flex-wrap items-center gap-3 text-sm text-gray-600"> |
| 71 | + <time datetime="{{ post.date | date: '%Y-%m-%d' }}"> |
| 72 | + {{ post.date | date: '%B %d, %Y' }} |
| 73 | + </time> |
| 74 | + {% if post.categories %} |
| 75 | + <span class="text-gray-400">•</span> |
| 76 | + <div class="flex flex-wrap gap-2"> |
| 77 | + {% for category in post.categories %} |
| 78 | + <span class="bg-blue-100 text-blue-700 px-2 py-1 rounded-md text-xs font-medium"> |
| 79 | + {{ category | replace: '_', ' ' | capitalize }} |
| 80 | + </span> |
| 81 | + {% endfor %} |
| 82 | + </div> |
| 83 | + {% endif %} |
| 84 | + </div> |
| 85 | + </header> |
| 86 | + |
| 87 | + {% if post.excerpt %} |
| 88 | + <div class="text-gray-700 leading-relaxed mb-4"> |
| 89 | + {{ post.excerpt | strip_html | truncate: 200 }} |
| 90 | + </div> |
| 91 | + {% endif %} |
| 92 | + |
| 93 | + <footer> |
| 94 | + <a href="{{ post.url | relative_url }}" |
| 95 | + class="inline-flex items-center gap-1 text-blue-600 hover:text-blue-800 font-medium transition-colors"> |
| 96 | + Read more |
| 97 | + <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 98 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/> |
| 99 | + </svg> |
| 100 | + </a> |
| 101 | + </footer> |
| 102 | + </div> |
| 103 | + </div> |
| 104 | + </article> |
| 105 | + {% endfor %} |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + {% endfor %} |
| 109 | + </div> |
| 110 | + {% endfor %} |
| 111 | + </div> |
| 112 | + </div> |
| 113 | + |
| 114 | + {% if site.posts.size == 0 %} |
| 115 | + <div class="text-center py-12"> |
| 116 | + <p class="text-gray-600 text-lg">No blog posts available yet.</p> |
| 117 | + </div> |
| 118 | + {% endif %} |
| 119 | + </main> |
| 120 | + |
| 121 | + <!-- Sidebar - Hidden on mobile --> |
| 122 | + <aside class="hidden lg:block w-80 flex-shrink-0"> |
| 123 | + {% include blog-sidebar.html %} |
| 124 | + </aside> |
| 125 | + </div> |
| 126 | +</div> |
| 127 | + |
| 128 | +<script> |
| 129 | +// Handle URL parameters for filtering and deep linking to specific months |
| 130 | +document.addEventListener('DOMContentLoaded', function() { |
| 131 | + const urlParams = new URLSearchParams(window.location.search); |
| 132 | + const month = urlParams.get('month'); |
| 133 | + |
| 134 | + if (month) { |
| 135 | + // Find the month section |
| 136 | + const monthSections = document.querySelectorAll('.month-section'); |
| 137 | + let targetSection = null; |
| 138 | + |
| 139 | + for (const section of monthSections) { |
| 140 | + if (section.dataset.month === month) { |
| 141 | + targetSection = section; |
| 142 | + break; |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + if (targetSection) { |
| 147 | + // Show filtered view |
| 148 | + const filteredView = document.getElementById('filtered-view'); |
| 149 | + const allContent = document.getElementById('all-content'); |
| 150 | + const filteredTitle = document.getElementById('filtered-title'); |
| 151 | + const filteredPosts = document.getElementById('filtered-posts'); |
| 152 | + |
| 153 | + // Hide all content and show filtered view |
| 154 | + allContent.style.display = 'none'; |
| 155 | + filteredView.style.display = 'block'; |
| 156 | + |
| 157 | + // Set the title |
| 158 | + filteredTitle.textContent = month; |
| 159 | + |
| 160 | + // Copy the posts from the target section |
| 161 | + const postsContainer = targetSection.querySelector('.space-y-6'); |
| 162 | + if (postsContainer) { |
| 163 | + filteredPosts.innerHTML = postsContainer.innerHTML; |
| 164 | + } |
| 165 | + } else { |
| 166 | + // Month not found, show all content (fallback) |
| 167 | + console.warn('Month not found:', month); |
| 168 | + } |
| 169 | + } |
| 170 | +}); |
| 171 | +</script> |
0 commit comments