-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed query-string, use goto svelte for url state changes #97
Conversation
onMount(() => { | ||
if (location.search.length < 1) return; // early terminate if no search | ||
let givenstate = queryString.parse(location.search); | ||
if (!Array.isArray(givenstate.show)) givenstate.show = [givenstate.show]; | ||
// if (!givenstate.show.includes('Essays')) essays = false; | ||
// if (!givenstate.show.includes('Talks')) talks = false; | ||
// if (!givenstate.show.includes('Podcasts')) podcasts = false; | ||
// if (!givenstate.show.includes('Tutorials')) tutorials = false; | ||
// if (!givenstate.show.includes('Snippets')) snippets = false; | ||
// if (!givenstate.show.includes('Notes')) notes = false; | ||
if (givenstate.filter) search = givenstate.filter; | ||
urlState = { ...defaultURLState, ...givenstate }; | ||
}); | ||
function saveURLState() { | ||
setTimeout(() => { | ||
setURLState({ | ||
filter: search, | ||
show: [ | ||
// essays && 'Essays', | ||
// talks && 'Talks', | ||
// podcasts && 'Podcasts', | ||
// snippets && 'Snippets', | ||
// tutorials && 'Tutorials', | ||
// notes && 'Notes' | ||
].filter(Boolean) | ||
}); | ||
}, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14691a7
Fixed the URLs to be updated with search filter.
appreciate the PR! left some thoughts before merging, curious what you think. let me know if you are interested in being a maintainer as well - i just ask that you send every change in as a PR so that we can discuss first and I can keep track |
Co-authored-by: swyx <shawnthe1@gmail.com>
I think URL parameter name should be changed as below for a more clear naming:
Let me know if that looks ok. |
almost! when you go to here: https://deploy-preview-97--swyxkit.netlify.app/blog?filter=test&show=Blog the "show" code is dropped somehow |
i tried fixing it but couldnt find the source of the bug - i can get back to it in future, thank you for the contribution, it is very valued. |
Fixed. |
@@ -49,6 +49,7 @@ See https://swyxkit.netlify.app/ (see [Deploy Logs](https://app.netlify.com/site | |||
- **Minor design/UX touches** | |||
- Top level blog URLs (`/myblog` instead of `/blog/myblog` - [why](https://www.swyx.io/namespacing-sites/)) | |||
- Blog index truncates at 20 posts to make sure to render quickly | |||
- Blog search/facets serialize to URLs for easy copy paste ([thanks @Ak4zh](https://github.com/sw-yx/swyxkit/pull/97)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added attribution to you @ak4zh :)
thank you so much! |
query-string
lib as the same task can be achieved with svelte '$page.url.searchParams`goto
instead.