Refactor duplicated code across layouts, stylesheets, and JavaScript#110
Draft
Refactor duplicated code across layouts, stylesheets, and JavaScript#110
Conversation
- Consolidate HTML boilerplate by making home.html extend default.html - Add support for body_class parameter in default layout - Create reusable CSS placeholders for common transition patterns - Create reusable CSS placeholder for brand color hover state - Replace 6 duplicate transition declarations with @extend - Replace 4 duplicate hover color declarations with @extend - Reduce code duplication and improve maintainability Co-authored-by: adrianmg <589285+adrianmg@users.noreply.github.com>
- Create getCurrentTime() helper to eliminate code duplication - Replace two identical time calculation expressions with function call - Improve code maintainability and readability in scrollToItem function Co-authored-by: adrianmg <589285+adrianmg@users.noreply.github.com>
Co-authored-by: adrianmg <589285+adrianmg@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor duplicated code to improve maintainability
Refactor duplicated code across layouts, stylesheets, and JavaScript
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 refactors duplicated code patterns across HTML layouts, SCSS stylesheets, and JavaScript files to improve maintainability and follow DRY (Don't Repeat Yourself) principles. All changes are pure refactoring with no functional modifications.
Changes
HTML Layout Consolidation
The
_layouts/home.htmlfile was duplicating the entire HTML boilerplate structure (DOCTYPE, html, head, body tags) from_layouts/default.html. This has been refactored:Before:
After:
--- layout: default body_class: home --- <!-- content -->The
default.htmllayout now supports an optionalbody_classparameter for flexible styling, making it reusable across all layouts.CSS Refactoring
Created reusable SCSS placeholders in
_sass/_base.scssto eliminate repeated transition and hover patterns:These placeholders replaced 10 duplicate CSS declarations throughout
_sass/_layout.scss:Example transformation:
JavaScript Refactoring
Extracted duplicated time calculation logic in
assets/js/s.js:Before:
After:
Benefits
Testing
Files Changed
_layouts/default.html- Added body_class parameter support_layouts/home.html- Refactored to extend default layout_sass/_base.scss- Added reusable CSS placeholders_sass/_layout.scss- Replaced duplicates with @extendassets/js/s.js- Extracted getCurrentTime() helper functionOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.