Refactor duplicated code across layouts, stylesheets, and JavaScript #110
+64
−49
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.