fix: use Vite virtual module for configuration instead of global state

The initial config-store approach failed because Astro's injected routes
run in isolated contexts during prerendering and don't have access to
global state set during astro:config:setup.

Solution: Created a Vite plugin that provides the configuration through
a virtual module (virtual:@astrojs/discovery/config) which routes can
import at build time.

Changes:
- Added Vite plugin in astro:config:setup hook
- Updated all route handlers to import from virtual module
- Changed version from date-based (2025.11.03) to semantic (1.0.0) per npm requirements
- Added @ts-ignore comments for virtual module imports

Testing: Verified in test project that all configuration now properly
passes through to generated files (robots.txt, llms.txt, humans.txt).
This commit is contained in:
Ryan Malloy 2025-11-03 07:51:14 -07:00
parent d25dde4627
commit c7b47bba5c
8 changed files with 594 additions and 8 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@astrojs/discovery",
"version": "2025.11.03",
"version": "1.0.0",
"description": "Complete discovery integration for Astro - handles robots.txt, llms.txt, humans.txt, and sitemap generation",
"type": "module",
"exports": {