Skip to content

Commit 7e9206e

Browse files
committed
Implement custom category section layouts and reusable component for filtering posts by category/tag
1 parent 794c562 commit 7e9206e

File tree

9 files changed

+830
-91
lines changed

9 files changed

+830
-91
lines changed

CUSTOM-MODIFICATIONS.md

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
# Custom Theme Modifications Summary
2+
3+
This document outlines all custom modifications made to the Icarus theme.
4+
5+
## Overview
6+
Your theme uses the built-in Icarus configuration system effectively, with minimal custom code modifications focused on improving the post reading experience.
7+
8+
---
9+
10+
## Custom Modifications
11+
12+
### 1. Post Page Layout (✅ Custom Code)
13+
**Files Modified:**
14+
- `themes/icarus/layout/layout.jsx`
15+
- `themes/icarus/layout/common/widgets.jsx`
16+
17+
**Changes:**
18+
- **Left Sidebar**: Shows only TOC widget on post pages
19+
- **Right Sidebar**: Hidden on post pages
20+
- **Main Content**: Expanded to 75% width (9/12 columns) on widescreen
21+
- **Left Sidebar Width**: Reduced to 25% (3/12 columns) on post pages
22+
23+
**Why Custom Code Needed:**
24+
Icarus doesn't provide built-in config to hide specific widgets per layout type, so custom logic was added.
25+
26+
**Code Location:**
27+
```javascript
28+
// themes/icarus/layout/layout.jsx
29+
if (page.layout === 'post' && columnCount === 3) {
30+
columnCount = 2;
31+
isPostWithLeftSidebar = true;
32+
}
33+
34+
// themes/icarus/layout/common/widgets.jsx
35+
if (page.layout === 'post' && position === 'right') {
36+
return null; // Hide right sidebar
37+
}
38+
const filteredWidgets = page.layout === 'post' && position === 'left'
39+
? widgets.filter(widget => widget.type === 'toc') // Only TOC
40+
: widgets;
41+
```
42+
43+
---
44+
45+
### 2. Category Section Layouts (✅ Custom Code)
46+
**Files Created:**
47+
- `themes/icarus/layout/common/category-posts.jsx` (reusable component)
48+
- `themes/icarus/layout/blogs.jsx`
49+
- `themes/icarus/layout/photography.jsx`
50+
- `themes/icarus/layout/life.jsx`
51+
52+
**Purpose:**
53+
Create custom landing pages that filter and display posts by category/tag.
54+
55+
**Why Custom Code Needed:**
56+
The built-in `category.jsx` layout requires Hexo's category system integration. Custom layouts give more flexibility for creating section landing pages independent of Hexo's category hierarchy.
57+
58+
**Usage:**
59+
- `/blogs/` page uses `blogs.jsx` to show all posts with "blogs" category/tag
60+
- `/photography/` page uses `photography.jsx` for "photography" posts
61+
- `/life/` page uses `life.jsx` for "life" posts
62+
63+
---
64+
65+
### 3. Category Layout Fix (✅ Custom Code)
66+
**File Modified:**
67+
- `themes/icarus/layout/category.jsx`
68+
69+
**Change:**
70+
Added null check for `page.parents` to prevent errors:
71+
```javascript
72+
{page.parents && page.parents.map(category => {
73+
return <li><a href={url_for(category.path)}>{category.name}</a></li>;
74+
})}
75+
```
76+
77+
**Why Needed:**
78+
The original theme assumed all category pages have a `parents` array, which caused crashes for top-level categories.
79+
80+
---
81+
82+
## Configurations Using Built-in Features (✅ No Custom Code)
83+
84+
All of these are configured via `_config.icarus.yml` without custom code:
85+
86+
### 1. Sticky Left Sidebar
87+
```yaml
88+
sidebar:
89+
left:
90+
sticky: true # TOC follows scroll
91+
right:
92+
sticky: false
93+
```
94+
95+
### 2. TOC Widget Settings
96+
```yaml
97+
widgets:
98+
-
99+
position: left
100+
type: toc
101+
index: true
102+
collapsed: true
103+
depth: 3
104+
```
105+
106+
### 3. Code Highlighting
107+
```yaml
108+
article:
109+
highlight:
110+
theme: atom-one-light
111+
clipboard: true
112+
fold: unfolded
113+
```
114+
115+
### 4. Read Time & Update Time
116+
```yaml
117+
article:
118+
readtime: true
119+
update_time: true
120+
```
121+
122+
### 5. Navigation & Footer
123+
```yaml
124+
navbar:
125+
menu:
126+
Home: /
127+
Archives: /archives
128+
Blogs: /blogs
129+
Photography: /photography
130+
Categories: /categories
131+
Tags: /tags
132+
dark_mode_toggle: true
133+
```
134+
135+
### 6. Profile Widget
136+
```yaml
137+
widgets:
138+
-
139+
position: left
140+
type: profile
141+
author: Siva Sravana Kumar Neeli
142+
author_title: Sr. ML Engineer
143+
location: Dallas, TX
144+
avatar: /img/profile_pic.png
145+
# ... social links
146+
```
147+
148+
---
149+
150+
## Configuration Strategy Analysis
151+
152+
### ✅ What's Done Right
153+
154+
1. **Using Built-in Features First**
155+
- Most settings use Icarus's configuration system
156+
- No redundant custom code for features that exist
157+
158+
2. **Sticky Sidebar**
159+
- ✅ Using `sidebar.left.sticky: true` (built-in)
160+
- ❌ NOT implemented via custom CSS
161+
162+
3. **TOC Configuration**
163+
- ✅ Using widget configuration (built-in)
164+
- ❌ NOT hardcoded
165+
166+
4. **Per-Post Overrides**
167+
- Can override any config in post front matter
168+
- No need for separate config files
169+
170+
### 🔧 Custom Code is Justified
171+
172+
1. **Post Layout Changes**
173+
- Icarus doesn't support per-layout widget filtering
174+
- Custom code is necessary
175+
176+
2. **Category Section Pages**
177+
- More flexible than built-in category system
178+
- Allows custom landing pages
179+
- Justified customization
180+
181+
3. **Category Layout Fix**
182+
- Bug fix for missing null check
183+
- Should be contributed back to Icarus theme
184+
185+
---
186+
187+
## Recommended Actions
188+
189+
### Keep As-Is ✅
190+
- Custom post layout modifications (improves UX)
191+
- Category section layouts (adds flexibility)
192+
- Category layout fix (fixes bug)
193+
- All built-in configurations
194+
195+
### Consider Creating `_config.post.yml` (Optional)
196+
If you want ALL posts to have specific settings without front matter:
197+
198+
```yaml
199+
# _config.post.yml
200+
toc: true
201+
article:
202+
highlight:
203+
theme: atom-one-dark
204+
```
205+
206+
This would apply to all posts by default, but can still be overridden in individual post front matter.
207+
208+
### Not Needed ❌
209+
- Custom CSS for sticky sidebar (built-in works)
210+
- Custom TOC implementation (widget system works)
211+
- Separate layout files for categories (unless you want custom styling)
212+
213+
---
214+
215+
## File Structure Summary
216+
217+
```
218+
├── _config.icarus.yml # Main theme config (✅ Uses built-in features)
219+
├── themes/icarus/layout/
220+
│ ├── layout.jsx # Modified: Post layout width (✅ Custom)
221+
│ ├── category.jsx # Modified: Null check fix (✅ Custom)
222+
│ ├── blogs.jsx # Created: Custom section (✅ Custom)
223+
│ ├── photography.jsx # Created: Custom section (✅ Custom)
224+
│ ├── life.jsx # Created: Custom section (✅ Custom)
225+
│ └── common/
226+
│ ├── widgets.jsx # Modified: Post widget filtering (✅ Custom)
227+
│ └── category-posts.jsx # Created: Reusable component (✅ Custom)
228+
└── source/
229+
├── blogs/index.md # Uses blogs.jsx layout
230+
├── photography/index.md # Uses photography.jsx layout
231+
└── life/index.md # Uses life.jsx layout
232+
```
233+
234+
---
235+
236+
## Conclusion
237+
238+
Your theme configuration is **well-optimized**:
239+
240+
1. ✅ Uses built-in features wherever possible
241+
2. ✅ Custom code is minimal and justified
242+
3. ✅ No redundant implementations
243+
4. ✅ Follows Icarus configuration patterns
244+
5. ✅ Easy to maintain and extend
245+
246+
**No changes needed** - your current setup is clean and efficient!
247+
248+
---
249+
250+
**Date**: November 8, 2025
251+
**Theme Version**: Icarus 5.1.0

0 commit comments

Comments
 (0)