File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,24 @@ function syncThemeColor(theme) {
4646
4747document . addEventListener ( 'DOMContentLoaded' , function ( ) {
4848
49+ // Sort project cards lexicographically (alphabetically) by title
50+ var projectsGrid = document . querySelector ( '.projects-grid' ) ;
51+ var rawCards = projectsGrid ? Array . from ( projectsGrid . querySelectorAll ( '.project-card' ) ) : [ ] ;
52+ if ( rawCards . length > 0 ) {
53+ rawCards . sort ( function ( a , b ) {
54+ var h3A = a . querySelector ( 'h3' ) ;
55+ var h3B = b . querySelector ( 'h3' ) ;
56+ var titleA = h3A ? h3A . textContent . trim ( ) : '' ;
57+ var titleB = h3B ? h3B . textContent . trim ( ) : '' ;
58+ return titleA . localeCompare ( titleB ) ;
59+ } ) ;
60+ var reorderedCards = document . createDocumentFragment ( ) ;
61+ rawCards . forEach ( function ( card ) {
62+ reorderedCards . appendChild ( card ) ;
63+ } ) ;
64+ projectsGrid . appendChild ( reorderedCards ) ;
65+ }
66+
4967 // ── DOM references ──────────────────────────────────────────────
5068 var html = document . documentElement ;
5169 var themeToggle = document . getElementById ( 'themeToggle' ) ;
You can’t perform that action at this time.
0 commit comments