Skip to content

feat(astro-seo-graph): add indexNowOnBranch for branch-gated IndexNow submission#59

Merged
jdevalk merged 2 commits into
jdevalk:mainfrom
gregturn:feat/conditional-indexnow
Jul 7, 2026
Merged

feat(astro-seo-graph): add indexNowOnBranch for branch-gated IndexNow submission#59
jdevalk merged 2 commits into
jdevalk:mainfrom
gregturn:feat/conditional-indexnow

Conversation

@gregturn

@gregturn gregturn commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Problem

The indexNow integration submits IndexNow submissions for every branch unconditionally. This means that platforms that deploy preview branches (Cloudflare Pages, Vercel, Netlify), will submit preview branches to IndexNow using the same key as production — URLs the production host hasn't served yet. That wastes daily quota and risks getting the key flagged invalid, forcing a rotation.

There's no built-in way to conditionalize submission; users either accept the unconditional behaviour or write their own branch-detection wrapper, which is what prompted this patch.

What This Adds

indexNowOnBranch(branch, options, productionBranch?) — a thin helper exported from @jdevalk/astro-seo-graph/integration (and re-exported from the main entry).

It passes IndexNowIntegrationOptions through unchanged when branch matches productionBranch (default "main") and returns undefined otherwise, so seoGraph() skips submission entirely on non-production deploys.

Here is an example of usage (CloudFlare-specific):

// astro.config.mjs
import { defineConfig } from 'astro/config';
import seoGraph, { indexNowOnBranch } from '@jdevalk/astro-seo-graph/integration';

export default defineConfig({
    integrations: [
        seoGraph({
            indexNow: indexNowOnBranch(process.env.CF_PAGES_BRANCH ?? '', {
                key: process.env.INDEXNOW_KEY,
                host: 'example.com',
                siteUrl: 'https://example.com',
            }),
        }),
    ],
});

NOTE: Existing configs that pass IndexNowIntegrationOptions directly are unaffected, making this a NON-BREAKING change.

Documentation is added to the existing IndexNow sections.

Verification

Test suite expanded with 4 new cases covering indexNowOnBranch

gregturn and others added 2 commits July 6, 2026 08:59
…on only on production branch

Preview and feature-branch builds share the same IndexNow key as
production but shouldn't notify search engines — submitting preview
URLs wastes daily quota and can get the key flagged invalid (the host
hasn't served those URLs yet).

indexNowOnBranch(branch, options, productionBranch?) passes
IndexNowIntegrationOptions through unchanged when branch matches
productionBranch (default "main") and returns undefined otherwise, so
seoGraph() skips submission entirely on non-production deploys.

Pair with your CI platform's branch variable:
- Cloudflare Pages: process.env.CF_PAGES_BRANCH
- Vercel:           process.env.VERCEL_GIT_COMMIT_REF
- Netlify:          process.env.BRANCH
…xnow

# Conflicts:
#	packages/astro-seo-graph/README.md
#	packages/astro-seo-graph/src/index.ts
@jdevalk
jdevalk merged commit 29426cb into jdevalk:main Jul 7, 2026
1 check passed
jdevalk added a commit that referenced this pull request Jul 7, 2026
* Version Packages

* docs(changelog): note indexNowOnBranch (#59) in 2.1.0 release notes

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Joost de Valk <joost@altha.nl>
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.

2 participants