astro-indexnow 2.0.0 → 2.1.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Velohost Technologies
3
+ Copyright (c) 2025-2026 Velohost UK Limited
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -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
- > **Version:** v2.0.0
9
+ > **Version:** v2.1.1
10
10
  > **Stateful by design. Changed-only submissions. Batch-safe. CI-aware.**
11
11
 
12
12
  ---
@@ -217,6 +217,17 @@ indexnow({ enabled: false })
217
217
 
218
218
  ---
219
219
 
220
+ ### `cacheDir` (optional)
221
+
222
+ Type: `string`
223
+ Default: `process.cwd()`
224
+
225
+ The directory where the `.astro-indexnow-cache.json` file will be stored. Can be an absolute path or relative to the project root.
226
+
227
+ Example: `./node_modules/.astro`
228
+
229
+ ---
230
+
220
231
  ## IndexNow Limits & Batching
221
232
 
222
233
  - IndexNow allows **up to 10,000 URLs per request**
@@ -247,6 +258,12 @@ such as `@astrojs/sitemap`:
247
258
 
248
259
  ---
249
260
 
261
+ ## Contributors
262
+
263
+ - Thanks to **@web-projects-lab** for adding the configurable `cacheDir` option.
264
+
265
+ ---
266
+
250
267
  ## Maintainer
251
268
 
252
269
  Built and maintained by **Velohost**
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export interface IndexNowOptions {
3
3
  key?: string;
4
4
  siteUrl?: string;
5
5
  enabled?: boolean;
6
+ cacheDir?: string;
6
7
  }
7
8
  export default function indexNow(options?: IndexNowOptions): AstroIntegration;
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAK9C,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CAiMlB"}
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;CACnB;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CAyMlB"}
package/dist/index.js CHANGED
@@ -1,17 +1,25 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import crypto from "crypto";
4
+ import { fileURLToPath } from "url";
4
5
  export default function indexNow(options = {}) {
5
6
  let site = null;
6
7
  const CACHE_FILENAME = ".astro-indexnow-cache.json";
7
8
  const projectRoot = process.cwd();
8
- const cachePath = path.join(projectRoot, CACHE_FILENAME);
9
+ const cachePath = options.cacheDir
10
+ ? path.resolve(projectRoot, options.cacheDir, CACHE_FILENAME)
11
+ : path.join(projectRoot, CACHE_FILENAME);
9
12
  const INDEXNOW_ENDPOINT = "https://api.indexnow.org/indexnow";
10
13
  const INDEXNOW_BATCH_SIZE = 10_000;
11
14
  /* =========================================================
12
15
  Helpers
13
16
  ========================================================= */
14
17
  function ensureCacheFile(logger) {
18
+ const dir = path.dirname(cachePath);
19
+ if (!fs.existsSync(dir)) {
20
+ logger.debug(`[astro-indexnow] creating cache directory: ${dir}`);
21
+ fs.mkdirSync(dir, { recursive: true });
22
+ }
15
23
  const exists = fs.existsSync(cachePath);
16
24
  logger.debug(`[astro-indexnow] cache exists: ${exists} (${cachePath})`);
17
25
  if (!exists) {
@@ -77,7 +85,7 @@ export default function indexNow(options = {}) {
77
85
  throw new Error("[astro-indexnow] Missing site URL");
78
86
  }
79
87
  ensureCacheFile(logger);
80
- const outDir = new URL(dir).pathname;
88
+ const outDir = fileURLToPath(dir instanceof URL ? dir : new URL(dir));
81
89
  const previousCache = loadCache(logger);
82
90
  const nextCache = {};
83
91
  const changedUrls = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-indexnow",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Astro integration to submit pages to IndexNow automatically after build",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,7 +23,7 @@
23
23
  "yandex"
24
24
  ],
25
25
  "peerDependencies": {
26
- "astro": "^4.0.0 || ^5.0.0"
26
+ "astro": "^4.0.0 || ^5.0.0 || ^6.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^25.0.3",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://github.com/velohost/astro-indexnow"
34
+ "url": "git+https://github.com/velohost/astro-indexnow.git"
35
35
  },
36
36
  "homepage": "https://velohost.co.uk/astro-indexnow",
37
37
  "bugs": {