Add "Back to documentation" link in 404 page#1020
Open
VictorPuga wants to merge 4 commits into
Open
Conversation
Extract the first module from interfaceLanguages in the index data and link to it on the NotFound page. Falls back to /documentation if no module is found or the index fetch fails. Includes translations for en-US, ja-JP, zh-CN, and ko-KR. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add the back-to-documentation string to de-DE, es-419, fr-FR, it-IT, and pt-BR locale files to complete the translations for the 404 page link. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The link container now conditionally renders based on whether the documentation path was successfully fetched, preventing broken links when the index cannot be accessed. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Tests verify that the back link renders when a module is available, handles missing modules, graceful error handling, and correctly selects the first module across languages. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a conditional "Back to Documentation" link to the 404 (Not Found) page that intelligently directs users to the first available module in the documentation. The implementation fetches the index data on page load and extracts the first module; if found, a link to that module is displayed. If no module is found or the fetch fails, the link is not rendered. Translations are provided for en-US, ja-JP, zh-CN, ko-KR, de-DE, es-419, fr-FR, it-IT, and pt-BR locales.
Based on the forum thread: https://forums.swift.org/t/improving-the-user-experience-at-the-documentation-archive-index/86433
Dependencies
None.
Testing
http://localhost:8080/nonexistent-page).Checklist
npm test, and it succeeded