Refactor duplicated code in layouts and portfolio display#94
Draft
Refactor duplicated code in layouts and portfolio display#94
Conversation
Co-authored-by: adrianmg <589285+adrianmg@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor duplicated code in application
Refactor duplicated code in layouts and portfolio display
Oct 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR eliminates significant code duplication across the Jekyll static site, improving maintainability and following DRY (Don't Repeat Yourself) principles.
Changes
1. Layout Inheritance Refactoring
Before: The
_layouts/home.htmlfile duplicated the entire HTML boilerplate structure that was already defined in_layouts/default.html:After:
home.htmlnow properly extendsdefault.htmlusing Jekyll's layout inheritance:The
default.htmllayout was updated to conditionally apply the "home" body class, maintaining all existing styling.Impact: Eliminates ~30 lines of duplicate HTML structure and establishes a single source of truth for the base layout.
2. Data-Driven Portfolio Display
Before: The
_includes/home-work.htmlfile contained 7 nearly identical blocks of HTML for displaying portfolio projects (165 lines), with each project manually coded:After: Implemented a data-driven approach with three components:
_data/projects.yml- Structured YAML data containing all project information:_includes/project.html- Reusable template for rendering a single project (15 lines)_includes/home-work.html- Simplified to loop over projects data (28 lines):{% for project in site.data.projects %} {% include project.html project=project is_first=forloop.first %} {% endfor %}Impact: Reduces portfolio display code from 165 lines to 28 lines. Adding or updating portfolio projects now requires editing YAML data instead of HTML markup.
Benefits
Testing
Stats
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.