Skip to content

Conversation

@steadyfall
Copy link
Contributor

This PR improves the blog tag handling logic to ensure a cleaner user experience when navigating blog pages.

  • Redirect when tag is missing or empty
    • Trim whitespace from activeTag
    • Redirect to /blog if no valid tag is present or URL contains an empty ?tag=
  • Redirect when tag has no posts
    • Redirect users to /blog if an active tag is specified but no posts exist for it

Below are examples of broken/empty tag links:

  • /blog?tag
  • /blog?tag=
  • /blog?tag=%20%20
  • /blog?tag=Infra
  • /blog?tag=%20%20Infra

- Add `useEffect` to check `router.query.tag` and redirect to `/blog` if:
  - no tag is provided
  - tag is an empty string or only whitespace
  - URL contains `?tag=` with no value
- Trim `activeTag` to avoid false positives from whitespace
- Use `useEffect` to redirect to `/blog` if active tag exists but has zero posts
- Prevent users from landing on empty tag pages
@steadyfall steadyfall force-pushed the tag-exception-handling branch from 8fdf165 to 861dbb3 Compare October 2, 2025 23:46
@steadyfall steadyfall closed this Oct 6, 2025
wato-github-automation bot pushed a commit that referenced this pull request Oct 6, 2025
## Description

<!--- Please provide a summary of your changes. Make sure to include
relevant motivation, context, and link related documents/conversations.
-->

#47

- Redirect when tag is missing or empty
  - Trim whitespace from `activeTag`
- Redirect to `/blog` if no valid tag is present or URL contains an
empty `?tag=`
- Redirect when tag has no posts
- Redirect users to `/blog` if an active tag is specified but no posts
exist for it

<!--- Use [linking
keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
like `Resolves #<issue_number>` to automatically close issues. -->


## Checklist
- [x] I have read and understood the [WATcloud
Guidelines](https://cloud.watonomous.ca/docs/community-docs/watcloud/guidelines)
- [x] I have performed a self-review of my code
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.

1 participant