feat(vite): add IndexNow build plugin#13
Conversation
Add a production-only Vite plugin that submits sitemap manifest URLs to IndexNow after builds, with a local verification-key guard for non-deploy environments.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughA new Vite plugin file ChangesIndexNow Vite Plugin
Sequence Diagram(s)sequenceDiagram
participant ViteBuild
participant indexNowPlugin
participant FileSystem
participant IndexNowAPI
ViteBuild->>indexNowPlugin: configResolved(config)
indexNowPlugin->>indexNowPlugin: store root, evaluate shouldSubmit
ViteBuild->>indexNowPlugin: closeBundle()
alt shouldSubmit is false
indexNowPlugin-->>ViteBuild: skip
else shouldSubmit is true
indexNowPlugin->>indexNowPlugin: check globalThis dedup map for existing promise
indexNowPlugin->>FileSystem: readFile(sitemap-manifest.json)
FileSystem-->>indexNowPlugin: manifest JSON
indexNowPlugin->>FileSystem: access(<key>.txt)
FileSystem-->>indexNowPlugin: exists or ENOENT
alt key file missing
indexNowPlugin-->>ViteBuild: log warning, skip
else key file present
indexNowPlugin->>indexNowPlugin: filter by excludePrefixes, normalize + deduplicate URLs
indexNowPlugin->>IndexNowAPI: POST endpoint (key, host, urlList)
IndexNowAPI-->>indexNowPlugin: 200 Accepted / error status
alt failOnError true and error
indexNowPlugin-->>ViteBuild: throw Error
else failOnError false
indexNowPlugin-->>ViteBuild: log warning
end
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Adds a shared docs-kit Vite plugin for IndexNow submissions so docs projects can stop carrying their own
deploy:indexnowscript. The plugin runs only for production Vite builds and skips submission when the local verification key file is missing, which keeps local builds quiet.Changes
✨ New features
indexNowPlugin()to submit sitemap-manifest URLs to IndexNow after production builds.indexNowPluginandIndexNowOptionsfrom@humanspeak/docs-kit/vite.🔧 Safeguards
apply: 'build'and Viteproductionmode by default.static/<key>.txtis missing, withkeyFilePath: falseavailable for custom verification setups.🧪 Testing
pnpm checkpnpm buildpnpm exec prettier --check src/lib/vite/indexnow.ts src/lib/vite/index.tsCommits
904cc13feat(vite): add IndexNow build plugin