@@ -961,6 +961,35 @@ function filterByTags() {
961961
962962 // Update results count and type
963963 updateResultsCount ( visibleApis + visibleSkills , selectedType ) ;
964+
965+ // Update URL with current filter
966+ updateURLWithFilter ( selectedType ) ;
967+ }
968+
969+ function updateURLWithFilter ( filterType ) {
970+ const url = new URL ( window . location ) ;
971+ if ( filterType && filterType !== 'all' ) {
972+ url . searchParams . set ( 'filter' , filterType ) ;
973+ localStorage . setItem ( 'homepage-filter' , filterType ) ;
974+ } else {
975+ url . searchParams . delete ( 'filter' ) ;
976+ localStorage . removeItem ( 'homepage-filter' ) ;
977+ }
978+ console . log ( 'Updating URL to:' , url . toString ( ) ) ;
979+ window . history . replaceState ( { } , '' , url ) ;
980+ }
981+
982+ function getFilterFromURL ( ) {
983+ const url = new URL ( window . location ) ;
984+ const urlFilter = url . searchParams . get ( 'filter' ) ;
985+
986+ // Priority: URL parameter > localStorage > default 'all'
987+ if ( urlFilter ) {
988+ return urlFilter ;
989+ }
990+
991+ const savedFilter = localStorage . getItem ( 'homepage-filter' ) ;
992+ return savedFilter || 'all' ;
964993}
965994
966995function updateResultsCount ( count , filterType ) {
@@ -1127,6 +1156,19 @@ document.addEventListener('DOMContentLoaded', () => {
11271156 } ) ;
11281157 } ) ;
11291158
1159+ // Initialize filter from URL on page load
1160+ const urlFilter = getFilterFromURL ( ) ;
1161+ console . log ( 'URL filter:' , urlFilter ) ;
1162+ if ( urlFilter !== 'all' ) {
1163+ const targetTab = document . querySelector ( `.hero-tab[data-filter="${ urlFilter } "]` ) ;
1164+ console . log ( 'Target tab:' , targetTab ) ;
1165+ if ( targetTab ) {
1166+ heroTabs . forEach ( t => t . classList . remove ( 'active' ) ) ;
1167+ targetTab . classList . add ( 'active' ) ;
1168+ filterByTags ( ) ;
1169+ }
1170+ }
1171+
11301172 // Set up tag search input
11311173 const tagSearchInput = document . getElementById ( 'tagSearchInput' ) ;
11321174 const tagSearchContainer = document . getElementById ( 'tagSearchInputContainer' ) ;
@@ -7133,6 +7175,22 @@ function toggleParamDescription(button) {
71337175 return direction === 'asc'
71347176 ? aValue . localeCompare ( bValue )
71357177 : bValue . localeCompare ( aValue ) ;
7178+ } else if ( sortBy === 'type' ) {
7179+ aValue = a . getAttribute ( 'data-type' ) || '' ;
7180+ bValue = b . getAttribute ( 'data-type' ) || '' ;
7181+ // Sort by type, then by name as secondary sort
7182+ const typeCompare = direction === 'asc'
7183+ ? aValue . localeCompare ( bValue )
7184+ : bValue . localeCompare ( aValue ) ;
7185+
7186+ if ( typeCompare !== 0 ) {
7187+ return typeCompare ;
7188+ }
7189+
7190+ // Secondary sort by name
7191+ const aName = a . getAttribute ( 'data-name' ) || '' ;
7192+ const bName = b . getAttribute ( 'data-name' ) || '' ;
7193+ return aName . localeCompare ( bName ) ;
71367194 } else if ( sortBy === 'endpoints' ) {
71377195 // Extract count from the badge text (endpoints for APIs, steps for Skills)
71387196 const aCard = a . querySelector ( '.badge-count' ) ;
0 commit comments