jargonsdev / jargonsdev/jargons.dev

Implement Redirect to First Page Route for Alphabetical Browse

Open
#61 2 comments 0 reactions 0 assignees View on GitHub
:arrow_upper_right: medium priority :sparkles: enhancement hacktoberfest
Dominant language
MDX
Stars
56
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Currently, when a user visits the `/browse/[alpha]` (example "/browse/a") route, they receive a 404 error. This issue requests implementing a redirect to the first page route (`/browse/[alpha]/1` i.e. "/browse/a/1") when a user visits `/browse/[alpha]`. This will ensure a smoother browsing experience for users.

**Steps to Implement:**
1. Detect when a user visits the `/browse/[alpha]` route without specifying a page number.
2. Redirect the user to the first page route (`/browse/[alpha]/1`).

**Implementation Note:**
- The following code snippet could be implemented into a `/browse/[alpha]/index.astro` file to handle the redirection:

```astro
---
/**
* Redirect traffic from `/[alpha]` to `/[alpha]/1` to avoid 404 error
*/
return Astro.redirect(`${Astro.params.alpha}/1`);
---
```

However, there's a build conflict with `/browse/[...slug]`, so it's important to understand the [Route Priority Order](https://docs.astro.build/en/guides/routing/#route-priority-order) for this to work.

**Acceptance Criteria:**
- When a user visits the `/browse/[alpha]` route, they should be automatically redirected to the first page route (`/browse/[alpha]/1`).
- The redirect should happen seamlessly without any additional user input.

**Additional Information:**
- This enhancement will improve user experience by ensuring that users are directed to the correct page when browsing alphabetically.
- It's important to state that I have tried the stated implementation in the implementation note and experienced the conflict myself, It worked by redirecting, but the words route that gets built from `src/content/dictionary` were also getting the redirects; not nice 😞

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the existing /browse/[...slug] route and the routes serving content from src/content/dictionary, then read Astro's Route Priority Order guidance linked in the issue. Add handling for /browse/[alpha] that redirects to /browse/[alpha]/1 without redirecting dictionary word routes, and verify both behaviors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.