Skip to content

Add search URL params - #282

Merged
AGulev merged 2 commits into
defold:masterfrom
goranovs:feature/asset-filter-url-state
Jul 30, 2026
Merged

Add search URL params#282
AGulev merged 2 commits into
defold:masterfrom
goranovs:feature/asset-filter-url-state

Conversation

@goranovs

@goranovs goranovs commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes: #281

Changes:

  • Changes in asset-portal-filter.js
  • Reads q, tag, and sort from query parameters.
  • Preserves layout-provided tag/sort defaults when parameters are absent.
  • Updates the URL using history.replaceState.
  • Preserves unrelated query parameters and URL hashes.
  • Removes default values (tag=all, sort=stars) for cleaner URLs.
  • Restores filters on popstate.
  • Keeps existing analytics behavior unchanged.
assets_search_url.mp4

@britzl
britzl requested review from AGulev and paweljarosz July 29, 2026 21:31
Comment thread js/asset-portal-filter.js
@AGulev

AGulev commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Looks good to me. Let’s wait to see what @paweljarosz thinks.

Thank you for your contribution!

Comment thread js/asset-portal-filter.js

const search = params.toString();
const nextUrl = `${window.location.pathname}${search ? `?${search}` : ""}${window.location.hash}`;
window.history.replaceState(window.history.state, "", nextUrl);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is a frequent call to replaceState at every input, but I'm not sure if this will be much of an issue in production, compared to the benefits of the PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a valid question. I don’t think this should be an issue. replaceState() is relatively lightweight and, unlike pushState(), doesn’t create a new history entry on every input. It only updates the current URL without triggering navigation or reloading the page.

@paweljarosz paweljarosz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (beside a small comment above), thank you so much for the contribution! <3

@goranovs

Copy link
Copy Markdown
Contributor Author

The build looks green✅!

P.S. In my next PR I will migrate the webiste to HUGO 😄 20 minutes build is a bit too much!

@AGulev
AGulev merged commit eca3b82 into defold:master Jul 30, 2026
1 check passed
@britzl

britzl commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

The build looks green✅!

P.S. In my next PR I will migrate the webiste to HUGO 😄 20 minutes build is a bit too much!

Yeah, it has ballooned out of proportion. We chose Jekyll because it was the default for GitHub Pages, but we could migrate to something else, such as Hugo, which is supposed to be a lot faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Asset Portal search shareable through the URL

4 participants