Skip to content

Commit 7e5c765

Browse files
committed
Merge pull request #1 from scholtz/patch-1
2 parents 3a695f0 + 56ba3d0 commit 7e5c765

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/routes/pages/projects/directory/+page.svelte

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
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 = () => {
@@ -20,10 +23,24 @@
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 {
@@ -174,4 +191,4 @@
174191
href="/pages/funding/bounties"
175192
/>
176193
</svelte:fragment>
177-
</SubSectionTemplate>
194+
</SubSectionTemplate>

tailwind.config.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)