Skip to content

Make DocSearch optional and update example data - Fix the build error#725

Open
222448082Ashen wants to merge 1 commit intothoth-tech:mainfrom
222448082Ashen:fix/build-error
Open

Make DocSearch optional and update example data - Fix the build error#725
222448082Ashen wants to merge 1 commit intothoth-tech:mainfrom
222448082Ashen:fix/build-error

Conversation

@222448082Ashen
Copy link
Copy Markdown

Description

This PR improves build resilience in Astro config and refreshes usage example metadata for docs content quality.

Summary of changes:

  • Refactored astro.config.mjs to load environment values via Vite loadEnv.
  • Derived DOCSEARCH values from loaded env and introduced a hasDocSearchConfig guard.
  • Replaced hard process exit with a warning when DocSearch variables are missing.
  • Included DocSearch integration only when all required variables are present.
  • Made link validation conditional with ENABLE_STRICT_LINKS so local builds do not fail by default.
  • Updated guides-groups.json with capitalization changes for selected guide groups (for example Camera and Graphics).
  • Updated usage-example-references.json with reorganized entries, title refinements, and additional examples across color, geometry, graphics, and windows.

Related issue:

  • Fixes local build failures caused by missing DocSearch environment variables.
  • Closes # (replace with the actual issue if available).

Motivation and context:

  • Local contributors should be able to build without production search credentials.
  • CI can still enforce stricter validation when explicitly enabled.
  • Usage example metadata updates improve discoverability and content consistency.

Dependencies required for this change:

  • No new package dependencies.
  • Optional environment variable: DOCSEARCH_API_ID.
  • Optional environment variable: DOCSEARCH_API_SEARCH_KEY.
  • Optional environment variable: DOCSEARCH_INDEX_NAME.
  • Optional environment variable: ENABLE_STRICT_LINKS.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (update or new)

How Has This Been Tested?

Tests run:

  1. npm run build
  2. Verified static build completes successfully when DocSearch vars are absent (with warning fallback behavior)

Repro steps:

  1. Ensure DOCSEARCH variables are unset locally.
  2. Run npm run build.
  3. Confirm build succeeds and DocSearch is skipped gracefully.
  4. Optionally set ENABLE_STRICT_LINKS=true and rerun to validate strict link-check behavior.

Testing Checklist

  • Tested in latest Chrome
  • Tested in latest Firefox
  • npm run build
  • npm run preview

Checklist

If involving code:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

If modified config files:

  • I have checked package.json for changes
  • I have checked astro.config.mjs for changes
  • I have checked netlify.toml for changes
  • I have checked container compose config for changes
  • I have checked custom.css for changes

Folders and Files Added/Modified

Added:

  • None

Modified:

  • astro.config.mjs
  • guides-groups.json
  • usage-example-references.json

Additional Notes

  • DocSearch is intentionally optional outside environments where credentials are available.
  • Strict link validation remains available through ENABLE_STRICT_LINKS for CI or targeted local checks.

Refactor astro.config.mjs to load env via Vite's loadEnv and derive DOCSEARCH_* vars from the loaded env. Add a hasDocSearchConfig check and emit a warning instead of exiting when DocSearch vars are missing; include starlightDocSearch only when configured. Also make starlightLinksValidator conditional based on ENABLE_STRICT_LINKS to avoid failing local builds. Update scripts/json-files: capitalize some guide group names (e.g. "camera" -> "Camera", "graphics" -> "Graphics") and modify usage-example-references.json with many new and reorganized example entries, title tweaks, and additional examples for color, geometry, graphics, and windows.
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 6, 2026

Deploy Preview for splashkit ready!

Name Link
🔨 Latest commit 9d82624
🔍 Latest deploy log https://app.netlify.com/projects/splashkit/deploys/69d36cd7aa70a50008d8c504
😎 Deploy Preview https://deploy-preview-725--splashkit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@222448082Ashen 222448082Ashen changed the title Make DocSearch optional and update example data Make DocSearch optional and update example data - Fix the build error Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant