Refactor duplicated code across HTML layouts, CSS, and JavaScript #92
+70
−54
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 addresses code duplication across the repository by refactoring HTML layouts, SCSS styles, and JavaScript code with minimal, surgical changes that maintain all existing functionality.
Changes Made
HTML Layout Refactoring
The
_layouts/home.htmlfile was duplicating the entire HTML document structure (DOCTYPE, html, head, body tags) from_layouts/default.html. This has been refactored so thathome.htmlnow uses Jekyll's layout inheritance:Before:
After:
To support this change,
_layouts/default.htmlnow accepts an optionalbody_classparameter, making it more flexible for future use.Meta Tags Consolidation
Open Graph and Twitter meta tags were hardcoded in
_includes/head.html. These have been extracted into a new reusable include_includes/meta-tags.htmlthat supports page-level overrides:{% include meta-tags.html %}This allows individual pages to override default values for title, description, and OG image by setting front matter variables like
page.og_image,page.og_image_width, etc.CSS Transition Patterns
Repeated transition declarations were consolidated using SCSS mixins and placeholder classes:
Before:
After:
This pattern was applied to 6 instances across
_sass/_layout.scss, creating three reusable placeholders:%transition-base,%transition-mid, and%transition-slow.JavaScript Optimization
The
scrollToItemfunction inassets/js/s.jshad duplicate logic for getting the current time:Before:
After:
CSS Cleanup
Removed outdated vendor prefixes that are no longer needed for modern browsers:
-webkit-transition: none→transition: none-moz-box-sizing: border-box→box-sizing: border-boxTesting
Impact
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.