Add random “Tip of the Week” widget to homepage - #148
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6927db7984
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| refreshButton.addEventListener("click", showRandomTip); | ||
|
|
||
| fetch(sourceUrl, { headers: { "Accept": "application/json" } }) |
There was a problem hiding this comment.
Guard the Fetch API before invoking it
In browsers or embedded webviews without the Fetch API, this call throws a synchronous ReferenceError, so the promise .catch() is never reached and the widget remains stuck on “Loading a tip…” rather than displaying its graceful fallback. Feature-detect window.fetch and invoke the same fallback path when it is unavailable.
Useful? React with 👍 / 👎.
Motivation
Description
layouts/partials/tip-of-the-week.htmland included it inlayouts/index.htmlto render the tip card and a deferred script.static/js/tip-of-the-week.jsto fetch the JSON feed, flexibly normalize entries, validate/whitelist HTTP(S) links, choose a non-repeating random tip, and expose a refresh control.static/css/custom.cssto match the site design and adapt to mobile layouts.Testing
node --check static/js/tip-of-the-week.js, which completed successfully.fetchand DOM elements and validated expected rendering and refresh behavior, which passed.hugo --minify) could not be executed in the environment because Hugo is not installed, so the final site build and visual screenshot were not generated.Codex Task