11<script lang =" ts" >
2+ import { goto } from ' $app/navigation' ;
3+ import { page } from ' $app/stores' ;
24 import SubSectionTemplate from ' $lib/components/SubSectionTemplate.svelte' ;
35 import Section from ' $lib/components/Section.svelte' ;
46 import InfoTile from ' $lib/components/InfoTile.svelte' ;
57 import ActionTile from ' $lib/components/ActionTile.svelte' ;
68 import { projects } from ' $lib/data/projects' ;
79 import { onMount } from ' svelte' ;
10+ import { get } from ' svelte/store' ;
811
912 // Get unique project types for filter, with type safety
1013 const getUniqueTypes = () => {
2023 const projectTypes = getUniqueTypes ();
2124 const statuses = [' All' , ' active' , ' inactive' ] as const ;
2225
23- let selectedType = ' All' ;
26+ const urlParams = get (page ).url .searchParams ;
27+ let selectedType = urlParams .get (' type' ) || ' All' ;
28+ let prevType = ' All' ;
2429 let selectedStatus = ' All' ;
2530 let filteredProjects = [... projects ];
2631
32+ $ : if (selectedType !== prevType ) {
33+ prevType = selectedType ;
34+ updateQueryParam (' type' , selectedType );
35+ }
36+ function updateQueryParam(key : string , value : string ) {
37+ const currentUrl = new URL (window .location .href );
38+ currentUrl .searchParams .set (key , value );
39+ if (key == ' type' ) {
40+ selectedType = value ;
41+ }
42+ goto (` ${currentUrl .pathname }?${currentUrl .searchParams .toString ()} ` , { replaceState: true });
43+ }
2744 // Filter projects based on selected type and status
2845 $ : {
2946 try {
174191 href =" /pages/funding/bounties"
175192 />
176193 </svelte:fragment >
177- </SubSectionTemplate >
194+ </SubSectionTemplate >
0 commit comments