Commit c78c127
authored
fix: update word filtering and path generation in browse page (#156)
### Description
<!-- Please add PR description (don't leave blank) - example: This PR
[adds/removes/fixes/replaces] the [feature/bug/etc] -->
This pull request updates the logic for browsing dictionary words by
alphabet to use the `id` property instead of the deprecated `slug`
property, and introduces a new utility function for building word slugs.
The changes improve type safety and future-proof the code against
upstream type changes.
**Refactoring for type safety and future compatibility:**
* Updated the filtering logic in `getStaticPaths` to use `word.id[0]`
instead of `word.slug[0]`, addressing a TypeScript type issue and
aligning with the latest data structure.
([src/pages/browse/[alpha]/[page].astroL20-R20](diffhunk://#diff-c87fe48708b5daee9f4aa138cb2970623ed74a334fa0912fef67f3a71905ee39L20-R20))
* Changed the word link rendering to use `buildWordSlug(word.id)` in
combination with `buildWordPathname`, ensuring consistent slug
generation from the new `id` property.
([src/pages/browse/[alpha]/[page].astroL48-R47](diffhunk://#diff-c87fe48708b5daee9f4aa138cb2970623ed74a334fa0912fef67f3a71905ee39L48-R47))
* Imported the new `buildWordSlug` utility from `lib/utils/index.js` to
support the updated slug-building logic.
([src/pages/browse/[alpha]/[page].astroL7-R8](diffhunk://#diff-c87fe48708b5daee9f4aa138cb2970623ed74a334fa0912fef67f3a71905ee39L7-R8))1 parent 2221e36 commit c78c127
1 file changed
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | | - | |
| 47 | + | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
0 commit comments