Skip to content

fix(tutorials): use filesystem reads with English fallback#17151

Merged
pettinarip merged 3 commits into
devfrom
fix/tutorial-fetching-fallback
Jan 28, 2026
Merged

fix(tutorials): use filesystem reads with English fallback#17151
pettinarip merged 3 commits into
devfrom
fix/tutorial-fetching-fallback

Conversation

@minimalsm
Copy link
Copy Markdown
Contributor

@minimalsm minimalsm commented Jan 23, 2026

Summary

Refactors tutorial content loading to use filesystem reads instead of HTTP requests during build. This change:

  • Eliminates ~5,000 build warnings - No more "Failed to fetch tutorial" 404 errors for locales without translations
  • Uses English fallback - Non-English locales now show English tutorial content when translations don't exist (matching the pattern used by importMd for other content)
  • Adds isTranslated flag - Enables future UI indicators for untranslated content
  • Faster builds - Filesystem reads are faster than HTTP requests to production

Changes

  • src/lib/utils/md.ts: Switch from fetch() to fs.readFile() with fallback logic
  • src/lib/types.ts: Add isTranslated?: boolean to ITutorial interface

Context

During builds, getTutorialsData() was making HTTP requests to fetch tutorial markdown files from the production site. For the 15 locales without any tutorial translations, this resulted in ~900 failed requests each (60 tutorials × 15 locales = 900 404s per build).

This PR aligns tutorial fetching with the existing importMd pattern used for other content, which reads from filesystem and falls back to English.

Test Plan

  • TypeScript compiles without errors
  • ESLint passes
  • Netlify preview build completes without "Failed to fetch tutorial" warnings
  • Tutorial pages render correctly for English locale
  • Tutorial pages render correctly for non-English locales (shows English fallback)

Closes #17150

Refactor getTutorialsData to read tutorial content from the filesystem
instead of making HTTP requests to the production site during build.

Changes:
- Switch from fetch() to fs.readFile() for tutorial content
- Add English fallback when translations don't exist
- Add isTranslated field to ITutorial interface
- Remove unused SITE_URL import

This eliminates ~5000 "Failed to fetch tutorial" 404 warnings during
builds for locales without tutorial translations. Instead of silently
dropping tutorials, non-English locales now display English content
with isTranslated: false flag for potential UI indicators.

Closes #17150
@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 23, 2026

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 8eb43ce
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/697a0e6316c1c700088ed977
😎 Deploy Preview https://deploy-preview-17151.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 57 (🟢 up 1 from production)
Accessibility: 94 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the tooling 🔧 Changes related to tooling of the project label Jan 23, 2026
Copy link
Copy Markdown
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! Those warnings were annoying 😄

Heads up: the dynamic imports add ~4 MB to the function bundle (Webpack bundles all matching files when it sees variable paths). Since this page is static, we can just use fs.readFile instead — same result, no bundle bloat.

I was already planning to do this for importMd too (for all static md files), so I'll include this in that PR.

Comment thread src/lib/utils/md.ts Outdated
@pettinarip pettinarip merged commit 73dad13 into dev Jan 28, 2026
8 checks passed
@pettinarip pettinarip deleted the fix/tutorial-fetching-fallback branch January 28, 2026 14:59
@pettinarip pettinarip mentioned this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tooling 🔧 Changes related to tooling of the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Tutorial fetching should fall back to English like other content

2 participants