Skip to content

Conversation

Copy link

Copilot AI commented Oct 24, 2025

This PR refactors several instances of code duplication throughout the codebase to improve maintainability and reduce redundancy.

Changes

1. Eliminated HTML Layout Duplication

The home.html layout was duplicating the entire HTML structure (DOCTYPE, html, head, and body tags) from default.html. This has been refactored so that home.html now extends default.html:

Before:

<!DOCTYPE html>
<html lang="en">
{% include head.html %}
<body class="home">
  <!-- content -->
</body>
</html>

After:

---
layout: default
body_class: home
---
<!-- content -->

The default.html layout now supports an optional body_class parameter to add CSS classes to the body tag, making it more flexible and reusable.

2. Removed Unused JavaScript Code

Removed the scrollToItem helper function (62 lines) from assets/js/s.js that was never used anywhere in the codebase. This function was a legacy scrolling utility that is no longer needed.

3. Consolidated SCSS Transition Patterns

Extracted repeated transition styles into reusable SCSS placeholders to follow DRY principles:

%transition-base {
  transition: all var(--base-trans) ease-in-out;
}

%transition-mid {
  transition: all var(--base-trans-mid) ease-in-out;
}

%transition-slow {
  transition: all var(--base-trans-slow) ease-in-out;
}

Updated 6 instances in _layout.scss that were duplicating these transition patterns to use the new placeholders via @extend.

Impact

  • Net reduction: 48 lines of code (97 removed, 49 added)
  • Maintainability: Changes to transitions can now be made in one place
  • Consistency: Ensures all transition styles remain consistent
  • No functional changes: Site behavior remains unchanged
Original prompt

Find and refactor duplicated code


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Refactor duplicated code for better maintainability Refactor duplicated code in layouts, JavaScript, and SCSS Oct 24, 2025
Copilot AI requested a review from adrianmg October 24, 2025 18:06
Copilot finished work on behalf of adrianmg October 24, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants