astro-indexnow 2.3.5 → 2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +36 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -2
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -6,7 +6,7 @@ to **IndexNow** after each build.
|
|
|
6
6
|
This package is designed for **modern CI/CD pipelines**, **Docker-based deployments**, and
|
|
7
7
|
**large static sites**, while remaining fully deterministic and explicit.
|
|
8
8
|
|
|
9
|
-
> **Current release:** v2.3.
|
|
9
|
+
> **Current release:** v2.3.7
|
|
10
10
|
> **Stateful by design. `changed` by default, `all` available. Batch-safe. CI-aware.**
|
|
11
11
|
|
|
12
12
|
---
|
|
@@ -137,6 +137,20 @@ Using environment variables is **strongly recommended** for CI/CD.
|
|
|
137
137
|
This release is backwards compatible with earlier supported package versions.
|
|
138
138
|
Older npm versions are not deprecated by default; they remain supported until a future major release introduces a breaking change.
|
|
139
139
|
|
|
140
|
+
## Migration Notes
|
|
141
|
+
|
|
142
|
+
### From v1
|
|
143
|
+
|
|
144
|
+
- v1 submitted all generated pages after each build
|
|
145
|
+
- v2 and later add cache-based changed-only submissions
|
|
146
|
+
- if you upgrade from v1, the first build may submit more URLs because the cache starts empty
|
|
147
|
+
|
|
148
|
+
### From v2
|
|
149
|
+
|
|
150
|
+
- v2.1 added `cacheDir`
|
|
151
|
+
- v2.3 added `submissionMode`, `dryRun`, `logMode`, `batchSize`, and retry controls
|
|
152
|
+
- the current build-time behavior remains compatible with static and hybrid builds
|
|
153
|
+
|
|
140
154
|
---
|
|
141
155
|
|
|
142
156
|
## How It Works
|
|
@@ -155,6 +169,23 @@ This ensures:
|
|
|
155
169
|
- No unnecessary API calls
|
|
156
170
|
- Accurate change detection based on real output
|
|
157
171
|
|
|
172
|
+
## What Gets Submitted
|
|
173
|
+
|
|
174
|
+
Only generated HTML pages are scanned and considered for submission.
|
|
175
|
+
|
|
176
|
+
Included:
|
|
177
|
+
- generated `index.html` pages
|
|
178
|
+
- static pages emitted into the final build output
|
|
179
|
+
|
|
180
|
+
Ignored:
|
|
181
|
+
- assets
|
|
182
|
+
- RSS or XML feeds
|
|
183
|
+
- JavaScript bundles
|
|
184
|
+
- images
|
|
185
|
+
- any other non-HTML outputs
|
|
186
|
+
|
|
187
|
+
This integration does not inspect source files directly. It only works from final build output.
|
|
188
|
+
|
|
158
189
|
---
|
|
159
190
|
|
|
160
191
|
## State & Cache File (Important)
|
|
@@ -167,10 +198,12 @@ To detect changes between builds, the integration stores a small cache file:
|
|
|
167
198
|
|
|
168
199
|
This file:
|
|
169
200
|
- Is created automatically
|
|
170
|
-
- Contains
|
|
201
|
+
- Contains a small version marker plus URL → hash mappings
|
|
171
202
|
- Contains **no secrets**
|
|
172
203
|
- Is safe to inspect, commit, or delete
|
|
173
204
|
|
|
205
|
+
Older flat cache files are still read automatically and will be upgraded on the next write.
|
|
206
|
+
|
|
174
207
|
Deleting the file simply causes the next build to treat all pages as new.
|
|
175
208
|
|
|
176
209
|
---
|
|
@@ -362,6 +395,7 @@ Controls the maximum backoff delay between retries.
|
|
|
362
395
|
- No reliance on Git history
|
|
363
396
|
- Deterministic output-based change detection
|
|
364
397
|
- Intended for static and hybrid builds, not SSR request-time submission
|
|
398
|
+
- Build-time only; use a webhook or server-side flow for SSR updates
|
|
365
399
|
|
|
366
400
|
---
|
|
367
401
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAM9C,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,cAAc,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAM9C,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,cAAc,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAOD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CAsVlB"}
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,16 @@ export default function indexNow(options = {}) {
|
|
|
48
48
|
function loadCache(logger) {
|
|
49
49
|
logger.debug("loading cache file");
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
const parsed = JSON.parse(fs.readFileSync(cachePath, "utf8"));
|
|
52
|
+
if (parsed &&
|
|
53
|
+
typeof parsed === "object" &&
|
|
54
|
+
"version" in parsed &&
|
|
55
|
+
parsed.version === 1 &&
|
|
56
|
+
"entries" in parsed &&
|
|
57
|
+
typeof parsed.entries === "object") {
|
|
58
|
+
return parsed.entries;
|
|
59
|
+
}
|
|
60
|
+
return parsed;
|
|
52
61
|
}
|
|
53
62
|
catch {
|
|
54
63
|
logger.warn("cache file unreadable, resetting");
|
|
@@ -57,7 +66,11 @@ export default function indexNow(options = {}) {
|
|
|
57
66
|
}
|
|
58
67
|
function saveCache(logger, data) {
|
|
59
68
|
logger.debug("writing cache file");
|
|
60
|
-
|
|
69
|
+
const cacheFile = {
|
|
70
|
+
version: 1,
|
|
71
|
+
entries: data,
|
|
72
|
+
};
|
|
73
|
+
fs.writeFileSync(cachePath, JSON.stringify(cacheFile, null, 2), "utf8");
|
|
61
74
|
}
|
|
62
75
|
function chunk(array, size) {
|
|
63
76
|
const chunks = [];
|
|
@@ -169,12 +182,15 @@ export default function indexNow(options = {}) {
|
|
|
169
182
|
if (entry.isDirectory())
|
|
170
183
|
walk(fullPath);
|
|
171
184
|
if (entry.isFile() && entry.name === "index.html") {
|
|
185
|
+
// Astro emits one index.html per generated route, so this is the
|
|
186
|
+
// canonical build artifact to hash and submit.
|
|
172
187
|
const relativePath = path
|
|
173
188
|
.relative(outDir, fullPath)
|
|
174
189
|
.replace(/index\.html$/, "")
|
|
175
190
|
.replace(/\\/g, "/");
|
|
176
191
|
const url = site + "/" + relativePath.replace(/^\/+/, "");
|
|
177
192
|
const hash = hashFile(fullPath);
|
|
193
|
+
// Cache by URL because IndexNow submits URLs, not filesystem paths.
|
|
178
194
|
nextCache[url] = hash;
|
|
179
195
|
if (previousCache[url] !== hash) {
|
|
180
196
|
changedUrls.push(url);
|
|
@@ -183,6 +199,8 @@ export default function indexNow(options = {}) {
|
|
|
183
199
|
}
|
|
184
200
|
}
|
|
185
201
|
walk(outDir);
|
|
202
|
+
const scannedCount = Object.keys(nextCache).length;
|
|
203
|
+
const changedCount = changedUrls.length;
|
|
186
204
|
logVerbose(logger, "page diff:");
|
|
187
205
|
for (const url of Object.keys(nextCache)) {
|
|
188
206
|
const state = previousCache[url] === nextCache[url]
|
|
@@ -201,7 +219,9 @@ export default function indexNow(options = {}) {
|
|
|
201
219
|
return;
|
|
202
220
|
}
|
|
203
221
|
const batches = chunk(urlsToSubmit, batchSize);
|
|
222
|
+
const batchCount = batches.length;
|
|
204
223
|
logInfo(logger, `submitting ${urlsToSubmit.length} URL(s) in ${batches.length} batch(es) [mode=${options.submissionMode ?? "changed"}, batchSize=${batchSize}]`);
|
|
224
|
+
logInfo(logger, `summary: scanned=${scannedCount}, changed=${changedCount}, batched=${batchCount}, submitted=${urlsToSubmit.length}`);
|
|
205
225
|
if (isVerbose()) {
|
|
206
226
|
logVerbose(logger, "planned URL list:");
|
|
207
227
|
for (const url of urlsToSubmit) {
|